Skip to content

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

Merged
AlenkaF merged 16 commits into
apache:mainfrom
AlenkaF:gh-51301-fix-deprecation-warnings
Oct 6, 2026
Merged

AlenkaF merged 16 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)

Comment thread python/pyarrow/tests/test_dlpack.py Outdated
@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

Comment thread python/pyarrow/tests/test_pandas.py
Comment thread python/pyarrow/tests/test_dlpack.py Outdated
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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reverted the rest dlpack changes: a148c13
and created a new issue: #51481

@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
Copilot AI review requested due to automatic review settings September 24, 2026 06:25
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Sep 24, 2026

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

Three moderate review issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)

Comment thread python/pyarrow/tests/test_array.py
AlenkaF and others added 3 commits October 5, 2026 06:41
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 5, 2026 05:43
@AlenkaF
AlenkaF force-pushed the gh-51301-fix-deprecation-warnings branch from 8e0342f to 8020466 Compare October 5, 2026 05:43
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 5, 2026
@AlenkaF

AlenkaF commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

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

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

🔵 Needs a closer look

Unresolved warnings and reduced generic timedelta test coverage remain.

Review effort: Lite
Findings: None

Resolved since last review (1)

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Revision: 8020466

Submitted crossbow builds: ursacomputing/crossbow @ actions-d4a8f679ef

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

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 5, 2026
Copilot AI lite review requested due to automatic review settings October 6, 2026 04:38
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 6, 2026

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

🔵 Needs a closer look

DLPack warning handling remains incomplete, and the NumPy prerelease version guards need correction.

Review effort: Lite
Findings: None

@AlenkaF

AlenkaF commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

I have run 3 different version of the test_does_not_mutate_timedelta_dtype on this diff:

-  if (type == NPY_DATETIME || type == NPY_TIMEDELTA) {
+  if (type == NPY_DATETIME) {

which should prodice a bug and the test should fail. That does
happen for the test on main:

expected = np.dtype('m8')

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

df = pd.DataFrame({"a": [np.timedelta64()]})
t = pa.Table.from_pandas(df)
t.to_pandas()

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

and the older version of the test on this PR:

expected = np.dtype('m8')

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

df = pd.DataFrame({"a": [np.timedelta64(0, "s")]})
t = pa.Table.from_pandas(df)
t.to_pandas()

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

but the bug can not be reproduced with this change:

expected = np.dtype('<m8[s]')

assert np.dtype(np.timedelta64(0, "s")) == expected

df = pd.DataFrame({"a": [np.timedelta64(0, "s")]})
t = pa.Table.from_pandas(df)
t.to_pandas()

assert np.dtype(np.timedelta64(0, "s")) == expected

as @tadeja opened up here: #51404 (comment).
I reverted the change in 40997f0 so we do keep testing the buggy behavior is fixed.

@AlenkaF

AlenkaF commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

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

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Revision: 40997f0

Submitted crossbow builds: ursacomputing/crossbow @ actions-7566b946d6

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

@AlenkaF

AlenkaF commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

I think I have addressed all the comments, the logs are clean: https://github.com/ursacomputing/crossbow/actions/runs/37419973097/job/112126927373#step:7:4398 with only dlpack fixes needed. I will work on that next.

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Oct 6, 2026
@AlenkaF
AlenkaF merged commit 1afe206 into apache:main Oct 6, 2026
40 checks passed
@AlenkaF AlenkaF removed the awaiting merge Awaiting merge label Oct 6, 2026
@AlenkaF
AlenkaF deleted the gh-51301-fix-deprecation-warnings branch October 6, 2026 11:33
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.

5 participants