Commit b9f0a0fa authored by valentin.emiya's avatar valentin.emiya

add test for str method, complex values

parent f1e39868
Pipeline #557 passed with stages
in 53 seconds
......@@ -700,6 +700,47 @@ class TestMadArray:
string = '<MadArray at {}>'
assert repr(ma) == string.format(hex(id(ma)))
# test with missing data, complex values, binary mask
x = np.copy(self.x_complex)
x[self.m] = np.nan
arr_str = np.ndarray.__str__(x)
arr_str = arr_str.replace('nan+0.j', ' x ')
ma = MadArray(self.x_complex, self.m)
n_miss = np.count_nonzero(self.m)
string = 'MadArray, dtype=complex128, {} missing entries (50.0%)\n{}'
assert str(ma) == string.format(n_miss, arr_str)
string = '<MadArray at {}>'
assert repr(ma) == string.format(hex(id(ma)))
# test with missing data, complex values, complex_masking
x = np.copy(self.x_complex)
m_any = np.logical_or(self.mm, self.mp)
x[m_any] = np.nan
arr_str = np.ndarray.__str__(x)
arr_str = arr_str.replace('nan+0.j', ' x ')
ma = MadArray(self.x_complex, complex_masking=True,
mask_magnitude=self.mm, mask_phase=self.mp)
m_all = np.logical_and(self.mm, self.mp)
n_miss = np.count_nonzero(m_all)
n_miss_m = np.count_nonzero(self.mm)
n_miss_p = np.count_nonzero(self.mp)
string = \
'MadArray, dtype=complex128, ' \
'{} missing magnitudes ({:.1%}) ' \
'and {} missing phases ({:.1%}), ' \
'including {} missing magnitudes and phases jointly ({:.1%})' \
'\n{}'
assert str(ma) == string.format(n_miss_m, n_miss_m / x.size,
n_miss_p, n_miss_p / x.size,
n_miss, n_miss / x.size,
arr_str)
string = '<MadArray at {}>'
assert repr(ma) == string.format(hex(id(ma)))
def test_merge_masks(self):
ma1 = MadArray(self.x_float, self.m)
ma2 = MadArray(self.x_float, self.m2)
......
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