TypeError: return arrays must be of ArrayType for a function that uses only floats
You are using numpy.log
function here, its second argument is not base
but out array:
>>> import numpy as np>>> np.log(1.1, 2)Traceback (most recent call last): File "<ipython-input-5-4d17df635b06>", line 1, in <module> np.log(1.1, 2)TypeError: return arrays must be of ArrayType
You can now either use numpy.math.log
or Python's math.log
:
>>> np.math.log(1.1, 2)0.13750352374993502>>> import math>>> math.log(1.1, 2) #This will return a float object not Numpy's scalar value0.13750352374993502
Or if you're dealing only with base 2 then as @WarrenWeckesser suggested you can use numpy.log2
: