@@ -386,16 +386,24 @@ def test_get_finder(self):
386
386
387
387
@pytest .mark .slow
388
388
def test_finder_daily (self ):
389
- xp = Period ('1999-1-1' , freq = 'B' ).ordinal
390
389
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 ]
392
399
rng = bdate_range ('1999-1-1' , periods = n )
393
400
ser = Series (np .random .randn (len (rng )), rng )
394
401
_ , ax = self .plt .subplots ()
395
402
ser .plot (ax = ax )
396
403
xaxis = ax .get_xaxis ()
397
404
rs = xaxis .get_majorticklocs ()[0 ]
398
405
assert xp == rs
406
+ xp = xpl2 [i ]
399
407
vmin , vmax = ax .get_xlim ()
400
408
ax .set_xlim (vmin + 0.9 , vmax )
401
409
rs = xaxis .get_majorticklocs ()[0 ]
@@ -404,16 +412,24 @@ def test_finder_daily(self):
404
412
405
413
@pytest .mark .slow
406
414
def test_finder_quarterly (self ):
407
- xp = Period ('1988Q1' ).ordinal
408
415
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 ]
410
425
rng = period_range ('1987Q2' , periods = int (n * 4 ), freq = 'Q' )
411
426
ser = Series (np .random .randn (len (rng )), rng )
412
427
_ , ax = self .plt .subplots ()
413
428
ser .plot (ax = ax )
414
429
xaxis = ax .get_xaxis ()
415
430
rs = xaxis .get_majorticklocs ()[0 ]
416
431
assert rs == xp
432
+ xp = xpl2 [i ]
417
433
(vmin , vmax ) = ax .get_xlim ()
418
434
ax .set_xlim (vmin + 0.9 , vmax )
419
435
rs = xaxis .get_majorticklocs ()[0 ]
@@ -422,16 +438,24 @@ def test_finder_quarterly(self):
422
438
423
439
@pytest .mark .slow
424
440
def test_finder_monthly (self ):
425
- xp = Period ('Jan 1988' ).ordinal
426
441
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 ]
428
451
rng = period_range ('1987Q2' , periods = int (n * 12 ), freq = 'M' )
429
452
ser = Series (np .random .randn (len (rng )), rng )
430
453
_ , ax = self .plt .subplots ()
431
454
ser .plot (ax = ax )
432
455
xaxis = ax .get_xaxis ()
433
456
rs = xaxis .get_majorticklocs ()[0 ]
434
457
assert rs == xp
458
+ xp = xpl2 [i ]
435
459
vmin , vmax = ax .get_xlim ()
436
460
ax .set_xlim (vmin + 0.9 , vmax )
437
461
rs = xaxis .get_majorticklocs ()[0 ]
@@ -450,7 +474,11 @@ def test_finder_monthly_long(self):
450
474
451
475
@pytest .mark .slow
452
476
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
+
454
482
for i , nyears in enumerate ([5 , 10 , 19 , 49 , 99 , 199 , 599 , 1001 ]):
455
483
rng = period_range ('1987' , periods = nyears , freq = 'A' )
456
484
ser = Series (np .random .randn (len (rng )), rng )
@@ -470,7 +498,10 @@ def test_finder_minutely(self):
470
498
ser .plot (ax = ax )
471
499
xaxis = ax .get_xaxis ()
472
500
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
474
505
assert rs == xp
475
506
476
507
def test_finder_hourly (self ):
@@ -481,7 +512,10 @@ def test_finder_hourly(self):
481
512
ser .plot (ax = ax )
482
513
xaxis = ax .get_xaxis ()
483
514
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
485
519
assert rs == xp
486
520
487
521
@pytest .mark .slow
@@ -1292,9 +1326,14 @@ def test_format_timedelta_ticks_narrow(self):
1292
1326
if is_platform_mac ():
1293
1327
pytest .skip ("skip on mac for precision display issue on older mpl" )
1294
1328
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 )]
1298
1337
1299
1338
rng = timedelta_range ('0' , periods = 10 , freq = 'ns' )
1300
1339
df = DataFrame (np .random .randn (len (rng ), 3 ), rng )
@@ -1310,17 +1349,32 @@ def test_format_timedelta_ticks_wide(self):
1310
1349
if is_platform_mac ():
1311
1350
pytest .skip ("skip on mac for precision display issue on older mpl" )
1312
1351
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
+ ]
1324
1378
1325
1379
rng = timedelta_range ('0' , periods = 10 , freq = '1 d' )
1326
1380
df = DataFrame (np .random .randn (len (rng ), 3 ), rng )
0 commit comments