Skip to content

Commit

Permalink
Fix kkrimp parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippRue committed Nov 21, 2024
1 parent 2ae32ce commit 5ccb1a7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
18 changes: 9 additions & 9 deletions aiida_kkr/parsers/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
from aiida import __version__ as aiida_core_version
from aiida.orm import Dict, CalcJobNode
from aiida.common.exceptions import InputValidationError, NotExistent
from aiida.common.exceptions import InputValidationError, NotExistent, NotExistentAttributeError
from aiida.parsers.parser import Parser
from aiida_kkr.calculations.kkrimp import KkrimpCalculation
from aiida_kkr.tools.context import open_files_in_context
Expand All @@ -21,7 +21,7 @@
__copyright__ = (u'Copyright (c), 2018, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.6.1'
__version__ = '0.6.2'
__contributors__ = (u'Philipp Rüßmann', u'Raffaele Aliberti')


Expand All @@ -42,7 +42,7 @@ def __init__(self, calc):

# pylint: disable=protected-access
# pylint: disable=unexpected-keyword-arg
def parse(self, debug=False, ignore_nan=True, **kwargs):
def parse(self, debug=False, ignore_nan=True, doscalc=None, **kwargs):
"""
Parse output data folder, store results in database.
Expand All @@ -67,12 +67,12 @@ def parse(self, debug=False, ignore_nan=True, **kwargs):
# Get the node of the parent calculation (useful for the imp calculations)
calc = out_folder.get_incoming(node_class=CalcJobNode).first().node

# figure out if this is a DOS calculation
parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node
npol = parent_host_calc.inputs.parameters.get_dict().get(
'NPOL', 1
) # This parameter discriminates if it is a DOS calc or not
doscalc = (npol == 0)
# figure out if this is a DOS calculation (if not specified in the input already)
if doscalc is None:
parent_host_calc = calc.inputs.host_Greenfunction_folder.get_incoming(node_class=CalcJobNode).first().node
# This parameter discriminates if it is a DOS calc or not
npol = parent_host_calc.inputs.parameters.get_dict().get('NPOL', 1)
doscalc = (npol == 0)

if debug:
print('doscalc = ', doscalc)

Check warning on line 78 in aiida_kkr/parsers/kkrimp.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/parsers/kkrimp.py#L78

Added line #L78 was not covered by tests
Expand Down
Binary file added tests/files/export_kkrimp_calc.aiida
Binary file not shown.
Binary file removed tests/files/export_kkrimp_calc.tar.gz
Binary file not shown.
18 changes: 10 additions & 8 deletions tests/parsers/test_kkrimp_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from builtins import object
import pytest
from aiida.manage.tests.pytest_fixtures import clear_database, clear_database_after_test, aiida_profile
from aiida import orm
from ..conftest import import_with_migration

# tests
Expand All @@ -12,10 +12,13 @@ def test_parse_kkrimp_calc(aiida_profile):
"""
simple Cu noSOC, FP, lmax2
"""
from aiida.orm import load_node
from aiida_kkr.parsers.kkrimp import KkrimpParser
import_with_migration('files/db_dump_kkrimp_out.tar.gz')
kkrimp_calc = load_node('eab8db1b-2cc7-4b85-a524-0df4ff2b7da6')
group_pk = import_with_migration('data_dir/kkrimp_full_wc.aiida')
kkrimp_calc = [
i for i in orm.load_group(group_pk).nodes if i.label == 'KKRimp calculation step 2 (IMIX=0, Zimp: [30.0])'
][0]
print(kkrimp_calc, kkrimp_calc.label)

print(kkrimp_calc.outputs.retrieved.list_object_names())
parser = KkrimpParser(kkrimp_calc)
out = parser.parse(debug=False)
Expand All @@ -29,12 +32,11 @@ def test_parse_kkrimp_calc_complex(aiida_profile):
"""
complex magnetic impurity with SOC
"""
from aiida.orm import load_node
from aiida_kkr.parsers.kkrimp import KkrimpParser
import_with_migration('files/export_kkrimp_calc.tar.gz')
kkrimp_calc = load_node('7547303b-69b7-4380-b0c0-7440e6c4f2a1')
import_with_migration('files/export_kkrimp_calc.aiida')
kkrimp_calc = orm.load_node('b9a2b29a-e250-4992-ae6a-579b733ad1f8')
parser = KkrimpParser(kkrimp_calc)
out = parser.parse(debug=False)
out = parser.parse(debug=False, doscalc=False)
assert out is None
out_dict = parser.outputs.output_parameters.get_dict()
assert out_dict['parser_errors'] == []

0 comments on commit 5ccb1a7

Please sign in to comment.