FAIRmat-NFDI / pynxtools

https://fairmat-nfdi.github.io/pynxtools/
Apache License 2.0
12 stars 8 forks source link

Implement support for use of numpy array notation when backwards converting nxdl to yaml #151

Closed mkuehbach closed 4 months ago

mkuehbach commented 10 months ago

For most dimensions groups in NXDL files only the "rank" and "dim" group with "index" "value" XML tags are used. In this case numpy shorthand notation can be used. This is currently implemented when converting forward i.e. yaml to nxdl but not when converting backwards. The backwards conversion is should fall back to the current "dimensions:" notation when dimensions have docs or constraints at the "dim" level like seen in NXstxm or NXmx Otherwise the numpy notation can be used

mkuehbach commented 10 months ago

Possible logic to add in xml_handle_dimension could be: If dimensions group has only the attribute "rank" with its value purely integer and all child "dim" groups have only tags "index" and "value" then use the numpy notation otherwise proceed as usual "dimensions" group notation.

sherjeelshabih commented 4 months ago

@mkuehbach has this been addressed already? If not, we can close this here and move it to the nyaml2nxdl repo.

mkuehbach commented 4 months ago

@sherjeelshabih not that I know of @RubelMozumder ?

RubelMozumder commented 4 months ago

@sherjeelshabih not that I know of @RubelMozumder ?

I have not made the forward conversion, I am a bit confused. At this moment dimension works as follows:

# 2D particle motion
dimensions:
   rank: 2
   dim: [[0, x coordinate], [1, y coordinate]]
   dim_parameters:
      doc: ["Position of particle on x-axis.","Position of particle on y-axis."]

What would be the case with numpy notation? or @mkuehbach do you have any yaml file link with numpy notation to have a look on it?

mkuehbach commented 4 months ago

I have implemented the forward conversion. The syntax follows numpy notation, i.e. no dim keyword for scalar (n,) 1d (n,m) 2d (n,m,k, ...) ...d Important is, the old syntax dimensions remains to cover cases where indeed individual dimensions get docstrings etc.

sherjeelshabih commented 4 months ago

I'll close this as there is already an issue for this in the nyaml repo: https://github.com/FAIRmat-NFDI/nyaml/issues/22