xarray-dataclasses 0.2.0


pip install xarray-dataclasses==0.2.0


Meta
Author: Akio Taniguchi
Requires Python: >=3.7,<4.0

Classifiers

License
  • OSI Approved :: MIT License

Programming Language
  • Python :: 3
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9

xarray-dataclasses

PyPI Python Test License

xarray extension for dataarray classes

TL;DR

xarray-dataclasses is a third-party Python package which helps to create DataArray classes in the same manner as the Python's native dataclass. Here is an introduction code of what the package provides:

from xarray_dataclasses import DataArray, dataarrayclass


@dataarrayclass
class Image:
    """DataArray class to represent images."""

    data: DataArray[('x', 'y'), float]
    x: DataArray['x', int] = 0
    y: DataArray['y', int] = 0

The key features are:

# create a DataArray instance
image = Image.new([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])

# create a DataArray instance filled with ones
ones = Image.ones((2, 2), x=[0, 1], y=[0, 1])
  • Custom DataArray instances with fixed dimensions, datatype, and coordinates can easily be created.
  • NumPy-like special functions like ones() are provided as class methods.

Requirements

  • Python: 3.7, 3.8, or 3.9 (tested by the author)
  • Dependencies: See pyproject.toml

Installation

$ pip install xarray-dataclasses

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
numpy (<2.0,>=1.19)
typing-extensions (<4.0,>=3.7)
xarray (<0.16,>=0.15)