Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator for DataArray shapes #665

Open
vhirtham opened this issue Dec 3, 2021 · 1 comment
Open

Validator for DataArray shapes #665

vhirtham opened this issue Dec 3, 2021 · 1 comment
Labels
ASDF everything ASDF related (python + schemas) validation custom ASDF validators xarray issues related to handling xarray objects

Comments

@vhirtham
Copy link
Collaborator

vhirtham commented Dec 3, 2021

Currently, we are using the wx_shape validator to ensure that certain dimensions have a specific size. For example, in the SpatialData scheme we want the last dimension that represents space (by definition) to always have the size 3.

This requires us to reorder the internal data of a DataArray during serialization or before to meet the requirements of the validator. This somehow ignores the benefit of a DataArray that all dimensions are named and directly accessible. So we should either expand the functionality of the wx_shape validator or (better I guess) introduce a new one that can handle dimension names too. The syntax can be close to the wx_shape validator just with added dimension names like this: [..., c=3]. This would express "any number of dimensions with arbitrary shape, but the dimension c must have shape (3,)". This would also mean that there has to be a dimension c. [..., (c=3)] would mean that the dimension c is optional, but if present, it has to be of size 3.

@vhirtham vhirtham added ASDF everything ASDF related (python + schemas) xarray issues related to handling xarray objects validation custom ASDF validators labels Dec 3, 2021
@CagtayFabry
Copy link
Member

I think implementing this should be really simple if we do it just for DataArray with a mapping like

wx_array:
  c: 3
  n: [5,~]
  time: [2,20]

In the end we should probably just find a nice serialization format to use for our xr_check_coords function inputs (which we basically already have)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASDF everything ASDF related (python + schemas) validation custom ASDF validators xarray issues related to handling xarray objects
Projects
None yet
Development

No branches or pull requests

2 participants