5
5
6
6
import pytest
7
7
from pandas .compat import lrange , zip
8
- try :
9
- import matplotlib
10
- except :
11
- pass
12
8
13
9
import numpy as np
14
10
from pandas import Index , Series , DataFrame , NaT , isna
@@ -429,9 +425,6 @@ def test_finder_daily(self):
429
425
rs2 .append (xaxis .get_majorticklocs ()[0 ])
430
426
self .plt .close (ax .get_figure ())
431
427
432
- if rs1 != xpl1 or rs2 != xpl2 :
433
- print (matplotlib .__version__ , np .__version__ ,
434
- rs1 , xpl1 , rs2 , xpl2 )
435
428
assert rs1 == xpl1
436
429
assert rs2 == xpl2
437
430
@@ -461,9 +454,6 @@ def test_finder_quarterly(self):
461
454
rs2 .append (xaxis .get_majorticklocs ()[0 ])
462
455
self .plt .close (ax .get_figure ())
463
456
464
- if rs1 != xpl1 or rs2 != xpl2 :
465
- print (matplotlib .__version__ , np .__version__ ,
466
- rs1 , xpl1 , rs2 , xpl2 )
467
457
assert rs1 == xpl1
468
458
assert rs2 == xpl2
469
459
@@ -493,9 +483,6 @@ def test_finder_monthly(self):
493
483
rs2 .append (xaxis .get_majorticklocs ()[0 ])
494
484
self .plt .close (ax .get_figure ())
495
485
496
- if rs1 != xpl1 or rs2 != xpl2 :
497
- print (matplotlib .__version__ , np .__version__ ,
498
- rs1 , xpl1 , rs2 , xpl2 )
499
486
assert rs1 == xpl1
500
487
assert rs2 == xpl2
501
488
@@ -528,8 +515,6 @@ def test_finder_annual(self):
528
515
rs .append (xaxis .get_majorticklocs ()[0 ])
529
516
self .plt .close (ax .get_figure ())
530
517
531
- if rs != xp :
532
- print (matplotlib .__version__ , np .__version__ , rs , xp )
533
518
assert rs == xp
534
519
535
520
@pytest .mark .slow
@@ -542,8 +527,7 @@ def test_finder_minutely(self):
542
527
xaxis = ax .get_xaxis ()
543
528
rs = xaxis .get_majorticklocs ()[0 ]
544
529
xp = Period ('1/1/1999' , freq = 'Min' ).ordinal
545
- if rs != xp :
546
- print (matplotlib .__version__ , np .__version__ , rs , xp )
530
+
547
531
assert rs == xp
548
532
549
533
def test_finder_hourly (self ):
@@ -556,10 +540,9 @@ def test_finder_hourly(self):
556
540
rs = xaxis .get_majorticklocs ()[0 ]
557
541
if self .mpl_ge_2_0_1 :
558
542
xp = Period ('1/1/1999' , freq = 'H' ).ordinal
559
- else :
543
+ else : # 2.0.0
560
544
xp = Period ('1998-12-31 22:00' , freq = 'H' ).ordinal
561
- if rs != xp :
562
- print (matplotlib .__version__ , np .__version__ , rs , xp )
545
+
563
546
assert rs == xp
564
547
565
548
@pytest .mark .slow
@@ -575,8 +558,7 @@ def test_gaps(self):
575
558
if self .mpl_ge_3_0_0 or not self .mpl_ge_2_0_1 :
576
559
# 2.0.0 or >= 3.0.0
577
560
data = np .ma .MaskedArray (data , mask = isna (data ), fill_value = np .nan )
578
- if not isinstance (data , np .ma .core .MaskedArray ):
579
- print (matplotlib .__version__ , np .__version__ , type (data ))
561
+
580
562
assert isinstance (data , np .ma .core .MaskedArray )
581
563
mask = data .mask
582
564
assert mask [5 :25 , 1 ].all ()
@@ -595,8 +577,7 @@ def test_gaps(self):
595
577
if self .mpl_ge_3_0_0 or not self .mpl_ge_2_0_1 :
596
578
# 2.0.0 or >= 3.0.0
597
579
data = np .ma .MaskedArray (data , mask = isna (data ), fill_value = np .nan )
598
- if not isinstance (data , np .ma .core .MaskedArray ):
599
- print (matplotlib .__version__ , np .__version__ , type (data ))
580
+
600
581
assert isinstance (data , np .ma .core .MaskedArray )
601
582
mask = data .mask
602
583
assert mask [2 :5 , 1 ].all ()
@@ -615,9 +596,7 @@ def test_gaps(self):
615
596
if self .mpl_ge_3_0_0 or not self .mpl_ge_2_0_1 :
616
597
# 2.0.0 or >= 3.0.0
617
598
data = np .ma .MaskedArray (data , mask = isna (data ), fill_value = np .nan )
618
- if not isinstance (data , np .ma .core .MaskedArray ):
619
- print (matplotlib .__version__ , np .__version__ , type (data ))
620
- print (data )
599
+
621
600
assert isinstance (data , np .ma .core .MaskedArray )
622
601
mask = data .mask
623
602
assert mask [2 :5 , 1 ].all ()
@@ -641,9 +620,6 @@ def test_gap_upsample(self):
641
620
# 2.0.0 or >= 3.0.0
642
621
data = np .ma .MaskedArray (data , mask = isna (data ), fill_value = np .nan )
643
622
644
- if not isinstance (data , np .ma .core .MaskedArray ):
645
- print (matplotlib .__version__ , np .__version__ , type (data ))
646
- print (data )
647
623
assert isinstance (data , np .ma .core .MaskedArray )
648
624
mask = data .mask
649
625
assert mask [5 :25 , 1 ].all ()
@@ -1428,12 +1404,9 @@ def test_format_timedelta_ticks_narrow(self):
1428
1404
df .plot (fontsize = 2 , ax = ax )
1429
1405
fig .canvas .draw ()
1430
1406
labels = ax .get_xticklabels ()
1431
- if len (labels ) != len (expected_labels ):
1432
- print (matplotlib .__version__ , np .__version__ ,
1433
- [str (x ) for x in labels ], expected_labels )
1407
+
1434
1408
assert len (labels ) == len (expected_labels )
1435
- for l , l_expected in zip (labels , expected_labels ):
1436
- assert l .get_text () == l_expected
1409
+ assert [x .get_text () for x in labels ] == expected_labels
1437
1410
1438
1411
def test_format_timedelta_ticks_wide (self ):
1439
1412
expected_labels = [
@@ -1464,12 +1437,9 @@ def test_format_timedelta_ticks_wide(self):
1464
1437
ax = df .plot (fontsize = 2 , ax = ax )
1465
1438
fig .canvas .draw ()
1466
1439
labels = ax .get_xticklabels ()
1467
- if len (labels ) != len (expected_labels ):
1468
- print (matplotlib .__version__ , np .__version__ ,
1469
- [str (x ) for x in labels ], expected_labels )
1440
+
1470
1441
assert len (labels ) == len (expected_labels )
1471
- for l , l_expected in zip (labels , expected_labels ):
1472
- assert l .get_text () == l_expected
1442
+ assert [x .get_text () for x in labels ] == expected_labels
1473
1443
1474
1444
def test_timedelta_plot (self ):
1475
1445
# test issue #8711
0 commit comments