Skip to content

Commit ab832a0

Browse files
modifed tesst to comply with new data update model
1 parent 72e0433 commit ab832a0

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

test/test_cleanfigure.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ def test_replaceDataWithNaN():
5050
```
5151
"""
5252
id_replace = np.array([0, 16])
53-
data = np.stack([np.linspace(1, 100, 20)] * 2, axis=1)
53+
xData = np.linspace(1, 100, 20)
54+
yData = xData.copy()
55+
data = np.stack([xData, yData], axis=1)
56+
57+
with plt.rc_context(rc=RC_PARAMS):
58+
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
59+
l, = ax.plot(xData, yData)
5460

55-
newdata = cleanfigure.replaceDataWithNaN(data, id_replace)
61+
cleanfigure.replaceDataWithNaN(l, id_replace)
62+
63+
newdata = np.stack(l.get_data(), axis=1)
5664
assert newdata.shape == data.shape
5765
assert np.any(np.isnan(newdata))
5866

@@ -73,9 +81,16 @@ def test_removeData():
7381
```
7482
"""
7583
id_remove = np.array([1, 2, 3, 17, 18, 19])
76-
data = np.stack([np.linspace(1, 100, 20)] * 2, axis=1)
84+
xData = np.linspace(1, 100, 20)
85+
yData = xData.copy()
86+
data = np.stack([xData, yData], axis=1)
7787

78-
newdata = cleanfigure.removeData(data, id_remove)
88+
with plt.rc_context(rc=RC_PARAMS):
89+
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
90+
l, = ax.plot(xData, yData)
91+
92+
cleanfigure.removeData(l, id_remove)
93+
newdata = np.stack(l.get_data(), axis=1)
7994
assert newdata.shape == (14, 2)
8095

8196

@@ -96,10 +111,17 @@ def test_removeNaNs():
96111
"""
97112
id_replace = np.array([0, 16])
98113
id_remove = np.array([1, 2, 3, 17, 18, 19])
99-
data = np.stack([np.linspace(1, 100, 20)] * 2, axis=1)
100-
newdata = cleanfigure.replaceDataWithNaN(data, id_replace)
101-
newdata = cleanfigure.removeData(newdata, id_remove)
102-
newdata = cleanfigure.removeNaNs(newdata)
114+
xData = np.linspace(1, 100, 20)
115+
yData = xData.copy()
116+
data = np.stack([xData, yData], axis=1)
117+
118+
with plt.rc_context(rc=RC_PARAMS):
119+
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
120+
l, = ax.plot(xData, yData)
121+
cleanfigure.replaceDataWithNaN(l, id_replace)
122+
cleanfigure.removeData(l, id_remove)
123+
cleanfigure.removeNaNs(l)
124+
newdata = np.stack(l.get_data(), axis=1)
103125
assert not np.any(np.isnan(newdata))
104126
assert newdata.shape == (12, 2)
105127

0 commit comments

Comments
 (0)