@@ -510,6 +510,14 @@ class TestScalarFormatter:
510
510
(True , (6 , 6 ), (- 1e5 , 1e5 ), 6 , False ),
511
511
]
512
512
513
+ cursor_data = [
514
+ [0. , "0.000" ],
515
+ [0.0123 , "0.012" ],
516
+ [0.123 , "0.123" ],
517
+ [1.23 , "1.230" ],
518
+ [12.3 , "12.300" ],
519
+ ]
520
+
513
521
@pytest .mark .parametrize ('unicode_minus, result' ,
514
522
[(True , "\N{MINUS SIGN} 1" ), (False , "-1" )])
515
523
def test_unicode_minus (self , unicode_minus , result ):
@@ -556,15 +564,21 @@ def test_scilimits(self, sci_type, scilimits, lim, orderOfMag, fewticks):
556
564
tmp_form .set_locs (ax .yaxis .get_majorticklocs ())
557
565
assert orderOfMag == tmp_form .orderOfMagnitude
558
566
559
- def test_cursor_precision (self ):
567
+ @pytest .mark .parametrize ('data, expected' , cursor_data )
568
+ def test_cursor_precision (self , data , expected ):
560
569
fig , ax = plt .subplots ()
561
570
ax .set_xlim (- 1 , 1 ) # Pointing precision of 0.001.
562
571
fmt = ax .xaxis .get_major_formatter ().format_data_short
563
- assert fmt (0. ) == "0.000"
564
- assert fmt (0.0123 ) == "0.012"
565
- assert fmt (0.123 ) == "0.123"
566
- assert fmt (1.23 ) == "1.230"
567
- assert fmt (12.3 ) == "12.300"
572
+ assert fmt (data ) == expected
573
+
574
+ @pytest .mark .parametrize ('data, expected' , cursor_data )
575
+ def test_cursor_dummy_axis (self , data , expected ):
576
+ # Issue #17624
577
+ sf = mticker .ScalarFormatter ()
578
+ sf .create_dummy_axis ()
579
+ sf .set_bounds (0 , 10 )
580
+ fmt = sf .format_data_short
581
+ assert fmt (data ) == expected
568
582
569
583
570
584
class FakeAxis :
0 commit comments