Name | xarray-dataclass JSON |
Version |
3.0.0
JSON |
| download |
home_page | None |
Summary | xarray data creation by data classes |
upload_time | 2025-07-30 20:26:31 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License
Copyright (c) 2020-2024 Akio Taniguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
dataarray
dataclass
dataset
typing
xarray
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# xarray-dataclass
[](https://pypi.org/project/xarray-dataclass/)
[](https://pypi.org/project/xarray-dataclass/)
[](https://pepy.tech/project/xarray-dataclass)
[](https://doi.org/10.5281/zenodo.16604747)
[](https://github.com/xarray-contrib/xarray-dataclass/actions/workflows/tests.yaml)
xarray data creation by data classes
This repository is adapted from [here](https://github.com/astropenguin/xarray-dataclasses). We are grateful for the
work of the developer on this repo. Sadly, that repository is inactive. Thus, a fork was moved here in order to allow
for more visibility and community maintenance.
## Overview
xarray-dataclass is a Python package that makes it easy to create [xarray]'s DataArray and Dataset objects that are "typed" (i.e. fixed dimensions, data type, coordinates, attributes, and name) using [the Python's dataclass]:
```python
from dataclasses import dataclass
from typing import Literal
from xarray_dataclass import AsDataArray, Coord, Data
X = Literal["x"]
Y = Literal["y"]
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
```
### Features
- Typed DataArray or Dataset objects can easily be created:
```python
image = Image.new([[0, 1], [2, 3]], [0, 1], [0, 1])
```
- NumPy-like filled-data creation is also available:
```python
image = Image.zeros([2, 2], x=[0, 1], y=[0, 1])
```
- Support for features by [the Python's dataclass] (`field`, `__post_init__`, ...).
- Support for static type check by [Pyright].
### Installation
There are multiple ways you can install xarray-dataclass, dependent on what kind of dependency manager you use.
```shell
pip install xarray-dataclass
pixi add --pypi xarray-dataclass
```
## Basic usage
xarray-dataclass uses [the Python's dataclass].
Data (or data variables), coordinates, attributes, and a name of DataArray or Dataset objects will be defined as dataclass fields by special type hints (`Data`, `Coord`, `Attr`, `Name`), respectively.
Note that the following code is supposed in the examples below.
```python
from dataclasses import dataclass
from typing import Literal
from xarray_dataclass import AsDataArray, AsDataset
from xarray_dataclass import Attr, Coord, Data, Name
X = Literal["x"]
Y = Literal["y"]
```
### Data field
Data field is a field whose value will become the data of a DataArray object or a data variable of a Dataset object.
The type hint `Data[TDims, TDtype]` fixes the dimensions and the data type of the object.
Here are some examples of how to specify them.
Type hint | Inferred dimensions
--- | ---
`Data[tuple[()], ...]` | `()`
`Data[Literal["x"], ...]` | `("x",)`
`Data[tuple[Literal["x"]], ...]` | `("x",)`
`Data[tuple[Literal["x"], Literal["y"]], ...]` | `("x", "y")`
Type hint | Inferred data type
--- | ---
`Data[..., Any]` | `None`
`Data[..., None]` | `None`
`Data[..., float]` | `numpy.dtype("float64")`
`Data[..., numpy.float128]` | `numpy.dtype("float128")`
`Data[..., Literal["datetime64[ns]"]]` | `numpy.dtype("<M8[ns]")`
### Coordinate field
Coordinate field is a field whose value will become a coordinate of a DataArray or a Dataset object.
The type hint `Coord[TDims, TDtype]` fixes the dimensions and the data type of the object.
### Attribute field
Attribute field is a field whose value will become an attribute of a DataArray or a Dataset object.
The type hint `Attr[TAttr]` specifies the type of the value, which is used only for static type check.
### Name field
Name field is a field whose value will become the name of a DataArray object.
The type hint `Name[TName]` specifies the type of the value, which is used only for static type check.
### DataArray class
DataArray class is a dataclass that defines typed DataArray specifications.
Exactly one data field is allowed in a DataArray class.
The second and subsequent data fields are just ignored in DataArray creation.
```python
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
units: Attr[str] = "cd / m^2"
name: Name[str] = "luminance"
```
A DataArray object will be created by a class method `new()`:
```python
Image.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])
<xarray.DataArray "luminance" (x: 2, y: 2)>
array([[0., 1.],
[2., 3.]])
Coordinates:
* x (x) int64 0 1
* y (y) int64 0 1
Attributes:
units: cd / m^2
```
NumPy-like class methods (`zeros()`, `ones()`, ...) are also available:
```python
Image.ones((3, 3))
<xarray.DataArray "luminance" (x: 3, y: 3)>
array([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]])
Coordinates:
* x (x) int64 0 0 0
* y (y) int64 0 0 0
Attributes:
units: cd / m^2
```
### Dataset class
Dataset class is a dataclass that defines typed Dataset specifications.
Multiple data fields are allowed to define the data variables of the object.
```python
@dataclass
class ColorImage(AsDataset):
"""2D color image as Dataset."""
red: Data[tuple[X, Y], float]
green: Data[tuple[X, Y], float]
blue: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
units: Attr[str] = "cd / m^2"
```
A Dataset object will be created by a class method `new()`:
```python
ColorImage.new(
[[0, 0], [0, 0]], # red
[[1, 1], [1, 1]], # green
[[2, 2], [2, 2]], # blue
)
<xarray.Dataset>
Dimensions: (x: 2, y: 2)
Coordinates:
* x (x) int64 0 0
* y (y) int64 0 0
Data variables:
red (x, y) float64 0.0 0.0 0.0 0.0
green (x, y) float64 1.0 1.0 1.0 1.0
blue (x, y) float64 2.0 2.0 2.0 2.0
Attributes:
units: cd / m^2
```
## Advanced usage
### Coordof and Dataof type hints
xarray-dataclass provides advanced type hints, `Coordof` and `Dataof`.
Unlike `Data` and `Coord`, they specify a dataclass that defines a DataArray class.
This is useful when users want to add metadata to dimensions for [plotting].
For example:
```python
from xarray_dataclass import Coordof
@dataclass
class XAxis:
data: Data[X, int]
long_name: Attr[str] = "x axis"
units: Attr[str] = "pixel"
@dataclass
class YAxis:
data: Data[Y, int]
long_name: Attr[str] = "y axis"
units: Attr[str] = "pixel"
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coordof[XAxis] = 0
y: Coordof[YAxis] = 0
```
### General data variable names in Dataset creation
Due to the limitation of Python's parameter names, it is not possible to define data variable names that contain white spaces, for example.
In such cases, please define DataArray classes of each data variable so that they have name fields and specify them by `Dataof` in a Dataset class.
Then the values of the name fields will be used as data variable names.
For example:
```python
@dataclass
class Red:
data: Data[tuple[X, Y], float]
name: Name[str] = "Red image"
@dataclass
class Green:
data: Data[tuple[X, Y], float]
name: Name[str] = "Green image"
@dataclass
class Blue:
data: Data[tuple[X, Y], float]
name: Name[str] = "Blue image"
@dataclass
class ColorImage(AsDataset):
"""2D color image as Dataset."""
red: Dataof[Red]
green: Dataof[Green]
blue: Dataof[Blue]
```
```python
ColorImage.new(
[[0, 0], [0, 0]],
[[1, 1], [1, 1]],
[[2, 2], [2, 2]],
)
<xarray.Dataset>
Dimensions: (x: 2, y: 2)
Dimensions without coordinates: x, y
Data variables:
Red image (x, y) float64 0.0 0.0 0.0 0.0
Green image (x, y) float64 1.0 1.0 1.0 1.0
Blue image (x, y) float64 2.0 2.0 2.0 2.0
```
### Customization of DataArray or Dataset creation
For customization, users can add a special class attribute, `__dataoptions__`, to a DataArray or Dataset class.
A custom factory for DataArray or Dataset creation is only supported in the current implementation.
```python
import xarray as xr
from xarray_dataclass import DataOptions
class Custom(xr.DataArray):
"""Custom DataArray."""
__slots__ = ()
def custom_method(self) -> bool:
"""Custom method."""
return True
@dataclass
class Image(AsDataArray):
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
__dataoptions__ = DataOptions(Custom)
image = Image.ones([3, 3])
isinstance(image, Custom) # True
image.custom_method() # True
```
### DataArray and Dataset creation without shorthands
xarray-dataclass provides functions, `asdataarray` and `asdataset`.
This is useful when users do not want to inherit the mix-in class (`AsDataArray` or `AsDataset`) in a DataArray or Dataset dataclass.
For example:
```python
from xarray_dataclass import asdataarray
@dataclass
class Image:
"""2D image as DataArray."""
data: Data[tuple[X, Y], float]
x: Coord[X, int] = 0
y: Coord[Y, int] = 0
image = asdataarray(Image([[0, 1], [2, 3]], [0, 1], [0, 1]))
```
## How to contribute
Thank you for being willing to contribute! If you have some ideas to propose, please open an [issue](https://github.com/xarray-contrib/xarray-dataclass/issues).
We use [GitHub flow](https://docs.github.com/en/get-started/using-github/github-flow) for developing and managing the project.
The first section describes how to contribute with it.
The second and third sections explain how to prepare a local development environment and our automated workflows in GitHub Actions, respectively.
### Get the source code
```shell
git clone https://github.com/xarray-contrib/xarray-dataclass
cd xarray-dataclass
```
### Install dependencies
First install [pixi](https://pixi.sh/latest/installation/). Then, install project dependencies:
```shell
pixi install -a
pixi run -e dev pre-commit install
```
### Testing, linting, and formatting
We have a test workflow for testing and a pre-commit workflow for static type checking, linting, and formatting the code.
It is performed when a pull request is created against main.
If you would like to check them in local, the following commands are almost equivalent (the difference is that the test workflows are run under multiple Python versions).
Furthermore, these tasks are defined only in the `dev` environment. Pixi does not require you to specify the environment
in that case.
```
pixi run tests
pixi run precommit # This runs pre-commit on all files.
```
### Creating documentation
We also have a documentation workflow. However, if you want to locally create the documentation
run the following:
```shell
pixi run doc_build # this just creates the build
pixi run doc_serve # build and serve at http://localhost:8000/
```
### Create a release
This section is relevant only for maintainers.
1. Pull `git`'s `main` branch.
2. `pixi install -a`
3. `pixi run -e dev pre-commit install`
4. `pixi run tests`
5. `pixi shell`
6. `hatch version <new-version>`
7. `git add .`
8. `git commit -m "ENH: Bump version to <version>"`
9. `hatch build`
10. `hatch publish`
11. `git push upstream main`
12. Create a new tag and Release via the GitHub UI. Auto-generate release notes
and add additional notes as needed.
<!-- References -->
[Pyright]: https://github.com/microsoft/pyright
[the Python's dataclass]: https://docs.python.org/3/library/dataclasses.html
[xarray]: https://xarray.pydata.org/en/stable/index.html
[plotting]: https://xarray.pydata.org/en/stable/user-guide/plotting.html#simple-example
Raw data
{
"_id": null,
"home_page": null,
"name": "xarray-dataclass",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Wouter-Michiel Vierdag <michiel.vierdag@scverse.org>",
"keywords": "dataarray, dataclass, dataset, typing, xarray",
"author": null,
"author_email": "Akio Taniguchi <taniguchi.akio@gmail.com>, Wouter-Michiel Vierdag <michiel.vierdag@scverse.org>",
"download_url": "https://files.pythonhosted.org/packages/60/99/04705ee6ff4d6d4db986058ceb19f2561014dde41e2f2ab73cc5ed35c958/xarray_dataclass-3.0.0.tar.gz",
"platform": null,
"description": "# xarray-dataclass\n\n[](https://pypi.org/project/xarray-dataclass/)\n[](https://pypi.org/project/xarray-dataclass/)\n[](https://pepy.tech/project/xarray-dataclass)\n[](https://doi.org/10.5281/zenodo.16604747)\n[](https://github.com/xarray-contrib/xarray-dataclass/actions/workflows/tests.yaml)\n\nxarray data creation by data classes\n\nThis repository is adapted from [here](https://github.com/astropenguin/xarray-dataclasses). We are grateful for the\nwork of the developer on this repo. Sadly, that repository is inactive. Thus, a fork was moved here in order to allow\nfor more visibility and community maintenance.\n\n## Overview\n\nxarray-dataclass is a Python package that makes it easy to create [xarray]'s DataArray and Dataset objects that are \"typed\" (i.e. fixed dimensions, data type, coordinates, attributes, and name) using [the Python's dataclass]:\n\n```python\nfrom dataclasses import dataclass\nfrom typing import Literal\nfrom xarray_dataclass import AsDataArray, Coord, Data\n\n\nX = Literal[\"x\"]\nY = Literal[\"y\"]\n\n\n@dataclass\nclass Image(AsDataArray):\n \"\"\"2D image as DataArray.\"\"\"\n\n data: Data[tuple[X, Y], float]\n x: Coord[X, int] = 0\n y: Coord[Y, int] = 0\n```\n\n### Features\n\n- Typed DataArray or Dataset objects can easily be created:\n ```python\n image = Image.new([[0, 1], [2, 3]], [0, 1], [0, 1])\n ```\n- NumPy-like filled-data creation is also available:\n ```python\n image = Image.zeros([2, 2], x=[0, 1], y=[0, 1])\n ```\n- Support for features by [the Python's dataclass] (`field`, `__post_init__`, ...).\n- Support for static type check by [Pyright].\n\n### Installation\n\nThere are multiple ways you can install xarray-dataclass, dependent on what kind of dependency manager you use.\n\n```shell\npip install xarray-dataclass\npixi add --pypi xarray-dataclass\n```\n\n## Basic usage\n\nxarray-dataclass uses [the Python's dataclass].\nData (or data variables), coordinates, attributes, and a name of DataArray or Dataset objects will be defined as dataclass fields by special type hints (`Data`, `Coord`, `Attr`, `Name`), respectively.\nNote that the following code is supposed in the examples below.\n\n```python\nfrom dataclasses import dataclass\nfrom typing import Literal\nfrom xarray_dataclass import AsDataArray, AsDataset\nfrom xarray_dataclass import Attr, Coord, Data, Name\n\n\nX = Literal[\"x\"]\nY = Literal[\"y\"]\n```\n\n### Data field\n\nData field is a field whose value will become the data of a DataArray object or a data variable of a Dataset object.\nThe type hint `Data[TDims, TDtype]` fixes the dimensions and the data type of the object.\nHere are some examples of how to specify them.\n\nType hint | Inferred dimensions\n--- | ---\n`Data[tuple[()], ...]` | `()`\n`Data[Literal[\"x\"], ...]` | `(\"x\",)`\n`Data[tuple[Literal[\"x\"]], ...]` | `(\"x\",)`\n`Data[tuple[Literal[\"x\"], Literal[\"y\"]], ...]` | `(\"x\", \"y\")`\n\nType hint | Inferred data type\n--- | ---\n`Data[..., Any]` | `None`\n`Data[..., None]` | `None`\n`Data[..., float]` | `numpy.dtype(\"float64\")`\n`Data[..., numpy.float128]` | `numpy.dtype(\"float128\")`\n`Data[..., Literal[\"datetime64[ns]\"]]` | `numpy.dtype(\"<M8[ns]\")`\n\n### Coordinate field\n\nCoordinate field is a field whose value will become a coordinate of a DataArray or a Dataset object.\nThe type hint `Coord[TDims, TDtype]` fixes the dimensions and the data type of the object.\n\n### Attribute field\n\nAttribute field is a field whose value will become an attribute of a DataArray or a Dataset object.\nThe type hint `Attr[TAttr]` specifies the type of the value, which is used only for static type check.\n\n### Name field\n\nName field is a field whose value will become the name of a DataArray object.\nThe type hint `Name[TName]` specifies the type of the value, which is used only for static type check.\n\n### DataArray class\n\nDataArray class is a dataclass that defines typed DataArray specifications.\nExactly one data field is allowed in a DataArray class.\nThe second and subsequent data fields are just ignored in DataArray creation.\n\n```python\n@dataclass\nclass Image(AsDataArray):\n \"\"\"2D image as DataArray.\"\"\"\n\n data: Data[tuple[X, Y], float]\n x: Coord[X, int] = 0\n y: Coord[Y, int] = 0\n units: Attr[str] = \"cd / m^2\"\n name: Name[str] = \"luminance\"\n```\n\nA DataArray object will be created by a class method `new()`:\n\n```python\nImage.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])\n\n<xarray.DataArray \"luminance\" (x: 2, y: 2)>\narray([[0., 1.],\n [2., 3.]])\nCoordinates:\n * x (x) int64 0 1\n * y (y) int64 0 1\nAttributes:\n units: cd / m^2\n```\n\nNumPy-like class methods (`zeros()`, `ones()`, ...) are also available:\n\n```python\nImage.ones((3, 3))\n\n<xarray.DataArray \"luminance\" (x: 3, y: 3)>\narray([[1., 1., 1.],\n [1., 1., 1.],\n [1., 1., 1.]])\nCoordinates:\n * x (x) int64 0 0 0\n * y (y) int64 0 0 0\nAttributes:\n units: cd / m^2\n```\n\n### Dataset class\n\nDataset class is a dataclass that defines typed Dataset specifications.\nMultiple data fields are allowed to define the data variables of the object.\n\n```python\n@dataclass\nclass ColorImage(AsDataset):\n \"\"\"2D color image as Dataset.\"\"\"\n\n red: Data[tuple[X, Y], float]\n green: Data[tuple[X, Y], float]\n blue: Data[tuple[X, Y], float]\n x: Coord[X, int] = 0\n y: Coord[Y, int] = 0\n units: Attr[str] = \"cd / m^2\"\n```\n\nA Dataset object will be created by a class method `new()`:\n\n```python\nColorImage.new(\n [[0, 0], [0, 0]], # red\n [[1, 1], [1, 1]], # green\n [[2, 2], [2, 2]], # blue\n)\n\n<xarray.Dataset>\nDimensions: (x: 2, y: 2)\nCoordinates:\n * x (x) int64 0 0\n * y (y) int64 0 0\nData variables:\n red (x, y) float64 0.0 0.0 0.0 0.0\n green (x, y) float64 1.0 1.0 1.0 1.0\n blue (x, y) float64 2.0 2.0 2.0 2.0\nAttributes:\n units: cd / m^2\n```\n\n## Advanced usage\n\n### Coordof and Dataof type hints\n\nxarray-dataclass provides advanced type hints, `Coordof` and `Dataof`.\nUnlike `Data` and `Coord`, they specify a dataclass that defines a DataArray class.\nThis is useful when users want to add metadata to dimensions for [plotting].\nFor example:\n\n```python\nfrom xarray_dataclass import Coordof\n\n\n@dataclass\nclass XAxis:\n data: Data[X, int]\n long_name: Attr[str] = \"x axis\"\n units: Attr[str] = \"pixel\"\n\n\n@dataclass\nclass YAxis:\n data: Data[Y, int]\n long_name: Attr[str] = \"y axis\"\n units: Attr[str] = \"pixel\"\n\n\n@dataclass\nclass Image(AsDataArray):\n \"\"\"2D image as DataArray.\"\"\"\n\n data: Data[tuple[X, Y], float]\n x: Coordof[XAxis] = 0\n y: Coordof[YAxis] = 0\n```\n\n### General data variable names in Dataset creation\n\nDue to the limitation of Python's parameter names, it is not possible to define data variable names that contain white spaces, for example.\nIn such cases, please define DataArray classes of each data variable so that they have name fields and specify them by `Dataof` in a Dataset class.\nThen the values of the name fields will be used as data variable names.\nFor example:\n\n```python\n@dataclass\nclass Red:\n data: Data[tuple[X, Y], float]\n name: Name[str] = \"Red image\"\n\n\n@dataclass\nclass Green:\n data: Data[tuple[X, Y], float]\n name: Name[str] = \"Green image\"\n\n\n@dataclass\nclass Blue:\n data: Data[tuple[X, Y], float]\n name: Name[str] = \"Blue image\"\n\n\n@dataclass\nclass ColorImage(AsDataset):\n \"\"\"2D color image as Dataset.\"\"\"\n\n red: Dataof[Red]\n green: Dataof[Green]\n blue: Dataof[Blue]\n```\n\n```python\nColorImage.new(\n [[0, 0], [0, 0]],\n [[1, 1], [1, 1]],\n [[2, 2], [2, 2]],\n)\n\n<xarray.Dataset>\nDimensions: (x: 2, y: 2)\nDimensions without coordinates: x, y\nData variables:\n Red image (x, y) float64 0.0 0.0 0.0 0.0\n Green image (x, y) float64 1.0 1.0 1.0 1.0\n Blue image (x, y) float64 2.0 2.0 2.0 2.0\n```\n\n### Customization of DataArray or Dataset creation\n\nFor customization, users can add a special class attribute, `__dataoptions__`, to a DataArray or Dataset class.\nA custom factory for DataArray or Dataset creation is only supported in the current implementation.\n\n\n```python\nimport xarray as xr\nfrom xarray_dataclass import DataOptions\n\n\nclass Custom(xr.DataArray):\n \"\"\"Custom DataArray.\"\"\"\n\n __slots__ = ()\n\n def custom_method(self) -> bool:\n \"\"\"Custom method.\"\"\"\n return True\n\n\n@dataclass\nclass Image(AsDataArray):\n \"\"\"2D image as DataArray.\"\"\"\n\n data: Data[tuple[X, Y], float]\n x: Coord[X, int] = 0\n y: Coord[Y, int] = 0\n\n __dataoptions__ = DataOptions(Custom)\n\n\nimage = Image.ones([3, 3])\nisinstance(image, Custom) # True\nimage.custom_method() # True\n```\n\n### DataArray and Dataset creation without shorthands\n\nxarray-dataclass provides functions, `asdataarray` and `asdataset`.\nThis is useful when users do not want to inherit the mix-in class (`AsDataArray` or `AsDataset`) in a DataArray or Dataset dataclass.\nFor example:\n\n```python\nfrom xarray_dataclass import asdataarray\n\n\n@dataclass\nclass Image:\n \"\"\"2D image as DataArray.\"\"\"\n\n data: Data[tuple[X, Y], float]\n x: Coord[X, int] = 0\n y: Coord[Y, int] = 0\n\n\nimage = asdataarray(Image([[0, 1], [2, 3]], [0, 1], [0, 1]))\n```\n\n## How to contribute\n\nThank you for being willing to contribute! If you have some ideas to propose, please open an [issue](https://github.com/xarray-contrib/xarray-dataclass/issues).\nWe use [GitHub flow](https://docs.github.com/en/get-started/using-github/github-flow) for developing and managing the project.\nThe first section describes how to contribute with it.\nThe second and third sections explain how to prepare a local development environment and our automated workflows in GitHub Actions, respectively.\n\n\n### Get the source code\n\n```shell\ngit clone https://github.com/xarray-contrib/xarray-dataclass\ncd xarray-dataclass\n```\n\n### Install dependencies\n\nFirst install [pixi](https://pixi.sh/latest/installation/). Then, install project dependencies:\n\n```shell\npixi install -a\npixi run -e dev pre-commit install\n```\n\n### Testing, linting, and formatting\nWe have a test workflow for testing and a pre-commit workflow for static type checking, linting, and formatting the code.\nIt is performed when a pull request is created against main.\nIf you would like to check them in local, the following commands are almost equivalent (the difference is that the test workflows are run under multiple Python versions).\nFurthermore, these tasks are defined only in the `dev` environment. Pixi does not require you to specify the environment\nin that case.\n\n```\npixi run tests\npixi run precommit # This runs pre-commit on all files.\n```\n\n### Creating documentation\nWe also have a documentation workflow. However, if you want to locally create the documentation\nrun the following:\n\n```shell\npixi run doc_build # this just creates the build\npixi run doc_serve # build and serve at http://localhost:8000/\n```\n\n### Create a release\n\nThis section is relevant only for maintainers.\n\n1. Pull `git`'s `main` branch.\n2. `pixi install -a`\n3. `pixi run -e dev pre-commit install`\n4. `pixi run tests`\n5. `pixi shell`\n6. `hatch version <new-version>`\n7. `git add .`\n8. `git commit -m \"ENH: Bump version to <version>\"`\n9. `hatch build`\n10. `hatch publish`\n11. `git push upstream main`\n12. Create a new tag and Release via the GitHub UI. Auto-generate release notes\n and add additional notes as needed.\n\n<!-- References -->\n[Pyright]: https://github.com/microsoft/pyright\n[the Python's dataclass]: https://docs.python.org/3/library/dataclasses.html\n[xarray]: https://xarray.pydata.org/en/stable/index.html\n[plotting]: https://xarray.pydata.org/en/stable/user-guide/plotting.html#simple-example\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2020-2024 Akio Taniguchi\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "xarray data creation by data classes",
"version": "3.0.0",
"project_urls": {
"Documentation": "https://xarray-contrib.github.io/xarray-dataclass/",
"Homepage": "https://github.com/xarray-contrib/xarray-dataclass/",
"Repository": "https://github.com/xarray-contrib/xarray-dataclass/"
},
"split_keywords": [
"dataarray",
" dataclass",
" dataset",
" typing",
" xarray"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "bceabc1de04d06b7c59fc3ff647a11fa248bf80af5a6227647a31c6250c32ce6",
"md5": "3d55a492d80132f16a9624a06cffb58e",
"sha256": "7956f29005671b2acaa0da700d8f359105dce84ef84f76ce2dd05b76dba3e826"
},
"downloads": -1,
"filename": "xarray_dataclass-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3d55a492d80132f16a9624a06cffb58e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 16862,
"upload_time": "2025-07-30T20:26:30",
"upload_time_iso_8601": "2025-07-30T20:26:30.696792Z",
"url": "https://files.pythonhosted.org/packages/bc/ea/bc1de04d06b7c59fc3ff647a11fa248bf80af5a6227647a31c6250c32ce6/xarray_dataclass-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "609904705ee6ff4d6d4db986058ceb19f2561014dde41e2f2ab73cc5ed35c958",
"md5": "3387c3d36922f2f58c3173b4d14a1572",
"sha256": "0fa438efda992b859dee07dc2f99c2660886402c366706c074c4c92795b354f1"
},
"downloads": -1,
"filename": "xarray_dataclass-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "3387c3d36922f2f58c3173b4d14a1572",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 8376,
"upload_time": "2025-07-30T20:26:31",
"upload_time_iso_8601": "2025-07-30T20:26:31.937733Z",
"url": "https://files.pythonhosted.org/packages/60/99/04705ee6ff4d6d4db986058ceb19f2561014dde41e2f2ab73cc5ed35c958/xarray_dataclass-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-30 20:26:31",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xarray-contrib",
"github_project": "xarray-dataclass",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "xarray-dataclass"
}