From 3b99fe8ef50a4630725abea440a6b353d092dde9 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Mon, 29 Apr 2024 11:13:27 +0200 Subject: [PATCH] Final fix in atoms_state.py module testing Fix normalize in model_system.py --- src/nomad_simulations/atoms_state.py | 1 - src/nomad_simulations/model_system.py | 19 ++++++++++--------- tests/test_atoms_state.py | 6 ++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/nomad_simulations/atoms_state.py b/src/nomad_simulations/atoms_state.py index 9d21f3d9..1b810c84 100644 --- a/src/nomad_simulations/atoms_state.py +++ b/src/nomad_simulations/atoms_state.py @@ -23,7 +23,6 @@ from structlog.stdlib import BoundLogger from nomad.units import ureg - from nomad.metainfo import Quantity, SubSection, MEnum, Section, Context from nomad.datamodel.data import ArchiveSection from nomad.datamodel.metainfo.basesections import Entity diff --git a/src/nomad_simulations/model_system.py b/src/nomad_simulations/model_system.py index 7f46d385..7303b1bb 100644 --- a/src/nomad_simulations/model_system.py +++ b/src/nomad_simulations/model_system.py @@ -563,13 +563,13 @@ def resolve_bulk_symmetry( symmetry['hall_symbol'] = symmetry_analyzer.get_hall_symbol() symmetry['point_group_symbol'] = symmetry_analyzer.get_point_group() symmetry['space_group_number'] = symmetry_analyzer.get_space_group_number() - symmetry[ - 'space_group_symbol' - ] = symmetry_analyzer.get_space_group_international_short() + symmetry['space_group_symbol'] = ( + symmetry_analyzer.get_space_group_international_short() + ) symmetry['origin_shift'] = symmetry_analyzer._get_spglib_origin_shift() - symmetry[ - 'transformation_matrix' - ] = symmetry_analyzer._get_spglib_transformation_matrix() + symmetry['transformation_matrix'] = ( + symmetry_analyzer._get_spglib_transformation_matrix() + ) # Populating the originally parsed AtomicCell wyckoff_letters and equivalent_atoms information original_wyckoff = symmetry_analyzer.get_wyckoff_letters_original() @@ -627,6 +627,8 @@ def resolve_bulk_symmetry( return primitive_atomic_cell, conventional_atomic_cell def normalize(self, archive, logger) -> None: + super().normalize(archive, logger) + atomic_cell = get_sibling_section( section=self, sibling_section_name='cell', logger=logger ) @@ -712,6 +714,8 @@ def resolve_chemical_formulas(self, formula: Formula) -> None: self.anonymous = formula.format('anonymous') def normalize(self, archive, logger) -> None: + super().normalize(archive, logger) + atomic_cell = get_sibling_section( section=self, sibling_section_name='cell', logger=logger ) @@ -957,9 +961,6 @@ def resolve_system_type_and_dimensionality( return system_type, dimensionality def normalize(self, archive, logger) -> None: - # ! Patch done in order to test when passing archive=None. This should be covered by default in all normalize functions - if not archive: - return super().normalize(archive, logger) # We don't need to normalize if the system is not representative diff --git a/tests/test_atoms_state.py b/tests/test_atoms_state.py index af48e76e..bcb6b7dd 100644 --- a/tests/test_atoms_state.py +++ b/tests/test_atoms_state.py @@ -75,8 +75,7 @@ def test_check_quantum_numbers( if number_label == 'ml_quantum_number': orbital_state.l_quantum_number = 2 setattr(orbital_state, number_label, val) - check = orbital_state._check_quantum_numbers(logger) - assert check == res + assert orbital_state._check_quantum_numbers(logger) == res @pytest.mark.parametrize( 'quantum_name, value, expected_result', @@ -157,8 +156,7 @@ def test_degeneracy( j_quantum_number, mj_quantum_number, ) - resolved_degeneracy = orbital_state.resolve_degeneracy() - assert resolved_degeneracy == degeneracy + assert orbital_state.resolve_degeneracy() == degeneracy def test_normalize(self): """