Closed sgill2 closed 7 years ago
Thanks for spotting the typo!
You would be completely right, if this was pure python code.
The problem lies in @jit(nopython=True)
as it is explained in the numba docs.
Real "jitted" functions allow only ints, floats, strings, bools and arrays of the former.
(A good rule of thumb is: If you can directly translate it into FORTRAN code, it can be nopython-mode jitted.)
This especially means, that you cannot decorate normal methods with @jit(nopython=True)
,
since the implicit first argument self
is always a non-basic-type python instance. So you need normal functions or staticmethods.
It is important to know that _jit_calc_positions
calls _jit_calc_single_position
.
Usually (without the restrictions of numba) _jit_calc_positions
would be a normal method and _jit_calc_single_position
a staticmethod. _jit_calc_positions
could then just call self._jit_calc_single_position
in its body.
If they are both staticmethods _jit_calc_positions
can't call normal or classmethods of itself.
For this reason I have put _jit_calc_single_position
into a namespace global to the class.
Now to conclude:
PS: Actually if it was normal python code, I would write this part completely without staticmethods.
All the information about the positions... is contained in self
. The only reason why I use a staticmethod and pass in an array of floats for the positions are the aforementioned restrictions of numba.
In
chemcoord.internal_coordinates._zmat_class_core.py
you've recently implemented_jit_calc_positions
as a static method for theZmatCore
class. It might make sense then to have_jit_calc_singe_position
be a static method for that class as well, since they are related functions.And on a minor related note, I think you probably intended to name the function _jit_cal_single_position, not _jit_calc_singe_position. That is, unless you wanted to slightly burn the molecule's position ;)