Skip to content

Instantly share code, notes, and snippets.

@cpelley
Created October 27, 2015 20:53
Show Gist options
  • Save cpelley/ed5e523f3e17ff5bf102 to your computer and use it in GitHub Desktop.
Save cpelley/ed5e523f3e17ff5bf102 to your computer and use it in GitHub Desktop.
numpy masked array bug
>>> import numpy as np
>>> arr = np.ma.array([1, 2, 3, 4], mask=[False, True, False, True])
>>> arr2 = arr.reshape((2, 2))
>>> arr2
masked_array(data =
[[1 --]
[3 --]],
mask =
[[False True]
[False True]],
fill_value = 999999)
>>> arr2[:] = 10
>>> arr
masked_array(data = [10 -- 10 --],
mask = [False True False True],
fill_value = 999999)
>>> arr2
masked_array(data =
[[10 10]
[10 10]],
mask =
[[False False]
[False False]],
fill_value = 999999)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment