Skip to content

Commit b48e8d7

Browse files
authored
Merge pull request #195 from QuLogic/lint
Fix minor linting issues
2 parents f5e0210 + 746bf07 commit b48e8d7

13 files changed

Lines changed: 12 additions & 27 deletions

scripts/adjustements.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import matplotlib as mpl
99
import matplotlib.pyplot as plt
1010
import matplotlib.patches as mpatches
11-
from matplotlib.collections import PatchCollection
1211

1312

1413
ROOT_DIR = pathlib.Path(__file__).parent.parent

scripts/anatomy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
def minor_tick(x, pos):
3131
if not x % 1.0:
3232
return ""
33-
return "%.2f" % x
33+
return f"{x:.2f}"
3434

3535

3636
ax.xaxis.set_major_locator(MultipleLocator(1.000))

scripts/annotate.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# -----------------------------------------------------------------------------
55
import pathlib
66

7-
import numpy as np
8-
import matplotlib as mpl
97
import matplotlib.pyplot as plt
108

119

scripts/colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
'raw' : ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'],
2727
'rgba' : [(1, 0, 0), (1, 0, 0, 0.75), (1, 0, 0, 0.50), (1, 0, 0, 0.25)],
2828
'HexRGBA' : ["#FF0000", "#FF0000BB", "#FF000088", "#FF000044"],
29-
'cycle' : ["C%d" % i for i in range(10)],
30-
'grey' : ["%1.1f" % (i/10) for i in range(11)],
29+
'cycle' : [f"C{i}" for i in range(10)],
30+
'grey' : [f"{i/10:1.1f}" for i in range(11)],
3131
'name' : ["DarkRed", "Firebrick", "Crimson", "IndianRed", "Salmon" ] }
3232

3333
for name, colors in palettes.items():

scripts/legend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# -----------------------------------------------------------------------------
55
import pathlib
66

7-
import numpy as np
87
import matplotlib as mpl
98
import matplotlib.pyplot as plt
109

scripts/linestyles.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def split(n_segment):
3333
for x0, x1, style in zip(X0, X1, styles):
3434
ax.plot([x0, x1], [y, y], color="C1", linestyle=style,
3535
solid_capstyle="round", dash_capstyle="round", linewidth=3)
36-
if isinstance(style, str): text = '"%s"' % style
37-
else: text = '%s' % str(style)
38-
text = text.replace(' ', '')
36+
text = f'{style!r}'.replace(' ', '')
3937
ax.text((x0+x1)/2, y-0.2, text,
4038
size=8, ha="center", va="top", family="Source Code Pro")
4139
ax.text(X0[0]-0.25, y+0.2, "linestyle or ls", family="Source Code Pro",
@@ -51,7 +49,7 @@ def split(n_segment):
5149
linewidth=7, linestyle="--", alpha=.25)
5250
ax.plot([x0, x1], [y, y], color="C1", linewidth=7,
5351
linestyle="--", dash_capstyle=style)
54-
ax.text((x0+x1)/2, y-0.2, '"%s"' % style, family="Source Code Pro",
52+
ax.text((x0+x1)/2, y-0.2, f'{style!r}', family="Source Code Pro",
5553
size=10, ha="center", va="top")
5654
ax.text(X0[0]-0.25, y+0.2, "capstyle or dash_capstyle", family="Source Code Pro",
5755
size=14, ha="left", va="baseline")

scripts/markers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,10 @@
2626
"1", "2", "3", "4", "+", "x", "|", "_", 4, 5, 6, 7,
2727
".", "o", "s", "P", "X", "*", "p", "D", "<", ">", "^", "v", ]
2828
for x, y, marker in zip(X, Y, markers):
29-
if y == 3: fc = "white"
30-
else: fc = "C1"
29+
fc = "white" if y == 3 else "C1"
3130
plt.scatter(x, 1+y, s=100, marker=marker, fc=fc, ec="C1", lw=0.5)
3231

33-
if y == 1: marker = "\$%s\$" % marker
34-
if isinstance(marker, str): text = "'%s'" % marker
35-
else: text = '%s' % marker
32+
text = f"{marker!r}".replace("$", r"\$")
3633
plt.text(x, 1+y-0.4, text,
3734
size="x-small", ha="center", va="top", family="Monospace")
3835

@@ -50,7 +47,7 @@
5047
Y = y*np.ones(len(X))
5148
ax.plot(X, Y, linewidth=1, color="black",
5249
marker=".", mfc="white", mec="black", mew="1", markevery=mark)
53-
ax.text((X[0]+X[-1])/2, y-0.2, '%s' % str(mark),
50+
ax.text((X[0]+X[-1])/2, y-0.2, str(mark),
5451
size="x-small", ha="center", va="top")
5552

5653
plt.text(.7, 1, "markevery",

scripts/plot-variations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
ax1.plot(X, Y1, color="C1", linewidth=0.75)
8282
ax1.set_ylim(0, 4), ax1.set_yticks(np.arange(1, 4))
8383
ax1.grid()
84-
ax1.tick_params(axis=u'both', which=u'both', length=0)
84+
ax1.tick_params(axis='both', which='both', length=0)
8585

8686
Y2 = 2+1*np.cos(2*X)
8787
ax2.plot(X, Y2, color="C0", linewidth=0.75)
8888
ax2.set_ylim(0, 4), ax2.set_yticks(np.arange(1, 4))
8989
ax2.grid()
90-
ax2.tick_params(axis=u'both', which=u'both', length=0)
90+
ax2.tick_params(axis='both', which='both', length=0)
9191
fig.savefig(ROOT_DIR / "figures/plot-vsplit.pdf")
9292

9393
# Basic line plot (hsplit)
@@ -99,13 +99,13 @@
9999
ax1.plot(Y1, X, color="C1", linewidth=0.75)
100100
ax1.set_xlim(0, 4), ax1.set_xticks(np.arange(1, 4))
101101
ax1.grid()
102-
ax1.tick_params(axis=u'both', which=u'both', length=0)
102+
ax1.tick_params(axis='both', which='both', length=0)
103103

104104
Y2 = 2+1*np.cos(2*X)
105105
ax2.plot(Y2, X, color="C0", linewidth=0.75)
106106
ax2.set_xlim(0, 4), ax2.set_xticks(np.arange(1, 4))
107107
ax2.grid()
108-
ax2.tick_params(axis=u'both', which=u'both', length=0)
108+
ax2.tick_params(axis='both', which='both', length=0)
109109
fig.savefig(ROOT_DIR / "figures/plot-hsplit.pdf")
110110

111111
# Basic line plot (title)

scripts/styles.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pathlib
66

77
import numpy as np
8-
import matplotlib as mpl
98
import matplotlib.pyplot as plt
109

1110

scripts/tick-multiple-locator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# ----------------------------------------------------------------------------
66
import pathlib
77

8-
import numpy as np
98
import matplotlib as mpl
109
import matplotlib.pyplot as plt
1110
import matplotlib.ticker as ticker

0 commit comments

Comments
 (0)