Scipy maximum_filter is crazy

2019-05-18 00:27发布

问题:

I have a little problem with the maximum_filter function from scipy and don't get the solution.

I have three different numpy arrays.

a =  np.array([[-152, nan, -30, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan]])


b =  np.array([[ nan, nan, -30, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan]])


c =  np.array([[-152, nan, nan, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan],
               [ nan, nan, nan, nan]])

If I now want to calculate the maximum for a,b and c with

 maximum = (a == maximum_filter(a,3))

For a and c I get a maximum, but when I try it with b I get no maximum.Why?

Is there a problem with the nans?