Skip to content

Commit 820696e

Browse files
changed tests for new interface
1 parent 4fbde3d commit 820696e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

test/test_cleanfigure.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@ def test_pruneOutsideBox():
4545
(l,) = ax.plot(x, y)
4646
ax.set_ylim([20, 80])
4747
ax.set_xlim([20, 80])
48-
cleanfigure._prune_outside_box(fig, ax, l)
49-
assert l.get_xdata().shape == (14,)
50-
plt.close("all")
48+
axhandle = ax
49+
linehandle = l
50+
fighandle = fig
51+
xData, yData = cleanfigure._get_visual_data(axhandle, linehandle)
52+
visual_data = cleanfigure._stack_data_2D(xData, yData)
53+
data = cleanfigure._get_data(linehandle)
54+
xLim, yLim = cleanfigure._get_visual_limits(fighandle, axhandle)
55+
is3D = cleanfigure._lineIs3D(linehandle)
56+
hasLines = cleanfigure._line_has_lines(linehandle)
57+
58+
data = cleanfigure._prune_outside_box(
59+
xLim, yLim, data, visual_data, is3D, hasLines
60+
)
61+
assert data.shape == (14, 2)
62+
5163

5264

5365
def test_replaceDataWithNaN():
@@ -71,16 +83,9 @@ def test_replaceDataWithNaN():
7183
yData = xData.copy()
7284
data = np.stack([xData, yData], axis=1)
7385

74-
with plt.rc_context(rc=RC_PARAMS):
75-
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
76-
(l,) = ax.plot(xData, yData)
77-
78-
cleanfigure._replace_data_with_NaN(l, id_replace)
79-
80-
newdata = np.stack(l.get_data(), axis=1)
86+
newdata = cleanfigure._replace_data_with_NaN(data, id_replace, False)
8187
assert newdata.shape == data.shape
8288
assert np.any(np.isnan(newdata))
83-
plt.close("all")
8489

8590

8691
def test_removeData():
@@ -102,15 +107,10 @@ def test_removeData():
102107
id_remove = np.array([1, 2, 3, 17, 18, 19])
103108
xData = np.linspace(1, 100, 20)
104109
yData = xData.copy()
110+
data = np.stack([xData, yData], axis=1)
105111

106-
with plt.rc_context(rc=RC_PARAMS):
107-
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
108-
(l,) = ax.plot(xData, yData)
109-
110-
cleanfigure._remove_data(l, id_remove)
111-
newdata = np.stack(l.get_data(), axis=1)
112+
newdata = cleanfigure._remove_data(data, id_remove, False)
112113
assert newdata.shape == (14, 2)
113-
plt.close("all")
114114

115115

116116
def test_removeNaNs():

0 commit comments

Comments
 (0)