(Python 2.7, Numba 0.33, OS X)
If I have a file called ex.py with some code that will fail to run in python mode:
import numpy as np
import numba
@numba.jit # didn't set nopython mode, so can fall back to object mode!
def example(values, threshold):
result = np.zeros_like(values)
for i in range(values.shape): # This should be values.shape[0]!
if np.abs(values[i]) >= threshold:
result[i] = values[i]
return result
And then I run the Numba function using execfile from a file called load_ex.py:
import np
global_dict = {}
execfile('ex.py', global_dict)
in_array = np.array([0,1,2])
print global_dict['example'](in_array, 1)
I get the unexpected exception:
Traceback (most recent call last):
File "load_ex.py", line 9, in <module>
print global_dict['example'](in_array, 1)
NameError: global name 'np' is not defined
rather than the exception I would have expected:
Traceback (most recent call last):
File "ex.py", line 15, in <module>
print example(in_array, 1)
TypeError: range() integer end argument expected, got tuple.
If I force nopython mode, I get the compiler failure that I also would have expected, so this is a low priority issue. It just seems pretty weird...
(Python 2.7, Numba 0.33, OS X)
If I have a file called
ex.pywith some code that will fail to run in python mode:And then I run the Numba function using
execfilefrom a file calledload_ex.py:I get the unexpected exception:
rather than the exception I would have expected:
If I force nopython mode, I get the compiler failure that I also would have expected, so this is a low priority issue. It just seems pretty weird...