Skip to main content

pytest-regressions plugin for xarray

Project description

PyPI version Build status Documentation Status

A pytest-regressions plugin for identifying regressions in Xarray objects.

Install

pip install xarray-regressions

Usage

If you're unfamiliar with pytest-regressions, check out their documentation first. xarray-regressions registers a compatible test fixture xarray_regression for detecting regressions in the data or metadata of xr.DataArray and xr.Dataset objects.

from xarray_regressions import XarrayRegressionFixture
import xarray as xr

def make_dataarray() -> xr.DataArray:
    """A dummy method that needs to be tested."""
    return xr.DataArray(
        np.full((2, 4, 3), 1),
        dims=["variable", "y", "x"],
        coords={
            "variable": ["var1", "var2"],
            "y": [1, 2, 3, 4],
            "x": [1, 2, 3],
        },
        name="sample_data",
        attrs={"foo": "bar"},
    )


def test_make_dataarray(xarray_regression: XarrayRegressionFixture):
    """Test that the function always returns an identical xr.DataArray."""
    da = make_dataarray()
    xarray_regression.check(
        da,
        check_names=True,
        check_attrs=True,
    )

Once the test is initialized and the expected result is stored in a NetCDF file, test_make_dataarray will fail if the generated xr.DataArray changes in a future run.

xarray_regression.check uses xr.testing.assert_equal to compare equality of values, dimensions, and coordinates. If atol or rtol are provided, it will use xr.testing.assert_allclose instead. Names and attributes are checked separately. Encodings are not currently checked.

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_regressions-0.0.1.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xarray_regressions-0.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file xarray_regressions-0.0.1.tar.gz.

File metadata

  • Download URL: xarray_regressions-0.0.1.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xarray_regressions-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a0ee87c23898acad35e2cb9e442d7ca0caa861eb2685b77c8858ccacc46ac2f4
MD5 c8edef62f010d8ba03e24974614c4479
BLAKE2b-256 eab7e167695b31944b9005656c13e09025dde8c040afe2c4680ec80986c24212

See more details on using hashes here.

Provenance

The following attestation bundles were made for xarray_regressions-0.0.1.tar.gz:

Publisher: publish.yaml on aazuspan/xarray-regressions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xarray_regressions-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for xarray_regressions-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92eb97ae38fb2cd2305a88afd7df14ea4081c96fb2643f7a573124777efb4bcf
MD5 9658014ba2ec4aafcd7f6b7929211a56
BLAKE2b-256 5369043fe62f472dca9065fdf0c83f97c57d1f841b3b3ec924bdc2381bbb0154

See more details on using hashes here.

Provenance

The following attestation bundles were made for xarray_regressions-0.0.1-py3-none-any.whl:

Publisher: publish.yaml on aazuspan/xarray-regressions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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