@@ -386,16 +386,24 @@ def test_get_finder(self):
386386
387387 @slow
388388 def test_finder_daily (self ):
389- xp = Period ('1999-1-1' , freq = 'B' ).ordinal
390389 day_lst = [10 , 40 , 252 , 400 , 950 , 2750 , 10000 ]
391- for n in day_lst :
390+
391+ if self .mpl_ge_2_0_0 :
392+ xpl1 = [7565 , 7564 , 7553 , 7546 , 7518 , 7428 , 7066 ]
393+ xpl2 = [7566 , 7564 , 7554 , 7546 , 7519 , 7429 , 7066 ]
394+ else :
395+ xpl1 = xpl2 = [Period ('1999-1-1' , freq = 'B' ).ordinal ] * len (day_lst )
396+
397+ for i , n in enumerate (day_lst ):
398+ xp = xpl1 [i ]
392399 rng = bdate_range ('1999-1-1' , periods = n )
393400 ser = Series (np .random .randn (len (rng )), rng )
394401 _ , ax = self .plt .subplots ()
395402 ser .plot (ax = ax )
396403 xaxis = ax .get_xaxis ()
397404 rs = xaxis .get_majorticklocs ()[0 ]
398405 assert xp == rs
406+ xp = xpl2 [i ]
399407 vmin , vmax = ax .get_xlim ()
400408 ax .set_xlim (vmin + 0.9 , vmax )
401409 rs = xaxis .get_majorticklocs ()[0 ]
@@ -404,16 +412,24 @@ def test_finder_daily(self):
404412
405413 @slow
406414 def test_finder_quarterly (self ):
407- xp = Period ('1988Q1' ).ordinal
408415 yrs = [3.5 , 11 ]
409- for n in yrs :
416+
417+ if self .mpl_ge_2_0_0 :
418+ xpl1 = [68 , 68 ]
419+ xpl2 = [72 , 68 ]
420+ else :
421+ xpl1 = xpl2 = [Period ('1988Q1' ).ordinal ] * len (yrs )
422+
423+ for i , n in enumerate (yrs ):
424+ xp = xpl1 [i ]
410425 rng = period_range ('1987Q2' , periods = int (n * 4 ), freq = 'Q' )
411426 ser = Series (np .random .randn (len (rng )), rng )
412427 _ , ax = self .plt .subplots ()
413428 ser .plot (ax = ax )
414429 xaxis = ax .get_xaxis ()
415430 rs = xaxis .get_majorticklocs ()[0 ]
416431 assert rs == xp
432+ xp = xpl2 [i ]
417433 (vmin , vmax ) = ax .get_xlim ()
418434 ax .set_xlim (vmin + 0.9 , vmax )
419435 rs = xaxis .get_majorticklocs ()[0 ]
@@ -422,16 +438,24 @@ def test_finder_quarterly(self):
422438
423439 @slow
424440 def test_finder_monthly (self ):
425- xp = Period ('Jan 1988' ).ordinal
426441 yrs = [1.15 , 2.5 , 4 , 11 ]
427- for n in yrs :
442+
443+ if self .mpl_ge_2_0_0 :
444+ xpl1 = [216 , 216 , 204 , 204 ]
445+ xpl2 = [216 , 216 , 216 , 204 ]
446+ else :
447+ xpl1 = xpl2 = [Period ('Jan 1988' ).ordinal ] * len (yrs )
448+
449+ for i , n in enumerate (yrs ):
450+ xp = xpl1 [i ]
428451 rng = period_range ('1987Q2' , periods = int (n * 12 ), freq = 'M' )
429452 ser = Series (np .random .randn (len (rng )), rng )
430453 _ , ax = self .plt .subplots ()
431454 ser .plot (ax = ax )
432455 xaxis = ax .get_xaxis ()
433456 rs = xaxis .get_majorticklocs ()[0 ]
434457 assert rs == xp
458+ xp = xpl2 [i ]
435459 vmin , vmax = ax .get_xlim ()
436460 ax .set_xlim (vmin + 0.9 , vmax )
437461 rs = xaxis .get_majorticklocs ()[0 ]
@@ -450,7 +474,11 @@ def test_finder_monthly_long(self):
450474
451475 @slow
452476 def test_finder_annual (self ):
453- xp = [1987 , 1988 , 1990 , 1990 , 1995 , 2020 , 2070 , 2170 ]
477+ if self .mpl_ge_2_0_0 :
478+ xp = [1986 , 1986 , 1990 , 1990 , 1995 , 2020 , 1970 , 1970 ]
479+ else :
480+ xp = [1987 , 1988 , 1990 , 1990 , 1995 , 2020 , 2070 , 2170 ]
481+
454482 for i , nyears in enumerate ([5 , 10 , 19 , 49 , 99 , 199 , 599 , 1001 ]):
455483 rng = period_range ('1987' , periods = nyears , freq = 'A' )
456484 ser = Series (np .random .randn (len (rng )), rng )
@@ -470,7 +498,10 @@ def test_finder_minutely(self):
470498 ser .plot (ax = ax )
471499 xaxis = ax .get_xaxis ()
472500 rs = xaxis .get_majorticklocs ()[0 ]
473- xp = Period ('1/1/1999' , freq = 'Min' ).ordinal
501+ if self .mpl_ge_2_0_0 :
502+ xp = Period ('1998-12-29 12:00' , freq = 'Min' ).ordinal
503+ else :
504+ xp = Period ('1/1/1999' , freq = 'Min' ).ordinal
474505 assert rs == xp
475506
476507 def test_finder_hourly (self ):
@@ -481,7 +512,10 @@ def test_finder_hourly(self):
481512 ser .plot (ax = ax )
482513 xaxis = ax .get_xaxis ()
483514 rs = xaxis .get_majorticklocs ()[0 ]
484- xp = Period ('1/1/1999' , freq = 'H' ).ordinal
515+ if self .mpl_ge_2_0_0 :
516+ xp = Period ('1998-12-31 22:00' , freq = 'H' ).ordinal
517+ else :
518+ xp = Period ('1/1/1999' , freq = 'H' ).ordinal
485519 assert rs == xp
486520
487521 @slow
@@ -1292,9 +1326,14 @@ def test_format_timedelta_ticks_narrow(self):
12921326 if is_platform_mac ():
12931327 pytest .skip ("skip on mac for precision display issue on older mpl" )
12941328
1295- expected_labels = [
1296- '00:00:00.00000000{:d}' .format (i )
1297- for i in range (10 )]
1329+ if self .mpl_ge_2_0_0 :
1330+ expected_labels = ['' ] + [
1331+ '00:00:00.00000000{:d}' .format (2 * i )
1332+ for i in range (5 )] + ['' ]
1333+ else :
1334+ expected_labels = [
1335+ '00:00:00.00000000{:d}' .format (i )
1336+ for i in range (10 )]
12981337
12991338 rng = timedelta_range ('0' , periods = 10 , freq = 'ns' )
13001339 df = DataFrame (np .random .randn (len (rng ), 3 ), rng )
@@ -1310,17 +1349,32 @@ def test_format_timedelta_ticks_wide(self):
13101349 if is_platform_mac ():
13111350 pytest .skip ("skip on mac for precision display issue on older mpl" )
13121351
1313- expected_labels = [
1314- '00:00:00' ,
1315- '1 days 03:46:40' ,
1316- '2 days 07:33:20' ,
1317- '3 days 11:20:00' ,
1318- '4 days 15:06:40' ,
1319- '5 days 18:53:20' ,
1320- '6 days 22:40:00' ,
1321- '8 days 02:26:40' ,
1322- ''
1323- ]
1352+ if self .mpl_ge_2_0_0 :
1353+ expected_labels = [
1354+ '' ,
1355+ '00:00:00' ,
1356+ '1 days 03:46:40' ,
1357+ '2 days 07:33:20' ,
1358+ '3 days 11:20:00' ,
1359+ '4 days 15:06:40' ,
1360+ '5 days 18:53:20' ,
1361+ '6 days 22:40:00' ,
1362+ '8 days 02:26:40' ,
1363+ '9 days 06:13:20' ,
1364+ ''
1365+ ]
1366+ else :
1367+ expected_labels = [
1368+ '00:00:00' ,
1369+ '1 days 03:46:40' ,
1370+ '2 days 07:33:20' ,
1371+ '3 days 11:20:00' ,
1372+ '4 days 15:06:40' ,
1373+ '5 days 18:53:20' ,
1374+ '6 days 22:40:00' ,
1375+ '8 days 02:26:40' ,
1376+ ''
1377+ ]
13241378
13251379 rng = timedelta_range ('0' , periods = 10 , freq = '1 d' )
13261380 df = DataFrame (np .random .randn (len (rng ), 3 ), rng )
0 commit comments