Skip to content

Commit c12dc7c

Browse files
committed
draw
1 parent 1af0ba5 commit c12dc7c

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

pandas/tests/plotting/test_datetimelike.py

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def test_axis_limits(self):
374374
def _test(ax):
375375
xlim = ax.get_xlim()
376376
ax.set_xlim(xlim[0] - 5, xlim[1] + 10)
377-
ax.get_figure().canvas.draw()
378377
result = ax.get_xlim()
379378
assert result[0] == xlim[0] - 5
380379
assert result[1] == xlim[1] + 10
@@ -383,7 +382,6 @@ def _test(ax):
383382
expected = (Period('1/1/2000', ax.freq),
384383
Period('4/1/2000', ax.freq))
385384
ax.set_xlim('1/1/2000', '4/1/2000')
386-
ax.get_figure().canvas.draw()
387385
result = ax.get_xlim()
388386
assert int(result[0]) == expected[0].ordinal
389387
assert int(result[1]) == expected[1].ordinal
@@ -392,7 +390,6 @@ def _test(ax):
392390
expected = (Period('1/1/2000', ax.freq),
393391
Period('4/1/2000', ax.freq))
394392
ax.set_xlim(datetime(2000, 1, 1), datetime(2000, 4, 1))
395-
ax.get_figure().canvas.draw()
396393
result = ax.get_xlim()
397394
assert int(result[0]) == expected[0].ordinal
398395
assert int(result[1]) == expected[1].ordinal
@@ -429,12 +426,7 @@ def test_get_finder(self):
429426
def test_finder_daily(self):
430427
day_lst = [10, 40, 252, 400, 950, 2750, 10000]
431428

432-
if self.mpl_ge_3_0_0 or not self.mpl_ge_2_2_3:
433-
xpl1 = xpl2 = [Period('1999-1-1', freq='B').ordinal] * len(day_lst)
434-
else: # 2.2.3, 2.2.4
435-
xpl1 = [7565, 7564, 7553, 7546, 7518, 7428, 7066]
436-
xpl2 = [7566, 7564, 7554, 7546, 7519, 7429, 7066]
437-
429+
xpl1 = xpl2 = [Period('1999-1-1', freq='B').ordinal] * len(day_lst)
438430
rs1 = []
439431
rs2 = []
440432
for i, n in enumerate(day_lst):
@@ -457,12 +449,7 @@ def test_finder_daily(self):
457449
def test_finder_quarterly(self):
458450
yrs = [3.5, 11]
459451

460-
if self.mpl_ge_3_0_0 or not self.mpl_ge_2_2_3:
461-
xpl1 = xpl2 = [Period('1988Q1').ordinal] * len(yrs)
462-
else: # 2.2.3, 2.2.4
463-
xpl1 = [68, 68]
464-
xpl2 = [72, 68]
465-
452+
xpl1 = xpl2 = [Period('1988Q1').ordinal] * len(yrs)
466453
rs1 = []
467454
rs2 = []
468455
for i, n in enumerate(yrs):
@@ -485,12 +472,7 @@ def test_finder_quarterly(self):
485472
def test_finder_monthly(self):
486473
yrs = [1.15, 2.5, 4, 11]
487474

488-
if self.mpl_ge_3_0_0 or not self.mpl_ge_2_2_3:
489-
xpl1 = xpl2 = [Period('Jan 1988').ordinal] * len(yrs)
490-
else: # 2.2.3, 2.2.4
491-
xpl1 = [216, 216, 204, 204]
492-
xpl2 = [216, 216, 216, 204]
493-
475+
xpl1 = xpl2 = [Period('Jan 1988').ordinal] * len(yrs)
494476
rs1 = []
495477
rs2 = []
496478
for i, n in enumerate(yrs):
@@ -521,11 +503,7 @@ def test_finder_monthly_long(self):
521503

522504
@pytest.mark.slow
523505
def test_finder_annual(self):
524-
if self.mpl_ge_3_0_0 or not self.mpl_ge_2_2_3:
525-
xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170]
526-
else: # 2.2.3, 2.2.4
527-
xp = [1986, 1986, 1990, 1990, 1995, 2020, 1970, 1970]
528-
506+
xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170]
529507
xp = [Period(x, freq='A').ordinal for x in xp]
530508
rs = []
531509
for i, nyears in enumerate([5, 10, 19, 49, 99, 199, 599, 1001]):
@@ -1093,7 +1071,6 @@ def test_time(self):
10931071
df.plot(ax=ax)
10941072

10951073
# verify tick labels
1096-
fig.canvas.draw()
10971074
ticks = ax.get_xticks()
10981075
labels = ax.get_xticklabels()
10991076
for t, l in zip(ticks, labels):
@@ -1120,7 +1097,6 @@ def test_time_change_xlim(self):
11201097
df.plot(ax=ax)
11211098

11221099
# verify tick labels
1123-
fig.canvas.draw()
11241100
ticks = ax.get_xticks()
11251101
labels = ax.get_xticklabels()
11261102
for t, l in zip(ticks, labels):
@@ -1138,7 +1114,6 @@ def test_time_change_xlim(self):
11381114
ax.set_xlim('1:30', '5:00')
11391115

11401116
# check tick labels again
1141-
fig.canvas.draw()
11421117
ticks = ax.get_xticks()
11431118
labels = ax.get_xticklabels()
11441119
for t, l in zip(ticks, labels):
@@ -1165,7 +1140,6 @@ def test_time_musec(self):
11651140
ax = df.plot(ax=ax)
11661141

11671142
# verify tick labels
1168-
fig.canvas.draw()
11691143
ticks = ax.get_xticks()
11701144
labels = ax.get_xticklabels()
11711145
for t, l in zip(ticks, labels):
@@ -1432,7 +1406,7 @@ def test_format_timedelta_ticks_narrow(self):
14321406
df = DataFrame(np.random.randn(len(rng), 3), rng)
14331407
fig, ax = self.plt.subplots()
14341408
df.plot(fontsize=2, ax=ax)
1435-
fig.canvas.draw()
1409+
self.plt.draw()
14361410
labels = ax.get_xticklabels()
14371411

14381412
result_labels = [x.get_text() for x in labels]
@@ -1456,7 +1430,7 @@ def test_format_timedelta_ticks_wide(self):
14561430
df = DataFrame(np.random.randn(len(rng), 3), rng)
14571431
fig, ax = self.plt.subplots()
14581432
ax = df.plot(fontsize=2, ax=ax)
1459-
fig.canvas.draw()
1433+
self.plt.draw()
14601434
labels = ax.get_xticklabels()
14611435

14621436
result_labels = [x.get_text() for x in labels]
@@ -1529,7 +1503,7 @@ def test_matplotlib_scatter_datetime64(self):
15291503
df["time"] = date_range("2018-01-01", periods=10, freq="D")
15301504
fig, ax = self.plt.subplots()
15311505
ax.scatter(x="time", y="y", data=df)
1532-
fig.canvas.draw()
1506+
self.plt.draw()
15331507
label = ax.get_xticklabels()[0]
15341508
if self.mpl_ge_3_0_0:
15351509
expected = "2017-12-08"

0 commit comments

Comments
 (0)