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

Forbid internally inconsistent schemas #39

Open
paiforsyth opened this issue Apr 30, 2022 · 0 comments
Open

Forbid internally inconsistent schemas #39

paiforsyth opened this issue Apr 30, 2022 · 0 comments
Labels
good first issue Good for newcomers

Comments

@paiforsyth
Copy link
Contributor

A key feature of xarray.Dataset is that all dimensions of the same name must have the same sizes across DataArrays. For this reason, a Dataset schema that requires different sizes for dimensions of the same name will never match any Datasets. I suggest that it should be an an error to construct such a schema. This would allow early detection of such erroneous schemas.

So with this feature, the following test would pass:

def test_forbid_internally_inconsistent_schema():
    with pytest.raises(Exception):
        schema =DatasetSchema(
            data_vars={
                "v1":DataArraySchema(shape=ShapeSchema((2,)), dims=("dim_1",)),
                "v2": DataArraySchema(shape=ShapeSchema((3,)), dims=("dim_1",)),
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants