[Numpy-discussion] use of concatenate with subclass of ndarray

Pierre GM pgmdevlist@gmail....
Thu Mar 29 13:37:40 CDT 2007

On Thursday 29 March 2007 14:09:38 Bryce Hendrix wrote:
> I really should widen my tests before proclaiming success... If you
> change the default units to "feet", the result of concatenating two
> UnitArrays instances with "meters" units is a UnitArray with "feet".

Not a surprise at all, and I should have thought about it:

concatenate creates a plain ndarray first and ends up calling 
Unit_array.__array_finalize__. As the caller has no unit yet 
(it's a plain ndarray), the result gets the Unit_array.default_unit. 

That's why you should really write a custom concatenate function that checks 
the units of its inputs, and sets the unit of the output accordingly.

More information about the Numpy-discussion mailing list