Data classes for custom xarray constructors
Project description
xarray-custom
:zap: Data classes for custom xarray constructors
TL;DR
xarray-custom is a third-party 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 ctype, dataarrayclass
@dataarrayclass(accessor='img')
class Image:
"""DataArray class to represent images."""
dims = 'x', 'y'
dtype = float
x: ctype('x', int) = 0
y: ctype('y', int) = 0
def normalize(self):
return self / self.max()
# create a custom DataArray
image = Image([[0, 1], [2, 3]], x=[0, 1], y=[0, 1])
# use a custom method via an accessor
normalized = image.img.normalize()
# create a custom DataArray filled with ones
ones = Image.ones((2, 2), x=[0, 1], y=[0, 1])
The key points are:
- Custom DataArray instances with fixed dimensions, datatype, and coordinates can easily be created.
- NumPy-like special functions like
ones()
are provided as class methods. - Custom DataArray methods can be available 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.3.0.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file xarray-custom-0.3.0.tar.gz
.
File metadata
- Download URL: xarray-custom-0.3.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.7 Linux/5.3.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c219394b912385317144179a4236616d5c97e8b426d61d831b45964007d9b49 |
|
MD5 | 696af1b3c6f636a11903df647de6e769 |
|
BLAKE2b-256 | 4b341f44a9ffb66a80a869053a44a27c7fb37475e485c5559c10bafb8041c6f4 |
File details
Details for the file xarray_custom-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: xarray_custom-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.7 Linux/5.3.0-1020-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b89d4f6ef06f13d8facc51cc99e6e11734a8952e2ccefb304e778c9cc746dec |
|
MD5 | 5e6bf56a2426dbe374cb316c092f20e5 |
|
BLAKE2b-256 | fba9658ef6df919d4b19eda5fa4b16d9d45959d810ff00a28c98b340b6ee7520 |