[Numpy-discussion] Strange error taking log of PyObject array
Travis Oliphant
oliphant.travis at ieee.org
Mon Jul 10 21:46:21 EDT 2006
Tom Denniston wrote:
> The following works on a float array but not an object array. It
> gives a very strange error message.
>
> (Pdb) numpy.log(numpy.array([19155613843.7], dtype=object))
> *** AttributeError: 'float' object has no attribute 'log'
>
This is expected behavior. For object arrays the ufuncs look to the
objects themselves for implementation. In this case. The ufunc tries
to call the log method of each entry in the array. The first entry is a
float (which as the error shows) does not have a log attribute and so
you get a failure.
-Travis
More information about the NumPy-Discussion
mailing list