[Numpy-discussion] .max() and zero length arrays
Nick Fotopoulos
nvf at uwm.edu
Mon May 14 13:38:58 EDT 2007
Dear all,
I find myself frequently wanting to take the max of an array that
might have zero length. If it is zero length, it throws an exception,
when I would like to gracefully substitute my own value. For example,
one solution with lists is to do max(possibly_empty_list +
[minimum_value]), but it seems clunky to do a similar trick with
arrays and concatenate or to use a try: except: block. What do other
people do? If there's no good idiom, would it be possible to add
kwargs like default_value and/or minimum_value?
Thanks,
Nick
More information about the NumPy-Discussion
mailing list