Hi, the following code works for numpy<=2.4.6 but doesn't in 2.5.0:
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "numpy-quaternion==2024.0.13",
# ]
# ///
import numpy as np
import quaternion
q = quaternion.quaternion(1, 0, 0, 0)
q = np.array(q, dtype=q.dtype)
print(q.conjugate())
q.dtype is quaternion.quaternion, it should have no effect recasting into an array of same type and size (?), but errors out weirdly:
$ uv run --with numpy==2.4.6 script.py
quaternion(1, -0, -0, -0)
$ uv run --with numpy==2.5.0 script.py
Traceback (most recent call last):
File "/home/tremeschin/script.py", line 15, in <module>
print(q.conjugate())
~~~~~~~~~~~^^
TypeError: cannot conjugate non-numeric dtype
Same thing when running np.array((1, 0, 0, 0), dtype=quaternion.quaternion).conjugate().
Not sure if this usage is intended/supported since isinstance(q, np.ndarray) is False, but it used to work. I've hit a bug in a project assuming otherwise, as my long-existing 'ensure numpy' method casted the incoming quaternions into themselves with the same dtype.
Well, wish I were familiar with numpy internals to tell what went wrong or suggest a fix, that's as far as I can help 🙂
Hi, the following code works for
numpy<=2.4.6but doesn't in2.5.0:q.dtype is
quaternion.quaternion, it should have no effect recasting into an array of same type and size (?), but errors out weirdly:Same thing when running
np.array((1, 0, 0, 0), dtype=quaternion.quaternion).conjugate().Not sure if this usage is intended/supported since
isinstance(q, np.ndarray)is False, but it used to work. I've hit a bug in a project assuming otherwise, as my long-existing 'ensure numpy' method casted the incoming quaternions into themselves with the same dtype.Well, wish I were familiar with numpy internals to tell what went wrong or suggest a fix, that's as far as I can help 🙂