Skip to content

Commit

Permalink
debug mapping functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MBueschelberger committed Aug 1, 2023
1 parent 78d0e0b commit b85504b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/CO+Pt111.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
max_time.add(time_float, rel=emmo.hasQuantityValue)

snapshots_float=emmo.Real(hasNumericalData='3.5')
snapshots = emmo.Snapshots()
snapshots = emmo.Snapshots(hasSymbolData="off")
snapshots.add(snapshots_float, rel=emmo.hasSpatialPart)

molar_fraction_CO = emmo.AmountFraction()
Expand Down
32 changes: 16 additions & 16 deletions osp/tools/mapping_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,7 @@ def map_function(self, root_cuds_object: Cuds, engine=None) -> tuple:
plams_molecule = map_PLAMSLandscape(search_landscape[0])

else:
search_molecule = \
search.find_cuds_objects_by_oclass(emmo.MolecularGeometry, root_cuds_object, emmo.hasPart)

if len(search_molecule) > 1:
raise_error(file=os.path.basename(__file__),
function=map_function.__name__,
type='ValueError',
message='More than one emmo.MolecularGeometry defined in the Wrapper object.')
elif not search_molecule:
raise_error(file=os.path.basename(__file__), function=map_molecule.__name__,
type='ValueError', message='Molecule CUDS object missed in the wrapper.')
else:
plams_molecule = map_PLAMSMolecule(search_molecule[0])
plams_molecule = map_PLAMSMolecule(root_cuds_object)

plams_settings = map_PLAMSSettings(root_cuds_object)

Expand Down Expand Up @@ -273,15 +261,27 @@ def map_molecule(root_cuds_object: Cuds) -> dict:
[coordinate_x_2, coordinate_y_n, coordinate_z_n, (region)]]
}
:param root_cuds_object: CUDS MolecularGeometry to be checked.
:param root_cuds_object: CUDS root_cuds_object to be checked.
:return str: If a Molecule object is present, return dictionary with
atom labels and positions. Otherwise, raise an error.
"""
molecule_data = {}

search_molecule = \
search.find_cuds_objects_by_oclass(emmo.MolecularGeometry, root_cuds_object, emmo.hasPart)

if len(search_molecule) > 1:
raise_error(file=os.path.basename(__file__),
function=map_function.__name__,
type='ValueError',
message='More than one emmo.MolecularGeometry defined in the Wrapper object.')
elif not search_molecule:
raise_error(file=os.path.basename(__file__), function=map_molecule.__name__,
type='ValueError', message='Molecule CUDS object missed in the wrapper.')

molecule_data = {}
# Looking for atoms:
first = root_cuds_object.get(rel=emmo.hasSpatialFirst)
first = search_molecule.pop().get(rel=emmo.hasSpatialFirst)
if len(first) > 1:
raise_error(file=os.path.basename(__file__),
function=map_molecule.__name__,
Expand Down

0 comments on commit b85504b

Please sign in to comment.