Skip to content

GH-51301: [Python] Fix NumPy and pandas nightly warnings - #51309

Open
akashchamp wants to merge 2 commits into
apache:mainfrom
akashchamp:GH-51301-fix-python-nightly-warnings
Open

akashchamp wants to merge 2 commits into
apache:mainfrom
akashchamp:GH-51301-fix-python-nightly-warnings

Conversation

@akashchamp

@akashchamp akashchamp commented Sep 11, 2026

Copy link
Copy Markdown

Rationale for this change

Fixes: #51301.

NumPy and pandas nightly builds emit deprecation warnings from PyArrow tests, which obscures compatibility signals.

What changes are included in this PR?

This updates pandas datetime accessors and Timestamp parsing, requests versioned DLPack exports outside legacy-behavior coverage, captures the expected warning where legacy DLPack behavior is intentionally tested, scopes intentional generic NumPy-unit warnings, and makes the pandas comparison and timedelta inputs explicit.

It also fixes the legacy DLPack path in Array.__dlpack__ and Tensor.__dlpack__ (array.pxi, tensor.pxi) so the "unversioned DLPack capsule" DeprecationWarning is only emitted after the legacy tensor and its capsule were created successfully (so a warning escalated to an error cannot leak the exported tensor). Previously a failing export (for example an immutable Tensor) raised NotImplementedError and warned at the same time, which is why test_dlpack_legacy_capsule_immutable_tensor had to expect both; it now only expects the error again.

Are these changes tested?

  • Manually exercised the affected NumPy/Pandas conversions and DLPack exports with warnings treated as errors, including versioned and legacy DLPack behavior.
  • Focused affected tests: 21 passed under NumPy 2.6.0.dev0 and pandas 3.1.0.dev0.
  • The unfiltered focused run passed and reported only the existing timezone Series.values Pandas4Warning tracked separately in [Python] Update pandas->pyarrow conversion for the .values deprecation in pandas #51302. That exact warning was filtered solely for the -W error validation command; this PR does not suppress it.
  • The .pxi reordering is covered by the existing test_dlpack_legacy_capsule* tests and relies on CI for a runtime run.

Are there any user-facing changes?

No.

used codex with pr development

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #51301 has been automatically assigned in GitHub to PR creator.

Comment thread python/pyarrow/tests/test_dlpack.py Outdated
…after a successful export

Array.__dlpack__ and Tensor.__dlpack__ warned about the deprecated
unversioned capsule before calling into the C++ exporter, so a failing
export (for example an immutable Tensor) raised NotImplementedError and
emitted a DeprecationWarning at the same time. Create the legacy tensor
and its capsule first and only warn once that succeeded, so the error
path no longer warns and a warning escalated to an error cannot leak
the exported tensor. Drop the warning expectation from
test_dlpack_legacy_capsule_immutable_tensor accordingly.
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #51301 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Fix deprecation warnings in the tests with numpy/pandas nightly

3 participants