Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion simphony/io/h5_cuds.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _add_mesh(self, mesh, cuba_keys):
item.data = DataContainer(
{key: item.data[key] for key in item.data
if key in cuba_keys[CUDSItem.EDGE]})
h5_mesh.add_points([item])
h5_mesh.add_edges([item])

for item in mesh.iter_faces():
item.data = DataContainer(
Expand Down
16 changes: 14 additions & 2 deletions simphony/io/tests/test_h5_cuds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from simphony.io.h5_mesh import H5Mesh
from simphony.io.h5_particles import H5Particles
from simphony.io.h5_lattice import H5Lattice
from simphony.cuds import Mesh, Particles
from simphony.cuds import Mesh, Particles, Point, Edge, Face, Cell
from simphony.cuds.lattice import make_cubic_lattice

from simphony.testing.abc_check_engine import (
Expand Down Expand Up @@ -187,13 +187,25 @@ def test_add_get_dataset_with_cuba_keys_argument(self):
expected = self.create_dataset(name='test')

# Add some CUBA data
for point in items:
for point in [p for p in items if isinstance(p, Point)]:
point.data = DataContainer({CUBA.VELOCITY: [1, 0, 0]})
expected.add_points([point])
point.data = DataContainer(
{CUBA.VELOCITY: [1, 0, 0], CUBA.MASS: 1})
reference.add_points([point])

for edge in [e for e in items if isinstance(e, Edge)]:
expected.add_edges([edge])
reference.add_edges([edge])

for face in [f for f in items if isinstance(f, Face)]:
expected.add_faces([face])
reference.add_faces([face])

for cell in [c for c in items if isinstance(c, Cell)]:
expected.add_cells([cell])
reference.add_cells([cell])

# Store reference dataset along with its data
engine.add_dataset(reference, {CUDSItem.POINT: [CUBA.VELOCITY]})

Expand Down
32 changes: 29 additions & 3 deletions simphony/testing/abc_check_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@

from simphony.core.cuba import CUBA
from simphony.cuds.particles import Particle, Particles
from simphony.cuds.mesh import Point, Mesh
from simphony.cuds.mesh import Edge, Face, Cell, Point, Mesh
from simphony.cuds.lattice import make_cubic_lattice


def grouper(iterable, group_size):
"""Given an iterable, returns groups of size group_size.
Excess entries are not included.

>>> grouper('abcdefg', 3)
[('a', 'b', 'c'), ('d', 'e', 'f')]
"""
iters = [iter(iterable)]*group_size
return zip(*iters)


class CheckEngine(object):

__metaclass__ = abc.ABCMeta
Expand Down Expand Up @@ -263,9 +274,24 @@ def create_dataset_items(self):
""" Create and return a list of items
"""
items = []
point_uids = []
for i in xrange(10):
items.append(
Point((1.1*i, 2.2*i, 3.3*i), uid=uuid.uuid4()))
point = Point((1.1*i, 2.2*i, 3.3*i), uid=uuid.uuid4())
items.append(point)
point_uids.append(point.uid)

for edge_points in grouper(point_uids, 2):
edge = Edge(edge_points, uid=uuid.uuid4())
items.append(edge)

for face_points in grouper(point_uids, 4):
face = Face(face_points, uid=uuid.uuid4())
items.append(face)

for cell_points in grouper(point_uids, 8):
cell = Cell(cell_points, uid=uuid.uuid4())
items.append(cell)

return items


Expand Down