Data classes for custom xarray creation
Project description
xarray-custom
:zap: Data classes for custom xarray creation
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()
The key features are:
# 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])
- 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.5.0.tar.gz
(9.8 kB
view details)
Built Distribution
File details
Details for the file xarray-custom-0.5.0.tar.gz
.
File metadata
- Download URL: xarray-custom-0.5.0.tar.gz
- Upload date:
- Size: 9.8 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 | 3c1201942d1df8b360d5da4d0587368e87ac73a8565efc8f5eb137cdfabc7937 |
|
MD5 | 7d28827f66fa6134d4d8eda6169e58cb |
|
BLAKE2b-256 | 8b3683b24dbee21203544b8a70ccae6fb4d70d7ce2bcd96258c0b06a2f87e724 |
File details
Details for the file xarray_custom-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: xarray_custom-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.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 | df00d039a457226c98111107390c1bc92f8a765ccc0066c0621aaa3799aadf48 |
|
MD5 | f3091bd16ec407c36249b924451afc88 |
|
BLAKE2b-256 | 4eabb5a4bfd5659e47f572b5a333c0744f45d1f35d729740511f0fc7892df5bd |