def container_factory(self, name, primitive_cell, size, origin): self.group = self.handle.create_group(self.handle.root, name) return H5Lattice.create_new(self.group, primitive_cell, size, origin, record=CustomRecord)
def test_version(self): filename = os.path.join(self.temp_dir, "test_file.cuds") group_name = "dummy_component_name" with tables.open_file(filename, "w") as handle: group = handle.create_group(handle.root, group_name) # given/when H5Lattice.create_new(group, PrimitiveCell.for_cubic_lattice(0.2), size=(5, 10, 15), origin=(-2, 0, 1)) # then self.assertTrue(isinstance(group._v_attrs.cuds_version, int)) # when with tables.open_file(filename, "a") as handle: handle.get_node("/{}".format(group_name))._v_attrs.cuds_version = -1 # then with tables.open_file(filename, "a") as handle: with self.assertRaises(ValueError): H5Lattice(handle.get_node("/" + group_name))
def test_version(self): filename = os.path.join(self.temp_dir, 'test_file.cuds') group_name = "dummy_component_name" with tables.open_file(filename, 'w') as handle: group = handle.create_group(handle.root, group_name) # given/when H5Lattice.create_new(group, PrimitiveCell.for_cubic_lattice(0.2), size=(5, 10, 15), origin=(-2, 0, 1)) # then self.assertTrue(isinstance(group._v_attrs.cuds_version, int)) # when with tables.open_file(filename, 'a') as handle: handle.get_node( "/{}".format(group_name))._v_attrs.cuds_version = -1 # then with tables.open_file(filename, 'a') as handle: with self.assertRaises(ValueError): H5Lattice(handle.get_node("/" + group_name))
def _add_lattice(self, lattice): """Add lattice to the file. Parameters ---------- lattice : Lattice lattice to be added Returns ---------- H5Lattice The lattice newly added to the file. """ name = lattice.name lattice_root = self._root.lattice group = tables.Group(lattice_root, name=name, new=True) h5_lattice = H5Lattice.create_new( group, lattice.primitive_cell, lattice.size, lattice.origin) h5_lattice.data = lattice.data h5_lattice.update_nodes(lattice.iter_nodes())
def container_factory(self, name, primitive_cell, size, origin): self.group = self.handle.create_group(self.handle.root, name) return H5Lattice.create_new(self.group, primitive_cell, size, origin)