[Numpy-discussion] numpy.trapz() doesn't respect subclass
rmay31 at gmail.com
Mon Mar 29 11:47:52 EDT 2010
I decided that having actual code that does what I want and keeps
backwards compatibility (and adds tests) might be better than arguing
semantics. I've updated my patch to:
* Uses the array.sum() method instead of add.reduce to make subclasses
fully work (this was still breaking masked arrays.
* Catches an exception on doing the actual multiply and sum of the
arrays and tries again after casting to ndarrays. This allows any
subclasses that relied on being cast to still work.
* Adds tests that ensure matrices work (test passes before and after
changes to trapz()) and adds a test for masked arrays that checks that
masked points are treated as expected. In this case, expected is
defined to be the same as if you implemented the trapezoidal method by
hand using MaskedArray's basic arithmetic operations.
Attached here and at: http://projects.scipy.org/numpy/ticket/1438
I think this addresses the concerns that were raised about the changes
for subclasses in this case. Let me know if I've missed something (or
if there's no way in hell any such patch will ever be committed).
Graduate Research Assistant
School of Meteorology
University of Oklahoma
More information about the NumPy-Discussion