From e294cc937f3f36be981195e5e99a6d78eb3c39fc Mon Sep 17 00:00:00 2001 From: Mike Boyle Date: Mon, 13 Feb 2023 11:27:36 -0500 Subject: [PATCH] Fix numpy's new behavior in np.sum of passing int(0) for some reason. (#212) Also, don't use `@jit` any more; just `@njit`. Fixes #209 Fixes #211 --- src/numpy_quaternion.c | 10 ++++++++++ src/quaternion/calculus.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/numpy_quaternion.c b/src/numpy_quaternion.c index 453e5c7..d8989f5 100644 --- a/src/numpy_quaternion.c +++ b/src/numpy_quaternion.c @@ -971,6 +971,16 @@ static int QUATERNION_setitem(PyObject* item, quaternion* qp, void* NPY_UNUSED(a if(element == NULL) { return -1; } /* Not a sequence, or other failure */ qp->z = PyFloat_AsDouble(element); Py_DECREF(element); + } else if(PyFloat_Check(item)) { + qp->w = PyFloat_AS_DOUBLE(item); + qp->x = 0.0; + qp->y = 0.0; + qp->z = 0.0; + } else if(PyLong_Check(item)) { + qp->w = PyLong_AsDouble(item); + qp->x = 0.0; + qp->y = 0.0; + qp->z = 0.0; } else { PyErr_SetString(PyExc_TypeError, "Unknown input to QUATERNION_setitem"); diff --git a/src/quaternion/calculus.py b/src/quaternion/calculus.py index 850bc70..7ecb2de 100644 --- a/src/quaternion/calculus.py +++ b/src/quaternion/calculus.py @@ -306,7 +306,7 @@ def _derivative_3d(f, t, dfdt): return -@jit +@njit def fd_indefinite_integral(f, t): Sfdt = np.empty_like(f) Sfdt[0] = 0.0