pyxem / orix

Analysing crystal orientations and symmetry in Python
https://orix.readthedocs.io
GNU General Public License v3.0
83 stars 50 forks source link

v0.13.2: NumPy 2.0 compatibility by using two import routes for VisibleDeprecationWarning #525

Closed hakonanes closed 2 months ago

hakonanes commented 2 months ago

Description of the change

The only place orix's code is incompatible with NumPy v2 is the importing of VisibleDeprecationWarning from the top namespace. This was removed in v2. The replacement, exceptions.VisibleDeprecationWarning, was added in v1.25. To support NumPy older and newer, I've added both import attempts in orix.constants, making the warning available internally via this module.

diffpy.structure just made a pre-release v3.2.2rc0 which supports NumPy 2.0 (here on PyPI). With this PR, orix is also compatible with NumPy 2.0. orix is still compatible with diffpy.structure >= 3.0.2, and we don't need to increase this.

I suggest to make a patch release v0.13.2 within the next few days after this PR is merged into main.

Progress of the PR

For reviewers

pc494 commented 2 months ago

Description of the change

The only place orix's code is incompatible with NumPy v2 is the importing of VisibleDeprecationWarning from the top namespace. This was removed in v2. The replacement, exceptions.VisibleDeprecationWarning, was added in v1.25. To support NumPy older and newer, I've added both import attempts in orix.constants, making the warning available internally via this module.

diffpy.structure just made a pre-release v3.2.2rc0 which supports NumPy 2.0 (here on PyPI). With this PR, orix is also compatible with NumPy 2.0. orix is still compatible with diffpy.structure >= 3.0.2, and we don't need to increase this.

Just to be clear, orix would have two installation options:

Path one, full fresh install

pip install orix

takes numpy2 and this new diffpy version.

Path 2, on a legacy install which already has numpy1 would install orix correctly (at 0.13.2) with no issues?

hakonanes commented 2 months ago

Yes

pc494 commented 2 months ago

Yes

great! I'll review. I think we should be numpy2 only at some point, but probably not just yet...

hakonanes commented 2 months ago

Thanks! I checked locally, and with this PR, diffpy.structure v3.2.2rc0, and NumPy v2, all tests ran fine.

hakonanes commented 2 months ago

I'll publish the patch release v0.13.2 then.

hakonanes commented 2 months ago

Hm, well, perhaps wait a few days until diffpy.structure v3.2.2 is released.