[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
Fri Jul 29 06:12:19 EDT 2011


Am Freitag, 29. Juli 2011, 11:31:24 schrieb Hans Meine:
> Am Donnerstag, 28. Juli 2011, 17:42:38 schrieb Matthew Brett:
> > Was there a particular case you ran into where this was a problem?
> [...]
> Basically, the problem arose because our ndarray subclass does not support
> zero-rank-instances fully.  (And previously, there was no need for that.)

I just reproduced the problem, it was this exception:

/home/hmeine/new_numpy/lib64/python2.6/site-packages/vigra/arraytypes.pyc in 
reshape(self, shape, order)
    587 
    588     def reshape(self, shape, order='C'):
--> 589         res = numpy.ndarray.reshape(self, shape, order)
    590         res.axistags = AxisTags(res.ndim)
    591         return res

TypeError: an integer is required

The problem is that 'self' has become a zero-rank array, and those cannot be 
reshaped in order to add singleton dimensions anymore.  IOW, if you implement 
sth. like broadcasting, this is made much harder.

Best,
  Hans



More information about the NumPy-Discussion mailing list