On Wed, Mar 23, 2011 at 13:51, <[email protected]> wrote: > 2011/3/23 Dmitrey <[email protected]>: >>>>> from numpy import log2, __version__ >>>>> >>>>> log2(2**63) >> Traceback (most recent call >> last): >> File "<stdin>", line 1, in >> <module> >> AttributeError: log2 >>>>> __version__ >> '2.0.0.dev-1fe8136' >> (doesn't work with 1.3.0 as well) > >>>> np.array([2**63]) > array([9223372036854775808], dtype=object) > >>>> log2(2.**63) > 62.999999999999993 >>>> log2(2**63) > Traceback (most recent call last): > File "<pyshell#9>", line 1, in <module> > log2(2**63) > AttributeError: log2 > > integer conversion problem
Right. numpy cannot safely convert a long object of that size to a dtype it knows about, so it leaves it as an object array. Most ufuncs operate on object arrays by looking for a method on each element with the name of the ufunc. So np.log2(np.array([x], dtype=object)) will look for x.log2(). -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
