[Numpy-discussion] TypeError when using double , longdouble in numpy.dot

Christoph Gohlke cgohlke at uci.edu
Thu Jul 8 00:13:05 EDT 2010


Dear NumPy developers,

I am trying to solve some scipy.sparse TypeError failures reported in 
[1] and reduced them to the following example:


>>> import numpy
>>> a = numpy.array([[1]])

>>> numpy.dot(a.astype('single'), a.astype('longdouble'))
array([[1.0]], dtype=float64)

>>> numpy.dot(a.astype('double'), a.astype('longdouble'))
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: array cannot be safely cast to required type


Is this exception expected?

Also I noticed this:

>>> numpy.array([1]).astype('longdouble').dtype.num
13
>>> numpy.array([1.0]).astype('longdouble').dtype.num
12


I am using Python 2.6.5 for Windows and numpy 1.4.1 compiled with msvc9, 
where sizeof(longdouble) == sizeof(double).


[1] http://aspn.activestate.com/ASPN/Mail/Message/scipy-user/3875416

--
Christoph



More information about the NumPy-Discussion mailing list