{"id":26163834,"url":"https://github.com/xarray-contrib/xarray-schema","last_synced_at":"2025-12-12T00:37:33.952Z","repository":{"id":37939452,"uuid":"425707035","full_name":"xarray-contrib/xarray-schema","owner":"xarray-contrib","description":"Schema validation for Xarray objects","archived":false,"fork":false,"pushed_at":"2025-03-31T18:43:43.000Z","size":208,"stargazers_count":42,"open_issues_count":21,"forks_count":9,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-11T18:16:25.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://xarray-schema.readthedocs.io/en/latest/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xarray-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-08T05:16:39.000Z","updated_at":"2025-03-28T19:41:58.000Z","dependencies_parsed_at":"2023-02-19T04:50:14.489Z","dependency_job_id":"fa5a289b-6214-4bff-a25f-9893c82b8c83","html_url":"https://github.com/xarray-contrib/xarray-schema","commit_stats":{"total_commits":174,"total_committers":11,"mean_commits":"15.818181818181818","dds":0.5344827586206897,"last_synced_commit":"af367520844509690956ad540bc26646bde5d064"},"previous_names":["carbonplan/xarray-schema"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xarray-contrib%2Fxarray-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xarray-contrib","download_url":"https://codeload.github.com/xarray-contrib/xarray-schema/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248898473,"owners_count":21179783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T14:53:16.385Z","updated_at":"2025-12-12T00:37:33.913Z","avatar_url":"https://github.com/xarray-contrib.png","language":"Python","readme":"# xarray-schema\n\nSchema validation for Xarray\n\n[![CI](https://github.com/xarray-contrib/xarray-schema/actions/workflows/main.yaml/badge.svg)](https://github.com/carbonplan/xarray-schema/actions/workflows/main.yaml)\n[![codecov](https://codecov.io/gh/xarray-contrib/xarray-schema/branch/main/graph/badge.svg?token=EI729ZRFK0)](https://codecov.io/gh/xarray-contrib/xarray-schema)\n![MIT License](https://badgen.net/badge/license/MIT/blue)\n\n## installation\n\nInstall xarray-schema from PyPI:\n\n```shell\npip install xarray-schema\n```\n\nConda:\n\n```shell\nconda install -c conda-forge xarray-schema\n```\n\nOr install it from source:\n\n```shell\npip install git+https://github.com/xarray-contrib/xarray-schema\n```\n\n## usage\n\nXarray-schema's API is modeled after [Pandera](https://pandera.readthedocs.io/en/stable/). The `DataArraySchema` and `DatasetSchema` objects both have `.validate()` methods.\n\nThe basic usage is as follows:\n\n```python\nimport numpy as np\nimport xarray as xr\nfrom xarray_schema import DataArraySchema, DatasetSchema, CoordsSchema\n\nda = xr.DataArray(np.ones(4, dtype='i4'), dims=['x'], name='foo')\n\nschema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, ), dims=['x'])\n\nschema.validate(da)\n```\n\nYou can also use it to validate a `Dataset` like so:\n\n```\nschema_ds = DatasetSchema({'foo': schema})\n\nschema_ds.validate(da.to_dataset())\n```\n\nEach component of the Xarray data model is implemented as a stand alone class:\n\n```python\nfrom xarray_schema.components import (\n    DTypeSchema,\n    DimsSchema,\n    ShapeSchema,\n    NameSchema,\n    ChunksSchema,\n    ArrayTypeSchema,\n    AttrSchema,\n    AttrsSchema\n)\n\n# example constructions\ndtype_schema = DTypeSchema('i4')\ndims_schema = DimsSchema(('x', 'y', None))  # None is used as a wildcard\nshape_schema = ShapeSchema((5, 10, None))  # None is used as a wildcard\nname_schema = NameSchema('foo')\nchunk_schema = ChunksSchema({'x': None, 'y': -1})  # None is used as a wildcard, -1 is used as\nArrayTypeSchema = ArrayTypeSchema(np.ndarray)\n\n# Example usage\ndtype_schema.validate(da.dtype)\n\n# Each object schema can be exported to JSON format\ndtype_json = dtype_schema.to_json()\n```\n\n## roadmap\n\nThis is a very early prototype of a library. Some key things are missing:\n\n1. Exceptions: Pandera accumulates schema exceptions and reports them all at once. Currently, we are a eagerly raising `SchemaErrors` when the are found.\n\n## license\n\nAll the code in this repository is [MIT](https://choosealicense.com/licenses/mit/) licensed.\n\n## history\n\nThis project was originally developed at [CarbonPlan](https://carbonplan.org/). It was transferred to the xarray-contrib organization in August 2022.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarray-contrib%2Fxarray-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxarray-contrib%2Fxarray-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxarray-contrib%2Fxarray-schema/lists"}