Created
July 21, 2014 22:58
-
-
Save guziy/fdbe65efa40728f3b7a8 to your computer and use it in GitHub Desktop.
biggus mean of a stack of masked arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import biggus | |
import numpy as np | |
def main(): | |
x = np.random.randn(10, 10) | |
y = np.ma.masked_where(x > 0, x) | |
yinv = np.ma.masked_where(~y.mask, x) | |
arrst = biggus.ArrayStack(np.array([biggus.NumpyArrayAdapter(el) for el in [y, yinv]])) | |
the_mean = biggus.mean(arrst, axis = 0).masked_array() | |
print np.all(~(y.mask & yinv.mask)) | |
assert np.all(the_mean.mask) == True, "I was expecting the_mean to be completely masked..." | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment