File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -989,3 +989,18 @@ def test_deprecation():
989
989
with pytest .warns (MatplotlibDeprecationWarning ):
990
990
# Enough arguments to pass "shape" positionally.
991
991
obj .imshow (data , * [None ] * 10 )
992
+
993
+
994
+ def test_image_cursor_formatting ():
995
+ fig , ax = plt .subplots ()
996
+ # Create a dummy image to be able to call format_cursor_data
997
+ im = ax .imshow (np .zeros ((4 , 4 )))
998
+
999
+ data = np .ma .masked_array ([0 ], mask = [True ])
1000
+ assert im .format_cursor_data (data ) == '[]'
1001
+
1002
+ data = np .ma .masked_array ([0 ], mask = [False ])
1003
+ assert im .format_cursor_data (data ) == '[0]'
1004
+
1005
+ data = np .nan
1006
+ assert im .format_cursor_data (data ) == '[nan]'
Original file line number Diff line number Diff line change @@ -629,6 +629,8 @@ def format_data_short(self, value):
629
629
"""
630
630
if self ._useLocale :
631
631
return locale .format_string ('%-12g' , (value ,))
632
+ elif isinstance (value , np .ma .MaskedArray ) and value .mask :
633
+ return ''
632
634
else :
633
635
return '%-12g' % value
634
636
You can’t perform that action at this time.
0 commit comments