Skip to content

GH-51301: Fix deprecation warnings in the tests with numpy/pandas nightly - #51404

Open
AlenkaF wants to merge 6 commits into
apache:mainfrom
AlenkaF:gh-51301-fix-deprecation-warnings
Open

AlenkaF wants to merge 6 commits into
apache:mainfrom
AlenkaF:gh-51301-fix-deprecation-warnings

Conversation

@AlenkaF

@AlenkaF AlenkaF commented Sep 21, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Test warnings accumulated in our CI.

What changes are included in this PR?

The warnings are fixed or filtered if the deprecated functionality is still being tested.

Are these changes tested?

Yes.

Are there any user-facing changes?

No. Fixing test warnings in our CI.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

Copy link
Copy Markdown

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

@AlenkaF

AlenkaF commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Opened a PR though we have one already opened: #51309.
Might be wrong, but the process seems very similar to other reviews where quite a lot of time is needed to communicate with the contributor (or the contributor's agent) what would be good to change. Decided to fix this quickly by myself.

@AlenkaF

AlenkaF commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Warnings gone:
https://github.com/apache/arrow/actions/runs/35588604946/job/106297664397?pr=51404#step:6:4899

vs:
https://github.com/apache/arrow/actions/runs/35589580522/job/106300673910#step:6:4897

from the same AMD64 Conda Python 3.14 Pandas latest job.

@jorisvandenbossche if you have time for review.

@AlenkaF
AlenkaF marked this pull request as ready for review September 21, 2026 14:04
Copilot AI lite review requested due to automatic review settings September 21, 2026 14:04
@AlenkaF
AlenkaF requested review from raulcd and rok as code owners September 21, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Warning failures can leak allocated DLPack tensors in both export paths.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This PR updates tests and DLPack handling to address NumPy/Pandas deprecation warnings while preserving legacy behavior coverage.

Changes:

  • Updated deprecated NumPy and pandas test usage.
  • Filtered intentional deprecation warnings.
  • Adjusted legacy DLPack export warning handling and tests.
File Summary
python/​pyarrow/​tests/​test_pandas.py Uses explicit timedelta units.
python/​pyarrow/​tests/​test_dlpack.py Updates warning filters and versioned DLPack coverage.
python/​pyarrow/​tests/​test_compute.py Updates timestamp construction and warning filters.
python/​pyarrow/​tests/​test_array.py Handles NumPy generic-unit deprecations.
python/​pyarrow/​tensor.pxi Adjusts legacy DLPack export warning handling.
python/​pyarrow/​array.pxi Adjusts legacy DLPack export warning handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/pyarrow/array.pxi Outdated
Comment thread python/pyarrow/tensor.pxi Outdated
@AlenkaF
AlenkaF marked this pull request as draft September 22, 2026 08:33
@AlenkaF

AlenkaF commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

Converting to draft as I need to think about Copilot's comment, looks right from a quick read.
I also need to rebase as I included some changes that have been fixed by #51307

@AlenkaF
AlenkaF force-pushed the gh-51301-fix-deprecation-warnings branch from b51c0a4 to 84a8518 Compare September 22, 2026 12:39
@AlenkaF

AlenkaF commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

I decided to remove changes connected to the depr warning in __dlpack__:
The solution would need or check if warning is turned into an error and calling a deleter, or constructing a PyCapsule before emitting a warning. Both seem to be things that need some discussion and a fix in a separate issue I think.

Currently the CI is not showing any deprecation warnings in out tests: https://github.com/apache/arrow/actions/runs/35728469810/job/106747835234?pr=51404#step:6:4240

@AlenkaF
AlenkaF marked this pull request as ready for review September 22, 2026 13:01
Copilot AI review requested due to automatic review settings September 22, 2026 13:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved NumPy compatibility issues affect DLPack tests and nightly generic-unit warning coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

with pytest.raises(TypeError, match="Can only use DLPack "
"on arrays with no nulls."):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))
@jorisvandenbossche

Copy link
Copy Markdown
Member

@github-actions crossbow submit test-conda-python-3.14-pandas-nightly-numpy-nightly

@github-actions

Copy link
Copy Markdown

Revision: 84a8518

Submitted crossbow builds: ursacomputing/crossbow @ actions-0a1f3fcf86

Task Status
test-conda-python-3.14-pandas-nightly-numpy-nightly GitHub Actions

assert np.dtype(np.timedelta64) == expected

df = pd.DataFrame({"a": [np.timedelta64()]})
df = pd.DataFrame({"a": [np.timedelta64(0, "s")]})

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.

While this makes the test run without the warning, I am not sure if then the surrounding asserts still make sense.
One thing to do is also to change expected = np.dtype('m8') to use "m8[s]", but no idea if that would then still have produced the initial bug (the reason this test was added, #13553)

with pytest.raises(TypeError, match="Can only use DLPack "
"on arrays with no nulls."):
np.from_dlpack(arr)
np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0)))

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.

If leaving the DLPack depr question for a separate issue, I would maybe also leave out any of the dlpack-related changes here.

@github-actions github-actions Bot removed the awaiting review Awaiting review label Sep 22, 2026
@jorisvandenbossche

Copy link
Copy Markdown
Member

@AlenkaF thanks for the PR! I triggered a nightly pandas/numpy crossbow build, because it is there that I checked for the warnings (it might be that some of those were also showing up in the main CI builds, though)

@github-actions github-actions Bot added the awaiting changes Awaiting changes label Sep 22, 2026
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.

3 participants