Remove most warning exclusions#10695
Merged
Merged
Conversation
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>
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>
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>
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>
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>
for more information, see https://pre-commit.ci
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'.
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.
These warnings are no longer ignored and will be reported in CI. Co-authored-by: Claude <no-reply@anthropic.com>
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.
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
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.
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.
- 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
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.
Summary
Removed the global warning filter for non-tuple sequence indexing by fixing the underlying code.
Changes
test_nputils.pythat was usingx[[1, 2], [1, 2]]x[([1, 2], [1, 2])]This continues the work from #10693 to clean up warning exclusions.
🤖 Generated with Claude Code