[Numpy-discussion] Odd numerical difference between Numpy 1.5.1 and Numpy > 1.5.1
robert.kern at gmail.com
Mon Apr 11 15:37:28 EDT 2011
On Mon, Apr 11, 2011 at 13:54, Skipper Seabold <jsseabold at gmail.com> wrote:
> We noticed some failing tests for statsmodels between numpy 1.5.1 and
> numpy >= 1.6.0. These are the versions where I noticed the change. It
> seems that when you divide a float array and multiply by a boolean
> array the answers are different (unless the others are also off by
> some floating point). Can anyone replicate the following using this
> script or point out what I'm missing?
> import numpy as np
> print np.__version__
> test = np.random.randint(0,2,size=10).astype(bool)
> t = 1.345
> arr = np.random.random(size=10)
> arr # okay
> t/arr # okay
> (1-test)*arr # okay
> (1-test)*t/arr # huh?
array([1, 0, 0, 0, 1, 0, 1, 1, 0, 1], dtype=int8)
array([ 1.34472656, 0. , 0. , 0. ,
1.34472656, 0. ,
1.34472656, 1.34472656, 0. , 1.34472656], dtype=float16)
Some of the recent ufunc changes or the introduction of the float16
type must have changed the way the dtype is chosen for the
"int8-array*float64-scalar" case. Previously, the result was a float64
array, as expected.
Mark, I expect this is a result of one of your changes. Can you take a
look at this?
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion