def record_vertices_in_file(nexus_wrapper: nx.NexusWrapper, group: h5py.Group, new_vertices: List[QVector3D]): """ Record vertex data in file :param nexus_wrapper: Wrapper for the file the data will be stored in :param group: The shape group node :param new_vertices: The new vertices data, list of cartesian coords for each vertex """ vertices = [qvector3d_to_numpy_array(vertex) for vertex in new_vertices] vertices_node = nexus_wrapper.set_field_value(group, CommonAttrs.VERTICES, vertices) nexus_wrapper.set_attribute_value(vertices_node, CommonAttrs.UNITS, "m")
def test_validate_dataset_does_not_report_problem_when_expected_attribute_is_present( ): nexus_wrapper = NexusWrapper() dataset_name = "test_dataset" dataset = nexus_wrapper.set_field_value(nexus_wrapper.nexus_file, dataset_name, 0) attr_name = "test_attribute" nexus_wrapper.set_attribute_value(dataset, attr_name, 0) validator = ValidateDataset(dataset_name, attributes={attr_name: None}) problems = [] validator.check(nexus_wrapper.nexus_file, problems) assert ( len(problems) == 0 ), "Expected there to be no reported problem because attribute is present"
def test_validate_dataset_reports_problem_when_attribute_does_not_have_expected_value( ): nexus_wrapper = NexusWrapper() dataset_name = "test_dataset" dataset = nexus_wrapper.set_field_value(nexus_wrapper.nexus_file, dataset_name, 0) attr_name = "test_attribute" attr_value = 42 nexus_wrapper.set_attribute_value(dataset, attr_name, attr_value) expected_value = 0 validator = ValidateDataset(dataset_name, attributes={attr_name: expected_value}) problems = [] validator.check(nexus_wrapper.nexus_file, problems) assert ( len(problems) > 0 ), "Expected there to be a reported problem because attribute does not have expected value"