jkrogager / VoigtFit

Python code to fit absorption lines semi-interactively
http://voigtfit.readthedocs.io/
MIT License
28 stars 12 forks source link

Numba deprecation messages #38

Closed nimishak-cosmos closed 3 years ago

nimishak-cosmos commented 3 years ago

Hello,

I hope that you are doing well. I am not sure whether you are aware of this. While running the latest version of the code, I encountered the following Numba errors and warnings. I think that this is mainly related to the Numba version. Could you please let me know which version you are using for your code for an error-free compilation? Or if you have some updates on the code, I am happy to test the updated code as well?

Thanks & Best Regards, Nimisha

Compilation is falling back to object mode WITH looplifting enabled because Function "convolve_numba" failed type inference due to: No implementation of function Function(<function concatenate at 0x7f22b8a15950>) found for signature:

concatenate(list(array(float64, 1d, C)))

There are 2 candidate implementations:

During: resolving callee type: Function(<function concatenate at 0x7f22b8a15950>) During: typing of call at /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py (103)

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py", line 103: def convolve_numba(P, kernel):

pad = np.ones(N)
P_pad = np.concatenate([pad, P, pad])
^

@jit /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py:76: NumbaWarning: Compilation is falling back to object mode WITHOUT looplifting enabled because Function "convolve_numba" failed type inference due to: Cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py", line 105: def convolve_numba(P, kernel):

P_con = np.zeros_like(P)
for i, lsf_i in enumerate(kernel):
^

@jit /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/numba/core/object_mode_passes.py:152: NumbaWarning: Function "convolve_numba" was compiled in object mode without forceobj=True, but has lifted loops.

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py", line 101: def convolve_numba(P, kernel):

"""
N = kernel.shape[1]//2
^

state.func_ir.loc)) /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/numba/core/object_mode_passes.py:162: NumbaDeprecationWarning: Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.6/site-packages/VoigtFit/voigt.py", line 101: def convolve_numba(P, kernel):

"""
N = kernel.shape[1]//2
^

jkrogager commented 3 years ago

What version of numba are you using?

I'm on numba v0.51.2 and running Python 3.8.6

nimishak-cosmos commented 3 years ago

Hi, thanks for the reply. I rebuilt my Conda environment with numba 0.51.2 and python 3.8.10. (Somehow python 3.8.6 was not available to be installed.) I still get the error and warnings shown at the end of this message.

(1) They direct to this link which might be worth checking: https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

The link mentions that the "Deprecation warnings and replacements will be issued in version 0.52.0". So it is strange warnings are issued even for 0.51.2.

(2) It might be useful to supply the keyword argument "forceobj=True" while using @jit decorator in https://github.com/jkrogager/VoigtFit/blob/master/VoigtFit/voigt.py

-- /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py:76: NumbaWarning: Compilation is falling back to object mode WITH looplifting enabled because Function "convolve_numba" failed type inference due to: No implementation of function Function(<function concatenate at 0x7f72cc981c10>) found for signature:

concatenate(list(array(float64, 1d, C)))

There are 2 candidate implementations:

During: resolving callee type: Function(<function concatenate at 0x7f72cc981c10>) During: typing of call at /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py (103)

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 103: def convolve_numba(P, kernel):

pad = np.ones(N)
P_pad = np.concatenate([pad, P, pad])
^

@jit /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py:76: NumbaWarning: Compilation is falling back to object mode WITHOUT looplifting enabled because Function "convolve_numba" failed type inference due to: cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 105: def convolve_numba(P, kernel):

P_con = np.zeros_like(P)
for i, lsf_i in enumerate(kernel):
^

@jit /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/numba/core/object_mode_passes.py:177: NumbaWarning: Function "convolve_numba" was compiled in object mode without forceobj=True, but has lifted loops.

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 101: def convolve_numba(P, kernel):

"""
N = kernel.shape[1]//2
^

warnings.warn(errors.NumbaWarning(warn_msg, /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/numba/core/object_mode_passes.py:187: NumbaDeprecationWarning: Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 101: def convolve_numba(P, kernel):

"""
N = kernel.shape[1]//2
^

warnings.warn(errors.NumbaDeprecationWarning(msg, /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py:76: NumbaWarning: Compilation is falling back to object mode WITHOUT looplifting enabled because Function "convolve_numba" failed type inference due to: non-precise type pyobject During: typing of argument at /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py (105)

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 105: def convolve_numba(P, kernel):

P_con = np.zeros_like(P)
for i, lsf_i in enumerate(kernel):
^

@jit /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/numba/core/object_mode_passes.py:177: NumbaWarning: Function "convolve_numba" was compiled in object mode without forceobj=True.

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 105: def convolve_numba(P, kernel):

P_con = np.zeros_like(P)
for i, lsf_i in enumerate(kernel):
^

warnings.warn(errors.NumbaWarning(warn_msg, /user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/numba/core/object_mode_passes.py:187: NumbaDeprecationWarning: Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "../../../../../user/kumari/miniconda3/envs/voigtfit_conda/lib/python3.8/site-packages/VoigtFit/voigt.py", line 105: def convolve_numba(P, kernel):

P_con = np.zeros_like(P)
for i, lsf_i in enumerate(kernel):
^

warnings.warn(errors.NumbaDeprecationWarning(msg,

jkrogager commented 3 years ago

Sorry for the delay. The code should be working by now (update to the latest version, 3.11.10). Turns out that numba only supports np.concatenate if the input is given as a tuple, not when using a list as input. Let me know if you keep having issues with this. Cheers!