Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed Apr 2, 2024
1 parent 162d0ba commit eaf5b84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/nomad_simulations/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ class SCFOutputs(Outputs):
)

# TODO add more functionality to automatically check convergence from `self_consistency_ref` and the last `scf_step[-1]`
def check_is_converged(self, is_converged: bool, logger: BoundLogger) -> bool:
def check_is_scf_converged(
self, is_scf_converged: bool, logger: BoundLogger
) -> bool:
"""
Check if the output property is converged or not.
Expand All @@ -188,13 +190,15 @@ def check_is_converged(self, is_converged: bool, logger: BoundLogger) -> bool:
Returns:
(bool): The flag indicating whether the output property is converged or not.
"""
if not is_converged:
logger.info('The output property is not converged.')
if not is_scf_converged:
logger.info('The output property is not converged after the SCF process.')
return False
return True

def normalize(self, archive, logger) -> None:
super().normalize(archive, logger)

# Set if the output property `is_converged` or not.
self.is_converged = self.check_is_converged(self.is_converged, logger)
self.is_scf_converged = self.check_is_scf_converged(
self.is_scf_converged, logger
)
12 changes: 6 additions & 6 deletions tests/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ class TestOutputs:
"""

@pytest.mark.parametrize(
'is_converged, result',
'is_scf_converged, result',
[
(False, False),
(True, True),
],
)
def test_normalize(self, is_converged, result):
def test_normalize(self, is_scf_converged, result):
"""
Test the `normalize` method.
"""
scf_outputs = SCFOutputs()
# ! This testing is repetivite, but `check_is_converged` should eventually contain more complex logic and be separated in its own testing method.
assert scf_outputs.check_is_converged(is_converged, logger) == result
scf_outputs.is_converged = is_converged
# ! This testing is repetivite, but `check_is_scf_converged` should eventually contain more complex logic and be separated in its own testing method.
assert scf_outputs.check_is_scf_converged(is_scf_converged, logger) == result
scf_outputs.is_scf_converged = is_scf_converged
scf_outputs.normalize(None, logger)
assert scf_outputs.is_converged == result
assert scf_outputs.is_scf_converged == result

0 comments on commit eaf5b84

Please sign in to comment.