qmathcore.py
fails its own doctest with a newer (1.9) numpy.
Adding this test to quatereon()
elif isinstance(q,float) or isinstance(q,int): # accept np.float64
self.q = 1.0 * np.array([q,0.,0.,0.])
allows qmath.quaternion([1,2,3,4]).imag()
(and conj
).
The quaternion
method is using a lot of type(q)==xxx
tests. isinstance()
is a more robust test. Also it ends with a else:pass
, and thus doesn't catch q
values that it can't handle.
After correcting some import errors, the qmathcore
doctest runs fine.