Skip to content

Forbid internally inconsistent schemas #39

@paiforsyth

Description

@paiforsyth

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",)),
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions