[NumPy-Tickets] [NumPy] #1863: Buggy results when operating on array copied with astype()
NumPy Trac
numpy-tickets@scipy....
Wed Jun 8 17:07:11 CDT 2011
#1863: Buggy results when operating on array copied with astype()
------------------------+---------------------------------------------------
Reporter: embray | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.core | Version: devel
Keywords: |
------------------------+---------------------------------------------------
I'm getting really buggy results from any mathematical operation I do on
an array of float64 that was obtained by calling `arr.astype('float64')`
on an existing array of float64s.
Here's an example that illustrates the problem (the fft stuff is
irrelevant; it just creates an array similar to the one my code is bugging
out on):
{{{
#!python
import numpy
from numpy import fft
shape = (32, 16)
type = numpy.complex64
true = numpy.arange(shape[0] * shape[1], dtype=type)
true.shape = shape
y = fft.fft(true, shape[0], 0)
y = y.imag
z = y.astype(numpy.float64)
print (y ** 2)[3]
print (z ** 2)[3]
}}}
This particular example also throws a `RuntimeWarning: overflow
encountered in square` when squaring `z`, the copy of the original array
`y`.
This just started happening recently using the latest from git. I'm
betting it has something to do with
[https://github.com/numpy/numpy/commit/a17a4996e4ed63d1b855a0917fb5fcdd5855a7d0
this commit] that made changes to astype(), but I haven't tracked down the
exact issue yet.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1863>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list