I want to compute the median of an array of masked array. No problem to compute the mean but an error rising when I want to compute the median and I don't know why:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Here is a minimal example which reproduce the problem:
import numpy as np
import numpy.mask as ma
test = ma.masked_array([[1,2,3,4],[5,6,7,8]], mask = [[False,False,False,False],[False,False,False,False]])
test_tot= np.zeros(4,dtype='object')
test_tot[0]=test
test_tot[1]=test
test_tot[2]=test
test_tot[3]=test
np.mean(test_tot) # OK
np.median(test_tot) # PROBLEM ?
Thank you in advance for your advices