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 coord, dataarrayclass
@dataarrayclass
class Image:
"""DataArray class to represent images."""
dims = 'x', 'y'
dtype = float
accessor = 'img'
x: coord('x', int) = 0
y: coord('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.
Requirements
- Python: 3.6, 3.7, or 3.8 (tested by the author)
- Dependencies: See pyproject.toml
Installation
$ pip install xarray-custom
License
Copyright (c) 2020 Akio Taniguchi
- xarray-custom is distributed under the MIT License
- xarray-custom uses an icon of xarray distributed under the Apache 2.0 license
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.6.1.tar.gz
(10.6 kB
view details)
Built Distribution
File details
Details for the file xarray-custom-0.6.1.tar.gz
.
File metadata
- Download URL: xarray-custom-0.6.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.8 Linux/5.3.0-1032-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef03cccf5d8b938945a83de2ff68fe50ee6ff330e81cad9be9d4462b26cbca21 |
|
MD5 | 5b3f1379f80851e2015d30dc7e87dd82 |
|
BLAKE2b-256 | 9e39466158ff670b698c8830799dab3cad4f050ba7fa9a10a33a1d81233472db |
File details
Details for the file xarray_custom-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: xarray_custom-0.6.1-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.7.8 Linux/5.3.0-1032-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12939062dbb00fef64cb585b9277303270026d2c2902eff4bca21abedf354c1e |
|
MD5 | f0b314aa20f1fc8bdbea1eab564993e8 |
|
BLAKE2b-256 | 678779e0bfe3b466ad8a8af335c92ba7a1e82e29926c086ba4b43cd7fc178a90 |