[Numpy-discussion] Utility function to find array items are in ascending order
Tue Feb 9 09:53:10 CST 2010
On Tue, Feb 9, 2010 at 7:51 AM, Brent Pedersen <firstname.lastname@example.org> wrote:
> On Tue, Feb 9, 2010 at 7:42 AM, Vishal Rana <email@example.com> wrote:
>> Is there any utility function to find if values in the array are in
>> ascending or descending order.
>> arr = [1, 2, 4, 6] should return true
>> arr2 = [1, 0, 2, -2] should return false
>> NumPy-Discussion mailing list
> i dont know if there's a utility function, but i'd use:
> >>> np.all(a[1:] >= a[:-1])
Yes, that's much better than np.diff.
More information about the NumPy-Discussion