FAIRmat-NFDI / nexus_definitions

Definitions of the NeXus Standard File Structure and Contents
https://manual.nexusformat.org/
Other
5 stars 8 forks source link

Change `get_enums` to return a list #218

Closed domna closed 2 months ago

domna commented 2 months ago

@rettigl

rettigl commented 2 months ago

@domna This seems to work with

def is_value_valid_element_of_enum(value, elem) -> Tuple[bool, list]:
    """Checks whether a value has to be specific from the NXDL enumeration and returns options."""
    if elem is not None:
        enums = nexus.get_enums(elem)
        if enums and (
            isinstance(value, list) or value not in enums or value == ""
        ):
            return False, enums
    return True, []
rettigl commented 2 months ago

But I don't overlook where else this is used. I suggest to also make this a warning instead of Exceptions: https://github.com/FAIRmat-NFDI/pynxtools/blob/6960709e974a39a55d139f5c6430aaa1bdcc38e1/pynxtools/dataconverter/helpers.py#L632

rettigl commented 2 months ago

Also, this should be a warning, I would say: https://github.com/FAIRmat-NFDI/pynxtools/blob/6960709e974a39a55d139f5c6430aaa1bdcc38e1/pynxtools/dataconverter/helpers.py#L478

domna commented 2 months ago

Thanks for the comments. I agree with your suggestions and will add it in https://github.com/FAIRmat-NFDI/pynxtools/pull/313