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

Christoph Gohlke cgohlke@uci....
Thu Jul 8 03:17:34 CDT 2010



On 7/7/2010 9:25 PM, David Cournapeau wrote:
> On Thu, Jul 8, 2010 at 6:13 AM, Christoph Gohlke<cgohlke@uci.edu>  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?
>
> No, I don't think so. The error seems to be platform specific - I have
> the expected result on my macbook.
>
>>
>> Also I noticed this:
>>
>>>>> numpy.array([1]).astype('longdouble').dtype.num
>> 13
>>>>> numpy.array([1.0]).astype('longdouble').dtype.num
>> 12
>
> This is unexpected. There maybe some untested/buggy codepaths for the
> windows case (where sizeof(double) == sizeof(long double)). I will try
> to look into it, but please post an issue on trac so that it does not
> get lost,
>

Thank you. I opened a ticket: http://projects.scipy.org/numpy/ticket/1539

--
Christoph


More information about the NumPy-Discussion mailing list