I have a function in a script problem1.py:
def normal_method(target):
a = np.array(np.arange(1,target))
divisible_numbers = a[(a%3==0)|(a%5==0)]
sum_value = np.sum(divisible_numbers)
print sum_value
While calling this function in an IPython window using ,
import numpy as np
from problem1 import normal_method
%timeit normal_method(100)
It gives me TypeError saying normal_method takes no arguments. But when I paste the function into IPython and then call it using the same statement it works. Any ideas why this occurs?
natural_numbersasayou are better off writingdivisible_numbers = a[(a%3==0) | (a%5==0)]to avoid the for loop.problem1.pydoes not haveimport numpy as np, could be something strange withIPythonerror reporting. It would be an issue withoutIPython.def ihn(): print np.arange(5)and I try to dofrom problem1 import ihn, it does not even acknowledge ihn. But if I doimport problem1, then I can use ihn. Strange!