-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: Fixed a bug with string representation of masked structured arrays #6094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,6 +685,42 @@ def test_mvoid_print(self): | |
finally: | ||
masked_print_option.set_display(ini_display) | ||
|
||
def test_mvoid_multidim_print(self): | ||
|
||
# regression test for gh-6019 | ||
t_ma = masked_array(data = [([1, 2, 3],)], | ||
mask = [([False, True, False],)], | ||
fill_value = ([999999, 999999, 999999],), | ||
dtype = [('a', '<i8', (3,))]) | ||
assert str(t_ma[0]) == "([1, --, 3],)" | ||
assert repr(t_ma[0]) == "([1, --, 3],)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this PR does fix the str and repr of this array, the array still doesn't seem very useable.
But that can be left for another time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh never mind, this is OK. Structured types do not support many ufuncs. |
||
|
||
# additonal tests with structured arrays | ||
|
||
t_2d = masked_array(data = [([[1, 2], [3,4]],)], | ||
mask = [([[False, True], [True, False]],)], | ||
dtype = [('a', '<i8', (2,2))]) | ||
assert str(t_2d[0]) == "([[1, --], [--, 4]],)" | ||
assert repr(t_2d[0]) == "([[1, --], [--, 4]],)" | ||
|
||
t_0d = masked_array(data = [(1,2)], | ||
mask = [(True,False)], | ||
dtype = [('a', '<i8'), ('b', '<i8')]) | ||
assert str(t_0d[0]) == "(--, 2)" | ||
assert repr(t_0d[0]) == "(--, 2)" | ||
|
||
t_2d = masked_array(data = [([[1, 2], [3,4]], 1)], | ||
mask = [([[False, True], [True, False]], False)], | ||
dtype = [('a', '<i8', (2,2)), ('b', float)]) | ||
assert str(t_2d[0]) == "([[1, --], [--, 4]], 1.0)" | ||
assert repr(t_2d[0]) == "([[1, --], [--, 4]], 1.0)" | ||
|
||
t_ne = masked_array(data=[(1, (1, 1))], | ||
mask=[(True, (True, False))], | ||
dtype = [('a', '<i8'), ('b', 'i4,i4')]) | ||
assert str(t_ne[0]) == "(--, (--, 1))" | ||
assert repr(t_ne[0]) == "(--, (--, 1))" | ||
|
||
def test_object_with_array(self): | ||
mx1 = masked_array([1.], mask=[True]) | ||
mx2 = masked_array([1., 2.]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, doesn't this lose something? What is thinking here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charris - well, the output was basically the same before between the two. This is backward-compatible for the cases that did work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@charris - would you prefer to see this behave differently? If so, do you have suggestions for expected behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems OK to me, since it looks like what normal void-scalars do too (repr is the same as str).