Skip to content

Commit

Permalink
Hotfix on PhysicalProperty (#56)
Browse files Browse the repository at this point in the history
* Added iri check in init

Fix _new_value
  • Loading branch information
JosePizarro3 authored Apr 18, 2024
1 parent 95286c4 commit 7273bf5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/nomad_simulations/physical_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,23 @@ def _new_value(self) -> Quantity:
Returns:
(Quantity): The new `Quantity` object for setting the `value` quantity.
"""
for quant in self.m_def.quantities:
if quant.name == 'value':
return Quantity(
type=quant.type,
unit=quant.unit, # ? this can be moved to __setattr__
description=quant.description,
)
value_quantity = self.m_def.all_quantities.get('value')
if value_quantity is None:
return None
return Quantity(
type=value_quantity.type,
unit=value_quantity.unit, # ? this can be moved to __setattr__
description=value_quantity.description,
)

def __init__(
self, m_def: Section = None, m_context: Context = None, **kwargs
) -> None:
super().__init__(m_def, m_context, **kwargs)
if self.iri is None:
logger.warning(
'The used property is not defined in the FAIRmat taxonomy (https://fairmat-nfdi.github.io/fairmat-taxonomy/). You can contribute there if you want to extend the list of available materials properties.'
)

def __setattr__(self, name: str, val: Any) -> None:
# For the special case of `value`, its `shape` needs to be defined from `_full_shape`
Expand Down

0 comments on commit 7273bf5

Please sign in to comment.