Commit 8d8c7866 authored by Florent Jaillet's avatar Florent Jaillet

Change behavior of MadArray constructor when passing a MadArray and a mask

parent 8e57c9b7
Pipeline #608 passed with stage
in 25 seconds
......@@ -248,11 +248,9 @@ class MadArray(np.ndarray):
_data = _data.astype(np.complex)
if mask_magnitude is None:
if isinstance(data, MadArray):
if data._complex_masking:
mask_magnitude = data.unknown_magnitude_mask
else:
mask_magnitude = data.unknown_mask
if isinstance(data, MadArray) and mask_phase is None:
mask_magnitude = data.unknown_magnitude_mask
mask_phase = data.unknown_phase_mask
else:
mask_magnitude = np.zeros_like(data, dtype=np.bool)
else:
......@@ -264,13 +262,7 @@ class MadArray(np.ndarray):
_data.shape))
if mask_phase is None:
if isinstance(data, MadArray):
if data._complex_masking:
mask_phase = data.unknown_phase_mask
else:
mask_phase = data.unknown_mask
else:
mask_phase = np.zeros_like(data, dtype=np.bool)
mask_phase = np.zeros_like(data, dtype=np.bool)
else:
mask_phase = np.array(mask_phase, dtype=np.bool)
......
......@@ -313,8 +313,7 @@ class TestMadArray:
assert ma._complex_masking
old_ma = MadArray(x, mask_phase=self.mp, mask_magnitude=self.mm)
ma = MadArray(old_ma, mask_phase=self.mm,
mask_magnitude=self.mp)
ma = MadArray(old_ma, mask_phase=self.mm, mask_magnitude=self.mp)
np.testing.assert_equal(ma.unknown_phase_mask, self.mm)
np.testing.assert_equal(ma.unknown_magnitude_mask, self.mp)
......@@ -325,14 +324,16 @@ class TestMadArray:
ma = MadArray(old_ma, mask_phase=self.mm)
np.testing.assert_equal(ma.unknown_phase_mask, self.mm)
np.testing.assert_equal(ma.unknown_magnitude_mask, self.mm)
np.testing.assert_equal(ma.unknown_magnitude_mask,
np.zeros_like(x, dtype=np.bool))
assert id(old_ma) != id(ma)
assert id(old_ma._mask) != id(ma._mask)
old_ma = MadArray(x, mask_phase=self.mp, mask_magnitude=self.mm)
ma = MadArray(old_ma, mask_magnitude=self.mp)
np.testing.assert_equal(ma.unknown_phase_mask, self.mp)
np.testing.assert_equal(ma.unknown_phase_mask,
np.zeros_like(x, dtype=np.bool))
np.testing.assert_equal(ma.unknown_magnitude_mask, self.mp)
assert id(old_ma) != id(ma)
assert id(old_ma._mask) != id(ma._mask)
......@@ -350,7 +351,8 @@ class TestMadArray:
ma = MadArray(old_ma, mask_phase=self.mp)
np.testing.assert_equal(ma.unknown_phase_mask, self.mp)
np.testing.assert_equal(ma.unknown_magnitude_mask, self.m)
np.testing.assert_equal(ma.unknown_magnitude_mask,
np.zeros_like(x, dtype=np.bool))
assert id(old_ma) != id(ma)
assert id(old_ma._mask) != id(ma._mask)
assert ma._complex_masking
......@@ -358,7 +360,8 @@ class TestMadArray:
old_ma = MadArray(x, self.m)
ma = MadArray(old_ma, mask_magnitude=self.mm)
np.testing.assert_equal(ma.unknown_phase_mask, self.m)
np.testing.assert_equal(ma.unknown_phase_mask,
np.zeros_like(x, dtype=np.bool))
np.testing.assert_equal(ma.unknown_magnitude_mask, self.mm)
assert id(old_ma) != id(ma)
assert id(old_ma._mask) != id(ma._mask)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment