Skip to content

Commit db21722

Browse files
flake8 fixes
1 parent 34e0b46 commit db21722

File tree

2 files changed

+27
-42
lines changed

2 files changed

+27
-42
lines changed

test/test_cleanfigure.py

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ def test_recursive_cleanfigure():
2222

2323
def test_pruneOutsideBox():
2424
"""test against matlab2tikz implementation
25-
26-
octave code to generate baseline results. Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
25+
26+
octave code to generate baseline results.
27+
Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
2728
```octave
2829
x = linspace(1, 100, 20);
2930
y1 = linspace(1, 100, 20);
30-
31+
3132
figure
3233
plot(x, y1)
3334
xlim([20, 80])
@@ -50,13 +51,14 @@ def test_pruneOutsideBox():
5051

5152

5253
def test_replaceDataWithNaN():
53-
"""test against matlab2tikz implementation
54-
55-
octave code to generate baseline results. Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
54+
"""test against matlab2tikz implementation.
55+
56+
octave code to generate baseline results.
57+
Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
5658
```octave
5759
x = linspace(1, 100, 20);
5860
y1 = linspace(1, 100, 20);
59-
61+
6062
figure
6163
plot(x, y1)
6264
xlim([20, 80])
@@ -83,13 +85,14 @@ def test_replaceDataWithNaN():
8385

8486

8587
def test_removeData():
86-
"""test against matlab2tikz implementation
87-
88-
octave code to generate baseline results. Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
88+
"""test against matlab2tikz implementation.
89+
90+
octave code to generate baseline results.
91+
Note that octave has indexing 1...N, whereas python has indexing 0...N-1.
8992
```octave
9093
x = linspace(1, 100, 20);
9194
y1 = linspace(1, 100, 20);
92-
95+
9396
figure
9497
plot(x, y1)
9598
xlim([20, 80])
@@ -102,7 +105,6 @@ def test_removeData():
102105
id_remove = np.array([1, 2, 3, 17, 18, 19])
103106
xData = np.linspace(1, 100, 20)
104107
yData = xData.copy()
105-
data = np.stack([xData, yData], axis=1)
106108

107109
with plt.rc_context(rc=RC_PARAMS):
108110
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
@@ -134,7 +136,6 @@ def test_removeNaNs():
134136
id_remove = np.array([1, 2, 3, 17, 18, 19])
135137
xData = np.linspace(1, 100, 20)
136138
yData = xData.copy()
137-
data = np.stack([xData, yData], axis=1)
138139

139140
with plt.rc_context(rc=RC_PARAMS):
140141
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
@@ -178,10 +179,10 @@ def test_getVisualLimits():
178179
"""octave code
179180
```octave
180181
addpath ("../matlab2tikz/src")
181-
182+
182183
x = linspace(1, 100, 20);
183184
y1 = linspace(1, 100, 20);
184-
185+
185186
figure
186187
plot(x, y1)
187188
xlim([20, 80])
@@ -210,10 +211,10 @@ def test_movePointsCloser():
210211
"""octave code
211212
```octave
212213
addpath ("../matlab2tikz/src")
213-
214+
214215
x = linspace(1, 100, 20);
215216
y1 = linspace(1, 100, 20);
216-
217+
217218
figure
218219
plot(x, y1)
219220
xlim([20, 80])
@@ -491,7 +492,6 @@ def test_hist(self):
491492

492493
def test_plot3d(self):
493494
""" """
494-
from mpl_toolkits.mplot3d import Axes3D
495495

496496
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
497497
z = np.linspace(-2, 2, 100)
@@ -519,7 +519,6 @@ def test_plot3d(self):
519519

520520
def test_scatter3d(self):
521521
""" """
522-
from mpl_toolkits.mplot3d import Axes3D
523522

524523
x, y = np.meshgrid(np.linspace(1, 100, 20), np.linspace(1, 100, 20))
525524
z = np.abs(x - 50) + np.abs(y - 50)
@@ -552,7 +551,6 @@ def test_wireframe3D(self):
552551

553552
def test_surface3D(self):
554553
""" """
555-
from mpl_toolkits.mplot3d import Axes3D
556554
from matplotlib import cm
557555
from matplotlib.ticker import LinearLocator, FormatStrFormatter
558556

