BUG: unwrap_phase on compressed masked array

unwrap_phase works on masked arrays with a compressed mask (no elements masked)

Closes #1346
This commit is contained in:
Jonathan Helmus
2015-01-21 16:01:13 -06:00
parent 9b16b35d96
commit 8ebe073ad5
2 changed files with 11 additions and 2 deletions
+9
View File
@@ -156,5 +156,14 @@ def test_unwrap_3d_middle_wrap_around():
unwrap = unwrap_phase(image, wrap_around=[False, True, False])
assert np.all(unwrap == 0)
def test_unwrap_2d_compressed_mask():
# ValueError when image is masked array with a compressed mask (no masked
# elments). GitHub issue #1346
image = np.ma.zeros((10, 10))
unwrap = unwrap_phase(image)
assert np.all(unwrap == 0)
if __name__ == "__main__":
run_module_suite()
+2 -2
View File
@@ -88,8 +88,8 @@ def unwrap_phase(image, wrap_around=False, seed=None):
'algorithm')
if np.ma.isMaskedArray(image):
mask = np.require(image.mask, np.uint8, ['C'])
image = image.data
mask = np.require(np.ma.getmaskarray(image), np.uint8, ['C'])
image = np.ma.getdata(image)
else:
mask = np.zeros_like(image, dtype=np.uint8, order='C')