Skip to content

Commit b73691a

Browse files
refactoring
only `cleanfigure.cleanfigure` is public, rest is protected now. Updated tests.
1 parent ab832a0 commit b73691a

File tree

2 files changed

+112
-110
lines changed

2 files changed

+112
-110
lines changed

test/test_cleanfigure.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_pruneOutsideBox():
3030
(l,) = ax.plot(x, y)
3131
ax.set_ylim([20, 80])
3232
ax.set_xlim([20, 80])
33-
cleanfigure.pruneOutsideBox(fig, ax, l)
33+
cleanfigure._pruneOutsideBox(fig, ax, l)
3434
assert l.get_xdata().shape == (14,)
3535

3636

@@ -58,7 +58,7 @@ def test_replaceDataWithNaN():
5858
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
5959
l, = ax.plot(xData, yData)
6060

61-
cleanfigure.replaceDataWithNaN(l, id_replace)
61+
cleanfigure._replaceDataWithNan(l, id_replace)
6262

6363
newdata = np.stack(l.get_data(), axis=1)
6464
assert newdata.shape == data.shape
@@ -89,7 +89,7 @@ def test_removeData():
8989
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
9090
l, = ax.plot(xData, yData)
9191

92-
cleanfigure.removeData(l, id_remove)
92+
cleanfigure._removeData(l, id_remove)
9393
newdata = np.stack(l.get_data(), axis=1)
9494
assert newdata.shape == (14, 2)
9595

@@ -118,9 +118,9 @@ def test_removeNaNs():
118118
with plt.rc_context(rc=RC_PARAMS):
119119
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
120120
l, = ax.plot(xData, yData)
121-
cleanfigure.replaceDataWithNaN(l, id_replace)
122-
cleanfigure.removeData(l, id_remove)
123-
cleanfigure.removeNaNs(l)
121+
cleanfigure._replaceDataWithNan(l, id_replace)
122+
cleanfigure._removeData(l, id_remove)
123+
cleanfigure._removeNaNs(l)
124124
newdata = np.stack(l.get_data(), axis=1)
125125
assert not np.any(np.isnan(newdata))
126126
assert newdata.shape == (12, 2)
@@ -147,7 +147,7 @@ def test_isInBox():
147147
tol = 1.0e-10
148148
relaxedXLim = xLim + np.array([-tol, tol])
149149
relaxedYLim = yLim + np.array([-tol, tol])
150-
mask = cleanfigure.isInBox(data, relaxedXLim, relaxedYLim)
150+
mask = cleanfigure._isInBox(data, relaxedXLim, relaxedYLim)
151151
assert int(np.sum(mask)) == 12
152152

153153

@@ -177,7 +177,7 @@ def test_getVisualLimits():
177177
(l,) = ax.plot(x, y)
178178
ax.set_xlim([20, 80])
179179
ax.set_ylim([20, 80])
180-
xLim, yLim = cleanfigure.getVisualLimits(fig, ax)
180+
xLim, yLim = cleanfigure._getVisualLimits(fig, ax)
181181
assert np.allclose(xLim, np.array([20, 80]))
182182
assert np.allclose(yLim, np.array([20, 80]))
183183

@@ -208,8 +208,8 @@ def test_movePointsCloser():
208208
(l,) = ax.plot(x, y)
209209
ax.set_ylim([20, 80])
210210
ax.set_xlim([20, 80])
211-
cleanfigure.pruneOutsideBox(fig, ax, l)
212-
cleanfigure.movePointscloser(fig, ax, l)
211+
cleanfigure._pruneOutsideBox(fig, ax, l)
212+
cleanfigure._movePointscloser(fig, ax, l)
213213
assert l.get_xdata().shape == (14,)
214214

215215

@@ -239,9 +239,9 @@ def test_simplifyLine():
239239
(l,) = ax.plot(x, y)
240240
ax.set_ylim([20, 80])
241241
ax.set_xlim([20, 80])
242-
cleanfigure.pruneOutsideBox(fig, ax, l)
243-
cleanfigure.movePointscloser(fig, ax, l)
244-
cleanfigure.simplifyLine(fig, ax, l, 600)
242+
cleanfigure._pruneOutsideBox(fig, ax, l)
243+
cleanfigure._movePointscloser(fig, ax, l)
244+
cleanfigure._simplifyLine(fig, ax, l, 600)
245245
assert l.get_xdata().shape == (2,)
246246
assert l.get_ydata().shape == (2,)
247247

@@ -272,10 +272,10 @@ def test_limitPrecision():
272272
(l,) = ax.plot(x, y)
273273
ax.set_ylim([20, 80])
274274
ax.set_xlim([20, 80])
275-
cleanfigure.pruneOutsideBox(fig, ax, l)
276-
cleanfigure.movePointscloser(fig, ax, l)
277-
cleanfigure.simplifyLine(fig, ax, l, 600)
278-
cleanfigure.limitPrecision(fig, ax, l, 1)
275+
cleanfigure._pruneOutsideBox(fig, ax, l)
276+
cleanfigure._movePointscloser(fig, ax, l)
277+
cleanfigure._simplifyLine(fig, ax, l, 600)
278+
cleanfigure._limitPrecision(fig, ax, l, 1)
279279
assert l.get_xdata().shape == (2,)
280280
assert l.get_ydata().shape == (2,)
281281

@@ -317,7 +317,7 @@ def test_opheimSimplify():
317317
)
318318
y = x.copy()
319319
tol = 0.02
320-
mask = cleanfigure.opheimSimplify(x, y, tol)
320+
mask = cleanfigure._opheimSimplify(x, y, tol)
321321
assert mask.shape == (12,)
322322
assert np.allclose(mask * 1, np.array([1,] + [0,] * 10 + [1,]))
323323

@@ -335,7 +335,7 @@ def test_is_step(function, result):
335335
(l,) = ax.plot(x, y)
336336
elif function == "step":
337337
(l,) = ax.step(x, y)
338-
assert cleanfigure.isStep(l) == result
338+
assert cleanfigure._isStep(l) == result
339339

340340

341341
class Test_plottypes:
@@ -849,7 +849,7 @@ def test_segmentVisible():
849849
dataIsInBox = np.array([0,] * 4 + [1,] * 12 + [0,] * 4) == 1
850850
xLim = np.array([20, 80])
851851
yLim = np.array([20, 80])
852-
mask = cleanfigure.segmentVisible(data, dataIsInBox, xLim, yLim)
852+
mask = cleanfigure._segmentVisible(data, dataIsInBox, xLim, yLim)
853853
assert np.allclose(mask * 1, np.array([0,] * 3 + [1,] * 13 + [0,] * 3))
854854

855855

@@ -863,7 +863,7 @@ def test_crossLines():
863863
X2 = data[1:, :]
864864
X3 = np.array([80, 20])
865865
X4 = np.array([80, 80])
866-
Lambda = cleanfigure.crossLines(X1, X2, X3, X4)
866+
Lambda = cleanfigure._crossLines(X1, X2, X3, X4)
867867

868868
expected_result = np.array(
869869
[
@@ -901,7 +901,7 @@ def test_segmentsIntersect():
901901
X2 = data[1:, :]
902902
X3 = np.array([80, 20])
903903
X4 = np.array([80, 80])
904-
mask = cleanfigure.segmentsIntersect(X1, X2, X3, X4)
904+
mask = cleanfigure._segmentsIntersect(X1, X2, X3, X4)
905905
assert np.allclose(mask * 1, np.zeros_like(mask))
906906

907907

@@ -925,14 +925,14 @@ def test_pixelate():
925925
]
926926
)
927927
yData = xData.copy()
928-
mask = cleanfigure.pixelate(xData, yData, xToPix, yToPix)
928+
mask = cleanfigure._pixelate(xData, yData, xToPix, yToPix)
929929
assert mask.shape == (12,)
930930
assert np.all(mask)
931931

932932

933933
def test_corners3D():
934934
xlim = ylim = zlim = np.array([-5, 5])
935-
corners = cleanfigure.corners3D(xlim, ylim, zlim)
935+
corners = cleanfigure._corners3D(xlim, ylim, zlim)
936936

937937
assert corners.shape == (8, 3)
938938
assert np.sum(corners) == 0

0 commit comments

Comments
 (0)