@@ -589,7 +587,6 @@ def test_trisurface3D(Self):
589587
:param Self:
590588
591589
"""
592-
from mpl_toolkits.mplot3d import Axes3D
593590
import matplotlib.pyplot as plt
594591
import numpy as np
595592

@@ -636,7 +633,6 @@ def test_contour3D(self):
636633

637634
def test_polygon3D(self):
638635
""" """
639-
from mpl_toolkits.mplot3d import Axes3D
640636
from matplotlib.collections import PolyCollection
641637
from matplotlib import colors as mcolors
642638

@@ -677,7 +673,6 @@ def cc(arg):
677673

678674
def test_bar3D(self):
679675
""" """
680-
from mpl_toolkits.mplot3d import Axes3D
681676
import matplotlib.pyplot as plt
682677
import numpy as np
683678

@@ -702,7 +697,6 @@ def test_bar3D(self):
702697

703698
def test_quiver3D(self):
704699
""" """
705-
from mpl_toolkits.mplot3d import axes3d
706700
import matplotlib.pyplot as plt
707701
import numpy as np
708702

@@ -733,7 +727,6 @@ def test_quiver3D(self):
733727

734728
def test_2D_in_3D(self):
735729
""" """
736-
from mpl_toolkits.mplot3d import Axes3D
737730
import numpy as np
738731
import matplotlib.pyplot as plt
739732

tikzplotlib/cleanfigure.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
import matplotlib as mpl
33
from matplotlib import pyplot as plt
44
import mpl_toolkits
5-
from mpl_toolkits.mplot3d import Axes3D
65

76

8-
# TODO: change docstring type [!!!]
9-
# TODO: see which test cases the matlab2tikz guys used [!]
7+
# TODO: see which test cases the matlab2tikz guys used [!!!]
8+
# TODO: find suitable test cases for remaining functions. [!!]
109
# TODO: implement remaining functions [!!]
1110
# - simplify stair : plt.step
1211
# -- looks like matlabs stairs plot and matplotlibs plt.step is implemented differently. The data representation is different.
1312
# - there is still a missing code block in movePointsCloser. Maybe find suitable axes limits to get this code block to work
14-
# TODO: find suitable test cases for remaining functions.
1513
# TODO: make grid of plot types which are working and which not. 2D and 3D
1614

1715

@@ -597,8 +595,8 @@ def _movePointscloser(fighandle, axhandle, linehandle):
597595
X1_second = data[id_second, :]
598596
X2_second = data[id_second - 1, :]
599597

600-
newData_first = _moveToBox(X1_first, X2_first, largeXLim, largeYLim)
601-
newData_second = _moveToBox(X1_second, X2_second, largeXLim, largeYLim)
598+
newData_first = _moveToBox(X1_first, X2_first, largeXlim, largeYlim)
599+
newData_second = _moveToBox(X1_second, X2_second, largeXlim, largeYlim)
602600

603601
isXlog = linehandle.get_xscale() == "log"
604602
if isXlog:
@@ -686,19 +684,18 @@ def _movePointscloser(fighandle, axhandle, linehandle):
686684

687685

688686
def _moveToBox(x, xRef, xLim, yLim):
689-
"""
687+
"""Takes a box defined by xlim, ylim, a vector of points x and a vector of
688+
reference points xRef.
689+
Returns the vector of points xNew that sits on the line segment between
690+
x and xRef *and* on the box. If several such points exist, take the
691+
closest one to x.
690692
691693
:param x:
692694
:param xRef:
693695
:param xLim:
694696
:param yLim:
695697
696698
"""
697-
#% Takes a box defined by xlim, ylim, a vector of points x and a vector of
698-
#% reference points xRef.
699-
#% Returns the vector of points xNew that sits on the line segment between
700-
#% x and xRef *and* on the box. If several such points exist, take the
701-
#% closest one to x.
702699
# n = size(x, 1);
703700

704701
# #% Find out with which border the line x---xRef intersects, and determine
@@ -724,7 +721,6 @@ def _moveToBox(x, xRef, xLim, yLim):
724721
# #% Create the new point
725722
# xNew = x + bsxfun(@times ,minAlpha, (xRef-x));
726723
raise NotImplementedError
727-
return xNew
728724

729725

730726
def _insertData(fighandle, linehandle, id_insert, dataInsert):
@@ -778,7 +774,6 @@ def _simplifyLine(fighandle, axhandle, linehandle, target_resolution):
778774
return
779775
W, H = _getWidthHeightInPixels(fighandle, target_resolution)
780776
xData, yData = _getVisualData(axhandle, linehandle)
781-
data = np.stack([xData, yData], axis=1)
782777
# Only simplify if there are more than 2 points
783778
if np.size(xData) <= 2 or np.size(yData) <= 2:
784779
return
@@ -1285,7 +1280,6 @@ def _isValidTargetResolution(val):
12851280
"""
12861281
# TODO: implement this
12871282
raise NotImplementedError
1288-
return isValid
12891283

12901284

12911285
def _isValidAxis(val):
@@ -1296,7 +1290,6 @@ def _isValidAxis(val):
12961290
"""
12971291
# TODO: implement this
12981292
raise NotImplementedError
1299-
return isValid
13001293

13011294

13021295
def _normalizeAxis(fighandle, axhandle):
@@ -1308,7 +1301,6 @@ def _normalizeAxis(fighandle, axhandle):
13081301
"""
13091302
# TODO: implement this
13101303
raise NotImplementedError
1311-
return isValid
13121304

13131305

13141306
def _segmentsIntersect(X1, X2, X3, X4):

0 commit comments

Comments
 (0)