[Numpy-discussion] .max(0) on reshaped array returns inconsistent results.
Nathaniel Smith
njs at pobox.com
Fri May 25 07:52:07 EDT 2012
On Fri, May 25, 2012 at 12:46 PM, Thouis (Ray) Jones <thouis at gmail.com> wrote:
> I'm seeing some strange behavior from .max() on a reshaped array in
> the current master, and wanted to raise it here to make sure it's not
> something uniquely broken in my setup.
>
> This code fails for me, though changing the context (adding a counter
> to the loop, or running under "python -i") sometimes prevents it from
> failing. This code doesn't fail under 1.6.2.
>
> ---------------
> import numpy as np
>
> b = np.array([0, 1, 2, 3, 4, 5], np.int64)
> a = b.reshape(3, 2)
>
> while True:
> np.testing.assert_array_equal(np.atleast_1d(np.array(a.max(0), np.float)),
> np.atleast_1d(np.array(a.max(0), np.float)))
> ---------------
>
> I spent several hours with valgrind trying to track down what was
> causing this, but had no luck. Perhaps someone with more knowledge of
> the numpy ufunc internals can track it down faster than me.
What do you get, if not the expected value? And are the calls to
atleast_1d, np.array, etc., necessary to trigger the problem, or will
just plain a.max(0) do it?
-- Nathaniel
More information about the NumPy-Discussion
mailing list