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

Make numpy-quaternion an optional dependency #514

Closed hakonanes closed 2 months ago

hakonanes commented 2 months ago

I see numpy-quaternion has become a NumPy-2.0-transition-bottleneck downstream for pyxem (https://github.com/pyxem/pyxem/issues/1099). There's discussion of our use of this package in https://github.com/pyxem/orix/issues/506 and https://github.com/pyxem/orix/pull/507.

I suggest to make numpy-quaternion an optional dependency.

We use numpy-quaternion for three operations:

All places for speed, not for functionality. We had implementations of these things without numpy-quaternion before. We can re-introduce these computations as a fall-back if numpy-quaternion is unavailable.

As an added bonus to this work, I want to make it easier to make dependencies in orix optional. numpy-quaternion is a good place to start.

We can do this fairly quickly. If interest, we can make a v0.13.1 patch release.

hakonanes commented 2 months ago

I've gotten one 👍🏻, so I'm going for it

CSSFrancis commented 2 months ago

@hakonanes That would be fantastic! I think @ericpre would also be very happy :)

pc494 commented 2 months ago

I certainly will be very happy. I assume the speed trade-off is significant, but the documentation can be marked up to reflect that.

CSSFrancis commented 2 months ago

I certainly will be very happy. I assume the speed trade-off is significant, but the documentation can be marked up to reflect that.

I think it's a factor of 2 is what @hakonanes said. I feel that is pretty minimal, there are other places in orix where it would be easier to speed things up if we really needed it.

hakonanes commented 1 month ago

Recently released numpy-quaternion 2024.0.2 is compatible with NumPy 2. However, I suggest we keep numpy-quaternion as an optional dependency. Rather, we should try to make more dependencies optional!