{"id":29121379,"url":"https://github.com/aazuspan/xarray-regressions","last_synced_at":"2025-08-12T18:44:04.699Z","repository":{"id":301137597,"uuid":"989172294","full_name":"aazuspan/xarray-regressions","owner":"aazuspan","description":"pytest-regressions plugin for xarray","archived":false,"fork":false,"pushed_at":"2025-06-05T01:17:31.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-25T10:55:21.798Z","etag":null,"topics":["pytest-plugin","regression-testing","xarray"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aazuspan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-23T17:11:10.000Z","updated_at":"2025-06-05T01:18:51.000Z","dependencies_parsed_at":"2025-06-25T10:55:27.957Z","dependency_job_id":"b069fced-ab79-40b9-a077-8d4904361471","html_url":"https://github.com/aazuspan/xarray-regressions","commit_stats":null,"previous_names":["aazuspan/xarray-regressions"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aazuspan/xarray-regressions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aazuspan%2Fxarray-regressions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aazuspan%2Fxarray-regressions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aazuspan%2Fxarray-regressions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aazuspan%2Fxarray-regressions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aazuspan","download_url":"https://codeload.github.com/aazuspan/xarray-regressions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aazuspan%2Fxarray-regressions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270116821,"owners_count":24530278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest-plugin","regression-testing","xarray"],"created_at":"2025-06-29T16:05:39.084Z","updated_at":"2025-08-12T18:44:04.693Z","avatar_url":"https://github.com/aazuspan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/xarray-regressions.svg)](https://badge.fury.io/py/xarray-regressions)\n[![Build status](https://github.com/aazuspan/xarray-regressions/actions/workflows/ci.yaml/badge.svg)](https://github.com/aazuspan/xarray-regressions/actions/workflows/ci.yaml)\n\nA [pytest-regressions](https://pytest-regressions.readthedocs.io/en/latest/overview.html) plugin for identifying regressions in [Xarray](https://docs.xarray.dev/en/stable/) objects.\n\n\n\u003e [!WARNING]\n\u003e `xarray-regressions` is in early development and might have breaking changes.\n\n\n## Install\n\n```\npip install xarray-regressions\n```\n\n## Usage\n\n\u003e [!TIP]\n\u003e If you're unfamiliar with `pytest-regressions`, check out [their documentation](https://pytest-regressions.readthedocs.io/en/latest/overview.html) first. \n\nOnce installed, this package registers a test fixture `xarray_regression` for detecting regressions in the data or metadata of `xr.DataArray` and `xr.Dataset` objects.\n\nSay you have a function `make_dataarray` that should always return the same output:\n\n```python\nimport xarray as xr\n\ndef make_dataarray(name: str) -\u003e xr.DataArray:\n    \"\"\"A dummy method that needs to be tested.\"\"\"\n    return xr.DataArray(\n        np.full((2, 4, 3), 1),\n        dims=[\"variable\", \"y\", \"x\"],\n        coords={\n            \"variable\": [\"var1\", \"var2\"],\n            \"y\": [1, 2, 3, 4],\n            \"x\": [1, 2, 3],\n        },\n        name=name,\n        attrs={\"foo\": \"bar\"},\n    )\n```\n\nAdd the `xarray_regression` fixture to a new test and call the `check` method on the returned data array:\n\n```python\nfrom xarray_regressions import XarrayRegressionFixture # Only used for type annotation\n\ndef test_make_dataarray(xarray_regression: XarrayRegressionFixture):\n    \"\"\"Test that the function always returns an identical xr.DataArray.\"\"\"\n    da = make_dataarray(name=\"test_array\")\n    xarray_regression.check(\n        da,\n        check_name=True,\n        check_attrs=True,\n    )\n```\n\nRunning the test once will write `da` to a local NetCDF[^netcdf], and future test runs will compare `da` with the stored result. Values, dimensions, and coordinates are checked using [xr.testing.assert_allclose](https://docs.xarray.dev/en/latest/generated/xarray.testing.assert_allclose.html) to allow for minor floating point differences between systems, but can be tested for exact equality by specifying `rtol=0` and `atol=0`. Names and attributes are checked separately. Encodings are *not* currently checked.\n\nIf `make_dataarray(name=\"test_array\")` returns a different result in the future, the test will fail:\n\n```text\nAssertionError: DataArray names are different. L: foo, R: test_array\n```\n\n### Testing multiple objects\n\nTo test multiple objects in the same test, you can pass an `obj_id` argument to the `check` method. This will be appended to the `basename` (by default, the name of the test) so that each object is saved to a separate file.\n\n```python\ndef test_make_dataarray(xarray_regression: XarrayRegressionFixture):\n    \"\"\"Test that the function always returns an identical xr.DataArray.\"\"\"\n    da1 = make_dataarray(name=\"test_array_1\")\n    da2 = make_dataarray(name=\"test_array_2\")\n    \n    xarray_regression.check(da1, obj_id=\"da1\", check_name=True)\n    xarray_regression.check(da2, obj_id=\"da2\", check_name=True)\n```\n\nWhen adding new tests with multiple objects, the [`--regen-all` flag](https://pytest-regressions.readthedocs.io/en/latest/overview.html#regen-all) can be helpful to avoid `pytest-regressions` aborting on the first missing file.\n\n[^netcdf]: Because results are stored in NetCDF, all tested objects *must* be serializable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faazuspan%2Fxarray-regressions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faazuspan%2Fxarray-regressions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faazuspan%2Fxarray-regressions/lists"}