[NumPy-Tickets] [NumPy] #1539: MSVC specific TypeError when using double, longdouble in numpy.dot
NumPy Trac
numpy-tickets@scipy....
Thu Jul 8 03:13:47 CDT 2010
#1539: MSVC specific TypeError when using double, longdouble in numpy.dot
---------------------+------------------------------------------------------
Reporter: cgohlke | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: Other | Version:
Keywords: |
---------------------+------------------------------------------------------
This issue has been discussed at [http://mail.scipy.org/pipermail/numpy-
discussion/2010-July/051352.html] and is the cause of the scipy.sparse
TypeError test failures reported at [http://mail.scipy.org/pipermail
/scipy-user/2010-July/025961.html].
Using Python 2.6.5 32 bit on Windows and numpy 1.4.1 built with Visual
Studio 2008 (msvc9), I get the following:
{{{
>>> a = numpy.array([[1.0]])
>>> numpy.dot(a.astype('double'), a.astype('longdouble'))
array([[ 1.]])
>>> a = numpy.array([[1]])
>>> 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
>>> a = numpy.array([[1]])
>>> numpy.dot(a.astype('single'), a.astype('longdouble'))
array([[1.0]], dtype=float64)
>>> a = numpy.array([[1]])
>>> numpy.dot(a.astype('longdouble'), a.astype('double'))
array([[1.0]], dtype=float64)
>>> numpy.array([1]).astype('longdouble').dtype.num
13
>>> numpy.array([1.0]).astype('longdouble').dtype.num
12
}}}
The TypeError is unexpected. The same results are obtained when using a
msvc7 build of numpy 1.4.1 on Python 2.5, or a msvc9 64 bit build of numpy
2.0.dev on Python 3.1.
Using numpy 1.4.1 built with mingw does not raise a TypeError:
{{{
>>> a = numpy.array([[1]])
>>> numpy.dot(a.astype('double'), a.astype('longdouble'))
array([[1.0]], dtype=float96)
}}}
Note that for MSVC compilers sizeof(longdouble) = sizeof(double) = 8
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1539>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list