Skip to content

Commit

Permalink
use inspect to get members of Interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudz committed Oct 31, 2023
1 parent 9a3427b commit 299d279
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions atomisticparsers/utils/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

from typing import Any, Dict, List
import numpy as np
import inspect
from collections.abc import Iterable

from nomad.utils import get_logger
from nomad.datamodel import EntryArchive
from nomad.metainfo import MSection, SubSection
from nomad.metainfo import MSection, SubSection, Quantity
from nomad.datamodel.metainfo.simulation.run import Run
from nomad.datamodel.metainfo.simulation.system import System
from nomad.datamodel.metainfo.simulation.calculation import Calculation
Expand Down Expand Up @@ -204,9 +205,7 @@ def parse_md_workflow(self, data: Dict[str, Any]) -> None:

def parse_interactions(self, interactions: List[Dict], sec_model: MSection) -> None:

interaction_key_list = [
'type', 'name', 'n_inter', 'n_atoms', 'atom_labels', 'atom_indices',
'functional_form', 'n_parameters', 'parameters']
interaction_key_list = [n for n, q in inspect.getmembers(Interaction) if isinstance(q, Quantity)]
interaction_dict = {}
for interaction_key in interaction_key_list:
interaction_dict[interaction_key] = np.array([interaction.get(interaction_key) for interaction in interactions], dtype=object)
Expand Down

0 comments on commit 299d279

Please sign in to comment.