Commit 2f5c5701 authored by valentin.emiya's avatar valentin.emiya

fix issue #3: display x for partial and full missing values

parent 23482ea5
Pipeline #556 failed with stages
in 45 seconds
......@@ -704,18 +704,26 @@ class MadArray(np.ndarray):
arr[self.unknown_mask] = np.nan
arr_str = np.ndarray.__str__(arr)
arr_str = arr_str.replace('nan', 'x')
if np.isrealobj(arr):
arr_str = arr_str.replace('nan', ' x')
else:
arr_str = arr_str.replace('nan+0.j', ' x ')
if np.issubdtype(self.dtype, np.integer):
arr_str = arr_str.replace('.', '')
if self._complex_masking:
string = 'MadArray, dtype={0},' \
n_all_unknown = np.count_nonzero(self.all_unknown_mask)
string = 'MadArray, dtype={0}, ' \
'{1[0]} missing magnitudes ({2[0]:.1%}) ' \
'and {1[1]} missing phases ({2[1]:.1%})\n{3}'
'and {1[1]} missing phases ({2[1]:.1%}), ' \
' including {3} missing magnitudes and phases jointly ' \
'({4:.1%})\n{5}'
return string.format(self.dtype,
self.n_missing_data,
self.ratio_missing_data,
n_all_unknown,
n_all_unknown/self.size,
arr_str)
else:
string = 'MadArray, dtype={}, {} missing entries ({:.1%})\n{}'
......
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