larray.maximum¶

larray.
maximum
(x1, x2, out=None, dtype=None)¶ Elementwise maximum of array elements.
Compare two arrays and returns a new array containing the elementwise maxima. If one of the elements being compared is a NaN, then that element is returned. If both elements are NaNs then the first is returned. The latter distinction is important for complex NaNs, which are defined as at least one of the real or imaginary parts being a NaN. The net effect is that NaNs are propagated.
 Parameters
 x1, x2LArray
The arrays holding the elements to be compared.
 outLArray, optional
An array into which the result is stored.
 dtypedatatype, optional
Overrides the dtype of the output array.
 Returns
 yLArray or scalar
The maximum of x1 and x2, elementwise. This is a scalar if both x1 and x2 are scalars.
See also
minimum
Elementwise minimum of two arrays, propagates NaNs.
Notes
The maximum is equivalent to
where(x1 >= x2, x1, x2)
when neither x1 nor x2 are NaNs, but it is faster.Examples
>>> from larray import LArray >>> arr1 = LArray([[10, 7, 5, 9], ... [5, 8, 3, 7]], "a=a0,a1;b=b0..b3") >>> arr2 = LArray([[6, 2, 9, 0], ... [9, 10, 5, 6]], "a=a0,a1;b=b0..b3") >>> arr1 a\b b0 b1 b2 b3 a0 10 7 5 9 a1 5 8 3 7 >>> arr2 a\b b0 b1 b2 b3 a0 6 2 9 0 a1 9 10 5 6
>>> maximum(arr1, arr2) a\b b0 b1 b2 b3 a0 10 7 9 9 a1 9 10 5 7
With broadcasting
>>> arr2['a0'] b b0 b1 b2 b3 6 2 9 0 >>> maximum(arr1, arr2['a0']) a\b b0 b1 b2 b3 a0 10 7 9 9 a1 6 8 9 7