Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NumPy 2 #61

Merged
merged 4 commits into from Apr 26, 2024
Merged

Support NumPy 2 #61

merged 4 commits into from Apr 26, 2024

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Apr 26, 2024

Description

This PR addresses some issues with NumPy 2.0 (see migration guide), which is being released soon:

  • Verify that dependencies support numpy 2:

    • matplotlib: 3.8.4
    • tifffile: 2024.4.24
    • lfdfiles: 2024.4.24
    • ptufile: 2024.4.24
    • sdtfile: 2024.4.24
    • czifile: needs rewrite
    • imagecodecs: next release
  • The representation of numpy scalars changed. For example, repr(numpy.float64(2.0)) is now 'np.float64(2.0)', was '2.0'. This broke many doctests. The workaround is to enable legacy printing during doctests.

  • numpy.array(..., copy=False) now raises an exception if the array can't be copied. The new option copy=None confuses MyPy. The workaround is to replace statements like numpy.array(..., copy=False, ndmin=1) with numpy.atleast_1d(numpy.asarray(...))

  • Build wheels against numpy 2 (>=2.0.0rc1) and test with numpy 2 and numpy>=1.23.5,<2.

Release note

Summarize the changes in the code block below to be included in the
release notes:

Support NumPy 2

Checklist

  • The pull request title, summary, and description are concise.
  • Related issues are linked in the description.
  • New dependencies are explained.
  • The source code and documentation can be distributed under the MIT license.
  • The source code adheres to code standards.
  • New classes, functions, and features are thoroughly tested.
  • New, user-facing classes, functions, and features are documented.
  • New features are covered in tutorials.
  • No files other than source code, documentation, and project settings are added to the repository.

@cgohlke cgohlke added the enhancement New feature or request label Apr 26, 2024
@cgohlke cgohlke self-assigned this Apr 26, 2024
@cgohlke cgohlke changed the title WIP: Support NumPy 2 Support NumPy 2 Apr 26, 2024
Copy link
Contributor

@bruno-pannunzio bruno-pannunzio left a comment

Choose a reason for hiding this comment

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

Hi @cgohlke, good you already anticipated this changes, as I was not aware of them. It makes sense to start now already implementing the changes to make it compatible. I haven't had much time to see into detail all the changes of Numpy 2 but maybe is something we can discuss on monday's meeting so we all know the impact of this. But I think this can be merged already and then we can see what we are missing

@cgohlke cgohlke merged commit b03f635 into phasorpy:main Apr 26, 2024
13 checks passed
@cgohlke cgohlke deleted the numpy2 branch April 26, 2024 21:50
@cgohlke cgohlke mentioned this pull request Apr 27, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants