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.4.1.tar.gz
(9.4 kB
view details)
Built Distribution
File details
Details for the file xarray-custom-0.4.1.tar.gz
.
File metadata
- Download URL: xarray-custom-0.4.1.tar.gz
- Upload date:
- Size: 9.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 | b7e4679e3ad3d8c21c740e901d009300eea653331ae8e5e3db85104796895f5c |
|
MD5 | e832cf22d561e51cb1acfeeec95bdb09 |
|
BLAKE2b-256 | 2e74c9611d997dd7553f9b4c32f5676b00caef0f22a5dff86c792e5ef5dc3f03 |
File details
Details for the file xarray_custom-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: xarray_custom-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.9 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 | abd4574aac7e27eb4c5fdf5fa90f4c0e41ab8f5ec5eb407b20fff9bae9f4b1f1 |
|
MD5 | 139e849f1fef25592649abb533eff4c5 |
|
BLAKE2b-256 | 7ea226232a4b689c17d3ac4a00b5ba895591d998f983dd33f19534cdad9d0c57 |