Data classes for custom xarray constructors
Project description
xarray-custom
:zap: Data classes for custom xarray constructors
TL;DR
xarray-custom is a Python package which helps to create custom DataArray classes in the same manner as the Python's native dataclass. Here is an introduction code of what the package provides:
from xarray_custom import coordtype, dataarrayclass
@dataarrayclass(('x', 'y'), float, 'custom')
class CustomDataArray:
x: coordtype('x', int)
y: coordtype('y', int)
z: coordtype(('x', 'y'), str) = 'spam'
def double(self):
"""Custom DataArray method which doubles values."""
return self * 2
dataarray = CustomDataArray([[0, 1], [2, 3]], x=[2, 2], y=[3, 3])
onesarray = CustomDataArray.ones(shape=(3, 3))
doubled = dataarray.custom.double()
The key points are:
- Custom DataArray instances with fixed dimensions and coordinates can easily be created.
- Default values and dtype can be specified via a class decorator and class variable annotations.
- NumPy-like special factory functions like
ones()
are provided as class methods. - Custom DataArray methods can be used via a custom accessor.
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
xarray-custom-0.2.0.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for xarray_custom-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55b778e231361704e6ca91025e3f35ae342a381287e17cb44001c1ad66b6350e |
|
MD5 | b5d2b3948a9915f17437927210abbbf4 |
|
BLAKE2b-256 | f2284d53137246f2420293d5d79ebc1fb1557eeb34617f0b06f39b1afccb8b4f |