Skip to content

Commit 44d924a

Browse files
author
Joseph Hamman
committed
update README.md
1 parent 4479233 commit 44d924a

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1+
<img
2+
src='https://carbonplan-assets.s3.amazonaws.com/monogram/dark-small.png'
3+
height='48'
4+
/>
5+
16
# xarray-schema
7+
8+
Schema validation for Xarray
9+
10+
[![CI](https://github.com/carbonplan/ndpyramid/actions/workflows/main.yaml/badge.svg)](https://github.com/carbonplan/xarray-schema/actions/workflows/main.yaml)
11+
![MIT License](https://badgen.net/badge/license/MIT/blue)
12+
13+
# installation
14+
15+
This package is in the early stages of development. Install it from source:
16+
17+
```shell
18+
pip install git+git://github.com/TomNicholas/datatree
19+
pip install git+git://github.com/carbonplan/xarray-schema
20+
```
21+
22+
# usage
23+
24+
Xarray-schema's API is modeled after [Pandera](https://pandera.readthedocs.io/en/stable/). The `DataArraySchema` and `DatasetSchema` objects both have `.validate()` methods.
25+
26+
The basic usage is as follows:
27+
28+
```python
29+
import numpy as np
30+
import xarray as xr
31+
from xarray_schema import DataArraySchema, DatasetSchema
32+
33+
da = xr.DataArray(np.ones(4, dtype='i4'), dims=['x'], name='foo')
34+
35+
schema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, ), dims=['x'])
36+
37+
schema.validate(da)
38+
```
39+
40+
# roadmap
41+
42+
This is a very early prototype of a library. Some key things are missing:
43+
44+
1. Validation of `coords`, `chunks`, and `attrs`. None of these are implemented yet.
45+
1. Class-based schema's for parts of the Xarray data model. Most validations are currently made as direct comparisons (`da.name == self.name`) but a more robust approach is possible that leverages classes for each component of the data model. We're already handling some special cases using `None` as a sentinel value to allow for wildcard-like behavior in places (i.e. `dims` and `shape`)
46+
1. Exceptions: Pandera accumulates schema exceptions and reports them all at once. Currently, we are a eagerly raising `SchemaErrors` when the are found.
47+
48+
## license
49+
50+
All the code in this repository is [MIT](https://choosealicense.com/licenses/mit/) licensed, but we request that you please provide attribution if reusing any of our digital content (graphics, logo, articles, etc.).
51+
52+
## about us
53+
54+
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](https://carbonplan.org/) or get in touch by [opening an issue](https://github.com/carbonplan/xarray-schema/issues/new) or [sending us an email](mailto:[email protected]).

xarray_schema/core.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
import numpy as np
44
import xarray as xr
55

6-
# Leaving off here:
7-
# Need to:
8-
# - write tests
9-
# - typing
10-
# - document missing features (mostly class based args)
6+
# TODOs:
117
# - api grouping, should the constructors look similar to the DataArray/Dataset constructors
128

139

0 commit comments

Comments
 (0)