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

Christoph Gohlke cgohlke at uci.edu
Thu Jul 8 19:37:00 EDT 2010



On 7/7/2010 9:13 PM, Christoph Gohlke wrote:
> 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
>


I submitted a patch and testcase at 
http://projects.scipy.org/numpy/ticket/1539.

--
Christoph




More information about the NumPy-Discussion mailing list