Open
Conversation
…ta#10519) Co-authored-by: DHRUVA KUMAR KAUSHAL <sanjay@MacBook-Air.local> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Cherian <deepak@cherian.net>
* create a policy definition file * use `xarray-contrib/minimum-dependency-versions` * remove the min-deps script * setup python * bump versions * exclude `hypothesis` * use `python-version` to select the version * stop ignoring `pydap` violations We appear to have reached the point where this is not necessary anymore (but the comment might have been wrong? We're already pinning to `pydap=3.5.0`)
…a#10650) In pandas 3.0, `Day` will no longer be considered a `Tick`-like frequency (pandas-dev/pandas#61985). This PR ports this change to the cftime version of this offset. The main implication in the cftime / xarray context is that it means the `offset` and `origin` options in `resample` will no longer have an effect when resampling to a daily frequency. As in pandas-dev/pandas#62101, warnings will be emitted if non-default values are passed.
* Remove default re-definition * colors arg should take priority over default cmaps * Update test_plot.py * Update test_plot.py * add log norm test * Add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update test_plot.py * Update test_plot.py * Update test_plot.py * Update test_plot.py * Update whats-new.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…f bytes from to_netcdf() (pydata#10656) * Improve consistency and engine keyword argument for to_netcdf() This PR introduces a bug fix and a breaking changes: 1. The default backend ``engine`` used by `Dataset.to_netcdf` and `DataTree.to_netcdf` is now chosen consistently with `open_dataset` and `open_datatree`, using whichever netCDF libraries are available and preferring netCDF4 to h5netcdf to scipy. Previously, `DataTree.to_netcdf` was hard-coded to use h5netcdf. 2. The return value of `Dataset.to_netcdf` without ``path`` is now a ``memoryview`` object instead of ``bytes``. This removes an unnecessary memory copy and ensures consistency when using either ``engine="scipy"`` or ``engine="h5netcdf"``. Fixes pydata#10654 * Add PR number to whatsnew * Consistently use BytesIOProxy * Fix test_engine * Clarify whats new * Clarify whats new * tweak whats-new * Fix release note typo * Rename to_file_or_memoryview * test fixes
updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](pre-commit/pre-commit-hooks@v5.0.0...v6.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.12.7 → v0.12.11](astral-sh/ruff-pre-commit@v0.12.7...v0.12.11) - [github.com/adhtruong/mirrors-typos: v1.34.0 → v1.35.6](adhtruong/mirrors-typos@v1.34.0...v1.35.6) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Stephan Hoyer <shoyer@google.com>
* Allow tests to pass locally on Mac move env vars into the tests, out of the env setup. xfail tests without codec dependencies (I think this is a PyPI vs conda diff?) * Fix ruff linting issue: use contextlib.suppress instead of try-except-pass
- Add explicit keyword arguments to netCDF4.Dataset.createVariable calls - Add type: ignore comments for dynamic compression parameter - Remove unnecessary type: ignore for requests import These changes resolve mypy type checking errors that were causing CI failures. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
Removed 11 warning exclusions that are no longer needed: - Invalid cast warnings from duck_array_ops and test_array_api - CachingFileManager deallocation warnings from backends - Deprecated treenode methods (ancestors, iter_lineage, lineage) - Test-specific deprecations that no longer exist These exclusions were verified to be safe to remove through testing. The test suite passes with 20,779 tests after removal. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
…0691) * Enable mypy checking for test_utils and test_parallelcompat Removes xarray.tests.test_utils and xarray.tests.test_parallelcompat from the mypy exclusion list by fixing type issues in these files: - Added type annotations where needed - Added targeted type: ignore comments for intentional test behaviors - Fixed function call signatures to match expected types All tests continue to pass and mypy now checks these files with check_untyped_defs=true. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Also enable mypy for test_missing Removes xarray.tests.test_missing from the mypy exclusion list by fixing type issues: - Added type: ignore comments for intentional test cases with invalid methods - Added type annotation for kwargs dict All 115 tests continue to pass. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Simple development instructions for using uv with xarray, including commands for running tests and linting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
* Remove obsolete warning exclusions from pyproject.toml Removed 11 warning exclusions that are no longer needed: - Invalid cast warnings from duck_array_ops and test_array_api - CachingFileManager deallocation warnings from backends - Deprecated treenode methods (ancestors, iter_lineage, lineage) - Test-specific deprecations that no longer exist These exclusions were verified to be safe to remove through testing. The test suite passes with 20,779 tests after removal. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove additional obsolete UserWarning exclusions Removed 3 more warning exclusions that are no longer needed: - UserWarning from test_coding_times - UserWarning from test_computation - UserWarning from test_dataset All test files pass without these warning exclusions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove 3 more obsolete warning exclusions Removed warning exclusions that are no longer needed: - "No index created" UserWarning - Tests properly handle with pytest.warns - "pandas.MultiIndex" FutureWarning - No longer triggered - "Duplicate dimension names" UserWarning - Tests handle with local filterwarnings These warnings are either properly tested or no longer occur. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Use pytest.warns consistently for quantile interpolation deprecation Fixed test_dataset.py to use pytest.warns instead of warnings.catch_warnings for testing the interpolation->method deprecation warning. This makes it consistent with the other test files. Note: We cannot remove the global warning exclusion because the error:::xarray.* rule converts warnings to errors before pytest.warns can catch them. This is a known limitation of the current filterwarnings configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add local filterwarnings to quantile interpolation deprecation tests Instead of relying on a global warning exclusion, added @pytest.mark.filterwarnings decorators to the specific tests that test the interpolation->method deprecation warning. This allows the warning to be properly tested while avoiding the conflict with the error:::xarray.* rule. Now the global exclusion for this warning can be safely removed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…a#10697) * QOL: detect both .zarr and .zarr/ as using the zarr engine * test: properly test the opening with a trailing slash
* Remove obsolete warning exclusions from pyproject.toml Removed 11 warning exclusions that are no longer needed: - Invalid cast warnings from duck_array_ops and test_array_api - CachingFileManager deallocation warnings from backends - Deprecated treenode methods (ancestors, iter_lineage, lineage) - Test-specific deprecations that no longer exist These exclusions were verified to be safe to remove through testing. The test suite passes with 20,779 tests after removal. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove additional obsolete UserWarning exclusions Removed 3 more warning exclusions that are no longer needed: - UserWarning from test_coding_times - UserWarning from test_computation - UserWarning from test_dataset All test files pass without these warning exclusions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Remove 3 more obsolete warning exclusions Removed warning exclusions that are no longer needed: - "No index created" UserWarning - Tests properly handle with pytest.warns - "pandas.MultiIndex" FutureWarning - No longer triggered - "Duplicate dimension names" UserWarning - Tests handle with local filterwarnings These warnings are either properly tested or no longer occur. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Use pytest.warns consistently for quantile interpolation deprecation Fixed test_dataset.py to use pytest.warns instead of warnings.catch_warnings for testing the interpolation->method deprecation warning. This makes it consistent with the other test files. Note: We cannot remove the global warning exclusion because the error:::xarray.* rule converts warnings to errors before pytest.warns can catch them. This is a known limitation of the current filterwarnings configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add local filterwarnings to quantile interpolation deprecation tests Instead of relying on a global warning exclusion, added @pytest.mark.filterwarnings decorators to the specific tests that test the interpolation->method deprecation warning. This allows the warning to be properly tested while avoiding the conflict with the error:::xarray.* rule. Now the global exclusion for this warning can be safely removed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove non-tuple sequence indexing warning exclusion Fixed the test in test_nputils.py that was using deprecated list indexing x[[1, 2], [1, 2]] by changing it to tuple indexing x[([1, 2], [1, 2])]. This allows us to remove the global warning filter for 'Using a non-tuple sequence for multidimensional indexing is deprecated'. * Remove two obsolete NumPy DeprecationWarning exclusions Removed the following warning exclusions from pyproject.toml: - 'Failed to decode variable.*NumPy will stop allowing conversion...' - 'NumPy will stop allowing conversion of:DeprecationWarning' These exclusions are no longer needed as the tests pass without them. The remaining 'invalid value encountered in cast' warnings are legitimate and occur when casting NaN values to integer types. * Change Zarr V3 warnings to default These warnings are no longer ignored and will be reported in CI. Co-authored-by: Claude <no-reply@anthropic.com> * Remove 'invalid value encountered in cast' warning exclusions Fixed tests to properly handle the expected RuntimeWarning when casting NaN values to integer types: - Updated test_conventions.py::test_missing_fillvalue to explicitly catch both the SerializationWarning and the numpy RuntimeWarning - Added create_nan_array() helper function in test_units.py that suppresses the cast warning when creating test arrays with NaN values for int dtypes - Removed the two warning exclusions from pyproject.toml These warnings were legitimate - they occur when casting float arrays containing NaN to integer types, which is expected behavior in these test scenarios. * Fix NumPy out-of-bound integer conversion warning Handle overflow when casting _FillValue to dtype in CFMaskCoder.encode(). This fixes CI failures on older NumPy versions where casting 255 to int8 raises a DeprecationWarning (newer NumPy raises OverflowError). The fix: - Wraps the dtype.type(fv) call in a try/except block - Suppresses the NumPy DeprecationWarning for older versions - Catches OverflowError for newer NumPy versions - Uses np.array(fv).astype(dtype) which properly wraps the value * Fix remaining NumPy out-of-bound integer conversion warnings Added comprehensive handling for NumPy's DeprecationWarning about out-of-bound integer conversion in multiple locations: - Added _safe_type_cast() helper function to handle the conversion safely - Updated _encode_unsigned_fill_value() to suppress the warning - Fixed missing_value encoding to use _safe_type_cast() - Refactored _FillValue encoding to use the helper function This should fix all test failures in the bare-min-and-scipy CI environment where older NumPy versions raise DeprecationWarning instead of OverflowError. * Simplify NumPy overflow handling with cleaner approach Replaced complex warning suppression with a simpler, more consistent approach: - _safe_type_cast() now uses np.array(value).astype(dtype).item() which works consistently across NumPy 1.x and 2.x for overflow cases - _encode_unsigned_fill_value() now explicitly checks bounds using np.iinfo() before attempting the cast, making the logic clearer - This removes unnecessary try/except blocks and warning filters The root issue: NumPy changed behavior between versions: - NumPy 1.x: dtype.type(out_of_bounds) raises DeprecationWarning but succeeds - NumPy 2.x: dtype.type(out_of_bounds) raises OverflowError The test itself (test_roundtrip_unsigned) is correctly testing edge cases where unsigned values (255) need to be stored as signed int8, which is a legitimate use case in CF conventions for unsigned integer encoding. * Add autouse fixture for NumPy 1.x warning handling - Added handle_numpy_1_warnings autouse fixture to conftest.py - Removes need for workarounds in the actual code - Handles NumPy version differences cleanly at the test level - Reverted variables.py to simpler implementation without _safe_type_cast --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <no-reply@anthropic.com>
* Upgrade mypy to 1.17.1 and fix all type errors - Update mypy from 1.15 to 1.17.1 in CI requirements - Fix 65 mypy errors across 20 files to achieve zero errors - Key fixes: - Remove obsolete type: ignore comments - Fix pandas MultiIndex type compatibility (list conversions) - Resolve dictionary key type issues (Hashable vs str) - Add type annotations for better type inference - Fix scipy/pandas interface compatibility in tests - Correct Variable.data setter override placement All changes are minimal type annotation improvements without logic modifications. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix test_stack_unstack for pandas compatibility Keep pd.Index objects instead of converting to lists to preserve dtype behavior in MultiIndex levels. * Add unused-ignore to all type: ignore comments for CI compatibility CI environment may report some type: ignore comments as unused while they're needed locally. Adding unused-ignore to suppress these warnings. * Add types-requests to CI and remove unnecessary type: ignore comments - Added types-requests to CI dependencies to provide typing for requests module - Removed type: ignore comments that were showing as unused both locally and in CI - Kept only the type: ignore that are actually necessary (one in test_plot.py) * Add back necessary type: ignore comments for CI compatibility The CI environment showed different mypy behavior than local environment, requiring us to keep these type: ignore comments with unused-ignore flag * Fix remaining CI mypy errors - Add type: ignore for indexes.py indexing operation - Add type: ignore for alignment.py return type issues - Add type: ignore for cftimeindex.py shift method override * Improve level_coords_dtype typing to match pandas MultiIndex - Change level_coords_dtype type from dict[str, Any] to dict[Hashable | None, Any] - This matches pandas MultiIndex.names which can be Hashable or None - Remove unnecessary str() conversions added in previous commit - Remove obsolete type: ignore comment and TODO that questioned if Hashables are ok (they are) This is a cleaner solution that better reflects the actual pandas API. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix IndexVariable.level_names type to match pandas - Changed return type from list[str] | None to list[Hashable | None] | None - This matches pandas MultiIndex.names actual type (list[Hashable | None]) - Removed unnecessary str() conversion that was losing type information - Now returns list(index.names) directly, preserving the correct types --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
* ignore the new pattern * construct the pattern dynamically
* update url * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Added explicit guidelines about GitHub interactions to ensure appropriate behavior when working with the xarray repository. These guidelines prevent unsolicited GitHub actions and require explicit user authorization for repository interactions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
) * Complete deprecation cycle for Dataset.update return value - Dataset.update() now returns None instead of self - Removes deprecation that was started in v0.17 and scheduled for removal in v0.21 - Updates documentation to remove return value information - Aligns behavior with standard dict.update() which returns None Closes pydata#10167 * Update doc/whats-new.rst Co-authored-by: Stephan Hoyer <shoyer@google.com> --------- Co-authored-by: Stephan Hoyer <shoyer@google.com>
* fun: add badge Co-authored-by: pierre-manchon <pierre-manchon@users.noreply.github.com> * fun: add badge to readme * Update badge.json * move badge and use more accessible color --------- Co-authored-by: pierre-manchon <pierre-manchon@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* The align_chunks parameter was not being sent on the to_zarr method of the datasets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add a note on the whats-new.rst about the error of the align_chunks for datasets * Fix a ValueError on the test_dataset_to_zarr_align_chunks_true * Fix the case when enc_chunks are bigger than the dask chunks * Linter * Fix small reintroduced issue when the region is None * Fix mypy issues * Update whats-new.rst * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use "v" instead of "var" to follow the name convention used on the rest of Xarray, move the modification of the enc_chunks to the build_grid_chunks function, add additional test to covert the scenario where the chunk is bigger than the size of the array * Update the whats-new.rst * Fix whats-new.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This reverts commit cf6bf5b.
Co-authored-by: Julia Signell <jsignell@gmail.com> Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
* Fix a typo in dataset.py * change whats-new.rst * Update whatsnew --------- Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
Bumps the actions group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact). Updates `actions/upload-artifact` from 6 to 7 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v6...v7) Updates `actions/download-artifact` from 7 to 8 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v7...v8) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: actions/download-artifact dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…_concat_periods` (pydata#11204) * Filter deprecated warning * Remove inspect.signature raises error test. The example no longer raises an error * Type of error changed in numpy 2.4
* Update pre-commit hooks updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.14 → v0.15.4](astral-sh/ruff-pre-commit@v0.14.14...v0.15.4) - [github.com/abravalheri/validate-pyproject: v0.24.1 → v0.25](abravalheri/validate-pyproject@v0.24.1...v0.25) - [github.com/adhtruong/mirrors-typos: v1.42.3 → v1.44.0](adhtruong/mirrors-typos@v1.42.3...v1.44.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * apply ruff changes * fix mypy stuff * fix stubtest, don't ask me why or how --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Michael Niklas <mick.niklas@gmail.com> Co-authored-by: Julia Signell <jsignell@gmail.com>
All parameters in open_zarr were untyped, which caused type checkers like pyright to reject valid arguments (e.g. passing "auto" for chunks). Adds annotations to every parameter and the return type, using T_Chunks for the chunks parameter and matching types from the docstrings for the rest. Fixes pydata#11221
7889687 to
8d80b04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds type annotations to all parameters of
open_zarrand its return type.Previously the function was essentially untyped, which caused type checkers like pyright to reject valid arguments such as
chunks="auto"because the default value_default(of typeDefault) was the only inferred type.chunksis now typed asT_Chunks | DefaultDatasetFixes #11221