Skip to content

Commit

Permalink
Final fix in atoms_state.py module testing
Browse files Browse the repository at this point in the history
Fix normalize in model_system.py
  • Loading branch information
JosePizarro3 committed Apr 29, 2024
1 parent 846f47f commit 3b99fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/nomad_simulations/atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions src/nomad_simulations/model_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions tests/test_atoms_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit 3b99fe8

Please sign in to comment.