My question about Python is really trivial: What do I have to modify that the function max() returns a real value for any compiler?
import numpy as np
a = np.array([-1, 0, 1, np.nan])
# The maximal value is 1. It is not nan!
a.max()
There is the possibility to use the following code but it looks ugly to me:
a[np.logical_not(np.isnan(a))].max()
As was answered by @Divakar using np.nanmax(a) will solve your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With