File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -989,3 +989,18 @@ def test_deprecation():
989989 with pytest .warns (MatplotlibDeprecationWarning ):
990990 # Enough arguments to pass "shape" positionally.
991991 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):
629629 """
630630 if self ._useLocale :
631631 return locale .format_string ('%-12g' , (value ,))
632+ elif isinstance (value , np .ma .MaskedArray ) and value .mask :
633+ return ''
632634 else :
633635 return '%-12g' % value
634636
You can’t perform that action at this time.
0 commit comments