Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object mode fallback deprecation in numba.jit #211

Closed
bcbnz opened this issue Jan 26, 2023 · 0 comments
Closed

Object mode fallback deprecation in numba.jit #211

bcbnz opened this issue Jan 26, 2023 · 0 comments

Comments

@bcbnz
Copy link
Contributor

bcbnz commented Jan 26, 2023

In the future, numba.jit will no longer fall back to object mode: https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit Note that prominent deprecation warnings will be emitted in 0.57.0 (not yet released; I see them because I am currently using the latest git version of numba) and fallback support will be removed in 0.59.0.

The only place where @jit is used is in src/quaternion/calculus.py for fd_indefinite_integral:

@jit
def fd_indefinite_integral(f, t):
Sfdt = np.empty_like(f)
Sfdt[0] = 0.0
for i in xrange(1, len(t)):
for j in xrange(f.shape[1]):
Sfdt[i, j] = Sfdt[i - 1, j] + (f[i, j] + f[i - 1, j]) * ((t[i] - t[i - 1]) / 2.0)
return Sfdt

All other JIT-compiled functions use @njit which disables object mode.

There are no tests which hit this function -- it is only used if SciPy is not available:

try:
from scipy.interpolate import InterpolatedUnivariateSpline
spline = spline_evaluation
derivative = spline_derivative
antiderivative = spline_indefinite_integral
indefinite_integral = spline_indefinite_integral
definite_integral = spline_definite_integral
except ImportError:
# import warnings
# warning_text = (
# "\n\n" + "!" * 57 + "\n" +
# "Could not import from scipy, which means that derivatives\n" +
# "and integrals will use less accurate finite-differencing\n" +
# "techniques. You may want to install scipy." +
# "\n" + "!" * 57 + "\n"
# )
# warnings.warn(warning_text)
derivative = fd_derivative
antiderivative = fd_indefinite_integral
indefinite_integral = fd_indefinite_integral
definite_integral = fd_definite_integral

I tried reusing test_antiderivative since fd_indefinite_integral is used to provide antiderivative if SciPy is not available, but it didn't accept the 1D input (and looking closer, test_antiderivative is really testing quaternion.calculus.spline not quaternion.calculus.antiderivative).

Unfortunately I am not familiar enough with quaternion integrals to write a suitable test to prove it, but I would guess that @jit could be replaced with @njit to future-proof the function.

moble added a commit that referenced this issue Feb 13, 2023
@moble moble closed this as completed in e294cc9 Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant