[Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

Hans Meine meine at informatik.uni-hamburg.de
Thu Jul 28 10:58:23 EDT 2011


Hi again!

Am Donnerstag, 21. Juli 2011, 16:56:21 schrieb Hans Meine:
> import numpy
> 
> class Test(numpy.ndarray):
>     pass
> 
> a1 = numpy.ndarray((1,))
> a2 = Test((1,))
> 
> assert type(a1.min()) == type(a2.min()), \
>   "%s != %s" % (type(a1.min()), type(a2.min()))
> # ---------------------------------------------------
> 
> This code fails with 1.6.0, while it worked in 1.3.0.

I just tried with 1.5.1 (Ubuntu natty), and it works, too.

Thus, this behavor-incompatible change happened between 1.5.1 and 1.6.0.

> I tend to think that this is a bug (after all, a1.min() does not return
> ndarray, but an array scalar), but maybe there is also a good reason for
> this (for us, unexpected) behavor change and a nice solution?

Unfortunately, I did not receive any answers so far.

Have a nice day,
  Hans



More information about the NumPy-Discussion mailing list