Schema validation for Xarray objects
Project description
xarray-schema
Schema validation for Xarray
installation
This package is in the early stages of development. Install it from source:
pip install git+git://github.com/carbonplan/xarray-schema
usage
Xarray-schema's API is modeled after Pandera. The DataArraySchema
and DatasetSchema
objects both have .validate()
methods.
The basic usage is as follows:
import numpy as np
import xarray as xr
from xarray_schema import DataArraySchema, DatasetSchema
da = xr.DataArray(np.ones(4, dtype='i4'), dims=['x'], name='foo')
schema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, ), dims=['x'])
schema.validate(da)
You can also use it to validate a Dataset like so:
schema_ds = DatasetSchema({'foo': schema})
schema_ds.validate(da.to_dataset())
roadmap
This is a very early prototype of a library. Some key things are missing:
- Validation of
coords
andattrs
. These are implemented yet. - Exceptions: Pandera accumulates schema exceptions and reports them all at once. Currently, we are a eagerly raising
SchemaErrors
when the are found.
license
All the code in this repository is MIT licensed, but we request that you please provide attribution if reusing any of our digital content (graphics, logo, articles, etc.).
about us
CarbonPlan is a non-profit organization working on the science and data of carbon removal. We aim to improve the transparency and scientific integrity of carbon removal and climate solutions through open data and tools. Find out more at carbonplan.org or get in touch by opening an issue or sending us an email.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for xarray_schema-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eca2239445f353aaaa91b9550935bf946d01ce8f7df0a3713ef001501b2f9fe9 |
|
MD5 | 741b08a697a79167b047ed214e495a59 |
|
BLAKE2b-256 | 9d17ca1cb2e13e1bef6fef975b8de8a698cb3507baed26c3b65771dbdfc0d7d1 |