Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3cb7e20

Browse files
committed
Delete some if __name__ == "__main__" clauses.
In offsetbox and mpl_axes, they are just examples (mpl_axes doesn't even call `show()`); if anything the examples belong in the examples/ directory but they don't look particularly worth moving there either. In rcsetup, the clause is checking that the defaults in rcParams don't get modified by the validators. If anything this should be a test, but it doesn't look like it mattered. I did fix `text.latex.preamble`, `pgf.preamble`, and `keymap.fullscreen` to be idempotent under the validator; now the only rcParam that gets changed is `savefig.bbox` (due to the presence of the "standard" / None synonym) but again this isn't a problem.
1 parent bcb372b commit 3cb7e20

File tree

3 files changed

+3
-60
lines changed

3 files changed

+3
-60
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,44 +1765,3 @@ def update_offset(self, dx, dy):
17651765
ann = self.annotation
17661766
ann.xyann = ann.get_transform().inverted().transform(
17671767
(self.ox + dx, self.oy + dy))
1768-
1769-
1770-
if __name__ == "__main__":
1771-
import matplotlib.pyplot as plt
1772-
fig = plt.figure()
1773-
ax = plt.subplot(121)
1774-
1775-
#txt = ax.text(0.5, 0.5, "Test", size=30, ha="center", color="w")
1776-
kwargs = dict()
1777-
1778-
a = np.arange(256).reshape(16, 16) / 256.
1779-
myimage = OffsetImage(a,
1780-
zoom=2,
1781-
norm=None,
1782-
origin=None,
1783-
**kwargs
1784-
)
1785-
ax.add_artist(myimage)
1786-
1787-
myimage.set_offset((100, 100))
1788-
1789-
myimage2 = OffsetImage(a,
1790-
zoom=2,
1791-
norm=None,
1792-
origin=None,
1793-
**kwargs
1794-
)
1795-
ann = AnnotationBbox(myimage2, (0.5, 0.5),
1796-
xybox=(30, 30),
1797-
xycoords='data',
1798-
boxcoords="offset points",
1799-
frameon=True, pad=0.4, # BboxPatch
1800-
bboxprops=dict(boxstyle="round", fc="y"),
1801-
fontsize=None,
1802-
arrowprops=dict(arrowstyle="->"),
1803-
)
1804-
1805-
ax.add_artist(ann)
1806-
1807-
plt.draw()
1808-
plt.show()

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def _validate_linestyle(ls):
11151115
'text.color': ['black', validate_color],
11161116
'text.usetex': [False, validate_bool],
11171117
'text.latex.unicode': [True, validate_bool],
1118-
'text.latex.preamble': [[''], validate_stringlist],
1118+
'text.latex.preamble': [[], validate_stringlist],
11191119
'text.latex.preview': [False, validate_bool],
11201120
'text.dvipnghack': [None, validate_bool_maybe_none],
11211121
'text.hinting': ['auto', validate_hinting],
@@ -1391,7 +1391,7 @@ def _validate_linestyle(ls):
13911391
# use matplotlib rc settings for font configuration
13921392
'pgf.rcfonts': [True, validate_bool],
13931393
# provide a custom preamble for the latex process
1394-
'pgf.preamble': [[''], validate_stringlist],
1394+
'pgf.preamble': [[], validate_stringlist],
13951395

13961396
# write raster image data directly into the svg file
13971397
'svg.image_inline': [True, validate_bool],
@@ -1412,7 +1412,7 @@ def _validate_linestyle(ls):
14121412
'agg.path.chunksize': [0, validate_int], # 0 to disable chunking;
14131413

14141414
# key-mappings (multi-character mappings should be a list/tuple)
1415-
'keymap.fullscreen': [('f', 'ctrl+f'), validate_stringlist],
1415+
'keymap.fullscreen': [['f', 'ctrl+f'], validate_stringlist],
14161416
'keymap.home': [['h', 'r', 'home'], validate_stringlist],
14171417
'keymap.back': [['left', 'c', 'backspace'], validate_stringlist],
14181418
'keymap.forward': [['right', 'v'], validate_stringlist],
@@ -1463,11 +1463,3 @@ def _validate_linestyle(ls):
14631463
# altogether. For that use `matplotlib.style.use('classic')`.
14641464
'_internal.classic_mode': [False, validate_bool]
14651465
}
1466-
1467-
1468-
if __name__ == '__main__':
1469-
rc = defaultParams
1470-
rc['datapath'][0] = '/'
1471-
for key in rc:
1472-
if not rc[key][1](rc[key][0]) == rc[key][0]:
1473-
print("%s: %s != %s" % (key, rc[key][1](rc[key][0]), rc[key][0]))

lib/mpl_toolkits/axes_grid1/mpl_axes.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,3 @@ def toggle(self, all=None, ticks=None, ticklabels=None, label=None):
131131
elif _label:
132132
self._axis.label.set_visible(True)
133133
self._axis.set_label_position(self._axis_direction)
134-
135-
136-
if __name__ == '__main__':
137-
import matplotlib.pyplot as plt
138-
fig = plt.figure()
139-
ax = Axes(fig, [0.1, 0.1, 0.8, 0.8])
140-
fig.add_axes(ax)
141-
ax.cla()

0 commit comments

Comments
 (0)