Skip to main content

Data classes for custom xarray constructors

Project description

xarray-custom

PyPI Python Test License

: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


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.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

xarray_custom-0.2.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file xarray-custom-0.2.1.tar.gz.

File metadata

  • Download URL: xarray-custom-0.2.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Linux/5.0.0-1035-azure

File hashes

Hashes for xarray-custom-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e016d6fd1453cf7b428b17271417a2cde92f28eec066305d28edc3dc98a1780e
MD5 9b777f4013101c000c81384f9881cd9e
BLAKE2b-256 df934d7ec5e6f57b529d7871635841804341d3d9a88cb0b1aad027c35654e21c

See more details on using hashes here.

File details

Details for the file xarray_custom-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: xarray_custom-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.6 Linux/5.0.0-1035-azure

File hashes

Hashes for xarray_custom-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ce80ae969fc879bced9a29cb70f9c5031a186838582a48b9fc19e8ebb79277c
MD5 9b781c4e8b81dbf63f147a678a89b716
BLAKE2b-256 30b57d9db41a78d90da375aeb140cede3ac7d381732c8df70a7ab3c460a41a2a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page