Closed ladinesa closed 3 weeks ago
Yeah, I think this is the weakest point of the dynamical shape.
I guess doing a default could work, can you give me a specific example where this breaks?
This does not work:
dct = {'electronic_eigenvalues': [{'n_bands': 3}]}
out = Outputs.m_from_dict(dct)
error
self.rank = [int(kwargs.get('n_bands'))]
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
I am having a different error with your code:
from nomad_simulations.schema_packages.outputs import Outputs
dct = {'electronic_eigenvalues': [{'n_bands': 3}]}
out = Outputs.m_from_dict(dct)
ValueError: `n_bands` is not defined during initialization of the class.
ah yeah I forgot to remove the other fix I put in.
While you break it again, I think this is going to be handled different anyways, so I am sure redefining __init__
is not the best programming choice here, but we need a way of handling the static part of the shape of a physical property
i am not sure but can we not use the derived
quantity decorator?
derived
? In which sense? you mean in value
?
def derived(**kwargs):
def decorator(f) -> Quantity:
kwargs.setdefault('name', f.__name__)
kwargs.setdefault(
'description', f.__doc__.strip() if f.__doc__ is not None else None
)
kwargs.setdefault('type', AnyType())
return Quantity(derived=f, **kwargs)
return decorator
in metainfo.py
Closing in favor of #143
The initialization of PhysicalProperty objects may require quantities to be defined such as in
BaseElectronicEigenvalues
, where nbands needs to be specified. This will not work with the mapping parser for we can only set the quantity after creating the section. Is is possible then to either 1. put a default for these required quantities or 2. make the quantities that depend on these required quantites as derived quantites.@JosePizarro3