Skip to content

Use np.isin instead of np.in1d to fix numpy 2.4 test compatibility#5522

Merged
emilykl merged 3 commits intoplotly:mainfrom
thunze:numpy-2.4-is1d-removal
Apr 14, 2026
Merged

Use np.isin instead of np.in1d to fix numpy 2.4 test compatibility#5522
emilykl merged 3 commits intoplotly:mainfrom
thunze:numpy-2.4-is1d-removal

Conversation

@thunze
Copy link
Copy Markdown
Contributor

@thunze thunze commented Feb 23, 2026

numpy.in1d has been deprecated since numpy 2.0 and was now removed with numpy 2.4 in favor of numpy.isin.

For the two affected calls, the behavior of numpy.in1d and numpy.isin should be equivalent, so I went ahead and replaced the usages of numpy.in1d with numpy.isin.

Code PR

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the code generator and not the generated files.
  • I have added tests or modified existing tests.
  • For a new feature, I have added documentation examples (please see the doc checklist as well).
  • I have added a CHANGELOG entry if changing anything substantial.
  • For a new feature or a change in behavior, I have updated the relevant docstrings in the code.

@thunze
Copy link
Copy Markdown
Contributor Author

thunze commented Feb 23, 2026

The CI failure doesn't look related to this change.

thunze added a commit to thunze/nixpkgs that referenced this pull request Feb 23, 2026
`pytest_ignore_collect` takes only `collection_path` starting with
pytest 9 [1]. Most of the paths referenced in `plotly/conftest.py`
don't exist anymore and wouldn't be collected anyway, so we can just
remove the file.

Upstream PR: plotly/plotly.py#5522

[1] https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path
@thunze thunze mentioned this pull request Feb 24, 2026
5 tasks
@camdecoster
Copy link
Copy Markdown
Contributor

Thanks for the PR! Could you please fill out the description post a bit more? It will be easier to review with more background information and any testing steps to verify that the change won't break anything.

@camdecoster camdecoster assigned camdecoster and unassigned thunze Apr 14, 2026
Copy link
Copy Markdown
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

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

Thanks @thunze for the fix! Looks good.

@emilykl emilykl merged commit c9d7330 into plotly:main Apr 14, 2026
23 checks passed
@thunze thunze deleted the numpy-2.4-is1d-removal branch April 14, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants