Skip to content

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

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

GH-51301: [Python] Fix NumPy and pandas nightly warnings#51309
akashchamp wants to merge 1 commit 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.

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.

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 on lines +273 to +277
with pytest.warns(DeprecationWarning, match="unversioned DLPack capsule"):
with pytest.raises(NotImplementedError,
match="Legacy DLPack support is not implemented "
"for immutable tensors"):
tensor.__dlpack__(max_version=max_version)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an issue with our own implementation? (we should not be raising both a warning an error at the same time? assuming they both from our code)

cc @AlenkaF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, this is coming from our code, yes.
DeprecationWarning is triggered in Cython, NotImplementedError is triggered in C++. I think we only need to change the order here:

arrow/python/pyarrow/array.pxi

Lines 2375 to 2379 in 9ae25f1

warnings.warn(
"Exporting an unversioned DLPack capsule is deprecated, "
"pass max_version=(1, 0) or higher.",
DeprecationWarning, stacklevel=2)
legacy_tensor = GetResultValue(ExportArrayToDLPack(self.sp_array))

where the warning is triggered only after legacy_tensor is successfully created. Same in tensor.pxi.

I can create a separate PR tomorrow, if this change is out of scope for this issue.

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