def read(self): hdf5_file = read(self.input_file_path) group = hdf5_file[GROUP_SIMULATION] self.version = group.attrs[ATTRIBUTE_VERSION] logger.info("File version: {}".format(self.version)) self.options.read(group) self.results.read(group)
def test_read(): file_path = get_current_module_path(__file__, "../../../test_data/test_Source.hdf5") if not os.path.isfile(file_path): # pragma: no cover pytest.skip("File does not exist: {}".format(file_path)) hdf5_file = read(file_path) source = Source() source.read(hdf5_file) _compare_values(source)
def test_read(): file_path = get_current_module_path( __file__, "../../../test_data/test_Element.hdf5") if not os.path.isfile(file_path): # pragma: no cover pytest.skip("File does not exist: {}".format(file_path)) hdf5_file = read(file_path) element = Element() element.read(hdf5_file) assert element != get_vacuum_element() assert element == get_silicon_element()
def test_read(): file_path = get_current_module_path( __file__, "../../../test_data/test_Material.hdf5") if not os.path.isfile(file_path): # pragma: no cover pytest.skip("File does not exist: {}".format(file_path)) hdf5_file = read(file_path) material = Material() material.read(hdf5_file) assert material != get_vacuum_material() assert material == get_silicon_material()
def test_write(tmpdir): file_path = tmpdir.join("output.hdf5") point = Point(-1, -2, -3) hdf5_file = write(file_path) point.write(hdf5_file) hdf5_file.close() point = Point(1, 2, 3) hdf5_file = read(file_path) point.read(hdf5_file) assert point.x == -1 assert point.y == -2 assert point.z == -3
def test_write(tmpdir): file_path = tmpdir.join("output.hdf5") element = get_silicon_element() hdf5_file = write(file_path) element.write(hdf5_file) hdf5_file.close() element = Element() hdf5_file = read(file_path) element.read(hdf5_file) assert element != get_vacuum_element() assert element == get_silicon_element()
def test_point_read(): file_path = get_current_module_path(__file__, "../../test_data/test_Point.hdf5") if not os.path.isfile(file_path): # pragma: no cover pytest.skip("File does not exist: {}".format(file_path)) hdf5_file = read(file_path) point = Point(0, 0, 0) assert point.x != 1 assert point.y != 2 assert point.z != 3 point.read(hdf5_file) assert point.x == 1 assert point.y == 2 assert point.z == 3
def test_write(tmpdir): file_path = tmpdir.join("output.hdf5") material = get_silicon_material() hdf5_file = write(file_path) material.write(hdf5_file) hdf5_file.close() material = Material() hdf5_file = read(file_path) material.read(hdf5_file) assert material != get_vacuum_material() material_si = get_silicon_material() assert material == material_si
def test_write_read(tmpdir): file_path = tmpdir.join("output.hdf5") hdf5_file = write(file_path) assert hdf5_file.filename == file_path assert hdf5_file.mode == "r+" assert hdf5_file.driver == "core" assert hdf5_file.userblock_size == 0 hdf5_file.close() hdf5_file = read(file_path) assert hdf5_file.filename == file_path assert hdf5_file.mode == "r" assert hdf5_file.driver == "core" assert hdf5_file.userblock_size == 0
def test_write(tmpdir): file_path = tmpdir.join("output.hdf5") source = Source() source.position_nm = Point(-1, -2, -3) source.direction = Point(0.2, 0.4, 0.6) source.kinetic_energy_keV = 53.1156 source.mass_amu = 68.93 source.atomic_number = 31 hdf5_file = write(file_path) source.write(hdf5_file) hdf5_file.close() source = Source() hdf5_file = read(file_path) source.read(hdf5_file) _compare_values(source)