Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 485e0f8

Browse filesBrowse files
committed
Cleanup unused variables and imports
1 parent b99e636 commit 485e0f8
Copy full SHA for 485e0f8
Expand file treeCollapse file tree

20 files changed

+49
-93
lines changed

‎lib/matplotlib/_constrained_layout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_constrained_layout.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,6 @@ def _align_spines(fig, gs):
344344
height_ratios[rownummin[n]:(rownummax[n] + 1)])
345345

346346
for nn, ax in enumerate(axs[:-1]):
347-
ss0 = ax.get_subplotspec()
348-
349347
# now compare ax to all the axs:
350348
#
351349
# If the subplotspecs have the same colnumXmax, then line

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7772,7 +7772,6 @@ def matshow(self, Z, **kwargs):
77727772
77737773
"""
77747774
Z = np.asanyarray(Z)
7775-
nr, nc = Z.shape
77767775
kw = {'origin': 'upper',
77777776
'interpolation': 'nearest',
77787777
'aspect': 'equal', # (already the imshow default)

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import matplotlib.font_manager as font_manager
2828
import matplotlib.text as mtext
2929
import matplotlib.image as mimage
30-
from matplotlib.artist import allow_rasterization
3130

3231
from matplotlib.rcsetup import cycler, validate_axisbelow
3332

@@ -2540,7 +2539,7 @@ def _update_title_position(self, renderer):
25402539
title.set_position((x, ymax))
25412540

25422541
# Drawing
2543-
@allow_rasterization
2542+
@martist.allow_rasterization
25442543
def draw(self, renderer=None, inframe=False):
25452544
"""Draw everything (plot lines, axes, labels)"""
25462545
if renderer is None:

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from matplotlib import rcParams
1212
import matplotlib.artist as artist
13-
from matplotlib.artist import allow_rasterization
1413
import matplotlib.cbook as cbook
1514
from matplotlib.cbook import _string_to_bool
1615
import matplotlib.font_manager as font_manager
@@ -286,7 +285,7 @@ def get_loc(self):
286285
'Return the tick location (data coords) as a scalar'
287286
return self._loc
288287

289-
@allow_rasterization
288+
@artist.allow_rasterization
290289
def draw(self, renderer):
291290
if not self.get_visible():
292291
self.stale = False
@@ -1174,7 +1173,7 @@ def get_tick_padding(self):
11741173
values.append(self.minorTicks[0].get_tick_padding())
11751174
return max(values, default=0)
11761175

1177-
@allow_rasterization
1176+
@artist.allow_rasterization
11781177
def draw(self, renderer, *args, **kwargs):
11791178
'Draw the axis lines, grid lines, tick lines and labels'
11801179

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+20-37Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -722,45 +722,29 @@ def remove(self, o):
722722

723723

724724
def report_memory(i=0): # argument may go away
725-
"""return the memory consumed by process"""
726-
from subprocess import Popen, PIPE
727-
pid = os.getpid()
728-
if sys.platform == 'sunos5':
725+
"""Return the memory consumed by the process."""
726+
def call(command, os_name):
729727
try:
730-
a2 = Popen(['ps', '-p', '%d' % pid, '-o', 'osz'],
731-
stdout=PIPE).stdout.readlines()
732-
except OSError:
728+
return subprocess.check_output(command)
729+
except subprocess.CalledProcessError:
733730
raise NotImplementedError(
734-
"report_memory works on Sun OS only if "
735-
"the 'ps' program is found")
736-
mem = int(a2[-1].strip())
731+
"report_memory works on %s only if "
732+
"the '%s' program is found" % (os_name, command[0])
733+
)
734+
735+
pid = os.getpid()
736+
if sys.platform == 'sunos5':
737+
lines = call(['ps', '-p', '%d' % pid, '-o', 'osz'], 'Sun OS')
738+
mem = int(lines[-1].strip())
737739
elif sys.platform == 'linux':
738-
try:
739-
a2 = Popen(['ps', '-p', '%d' % pid, '-o', 'rss,sz'],
740-
stdout=PIPE).stdout.readlines()
741-
except OSError:
742-
raise NotImplementedError(
743-
"report_memory works on Linux only if "
744-
"the 'ps' program is found")
745-
mem = int(a2[1].split()[1])
740+
lines = call(['ps', '-p', '%d' % pid, '-o', 'rss,sz'], 'Linux')
741+
mem = int(lines[1].split()[1])
746742
elif sys.platform == 'darwin':
747-
try:
748-
a2 = Popen(['ps', '-p', '%d' % pid, '-o', 'rss,vsz'],
749-
stdout=PIPE).stdout.readlines()
750-
except OSError:
751-
raise NotImplementedError(
752-
"report_memory works on Mac OS only if "
753-
"the 'ps' program is found")
754-
mem = int(a2[1].split()[0])
743+
lines = call(['ps', '-p', '%d' % pid, '-o', 'rss,vsz'], 'Mac OS')
744+
mem = int(lines[1].split()[0])
755745
elif sys.platform == 'win32':
756-
try:
757-
a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid],
758-
stdout=PIPE).stdout.read()
759-
except OSError:
760-
raise NotImplementedError(
761-
"report_memory works on Windows only if "
762-
"the 'tasklist' program is found")
763-
mem = int(a2.strip().split()[-2].replace(',', ''))
746+
lines = call(["tasklist", "/nh", "/fi", "pid eq %d" % pid], 'Windows')
747+
mem = int(lines.strip().split()[-2].replace(',', ''))
764748
else:
765749
raise NotImplementedError(
766750
"We don't have a memory monitor for %s" % sys.platform)
@@ -810,7 +794,6 @@ def print_cycles(objects, outstream=sys.stdout, show_progress=False):
810794
If True, print the number of objects reached as they are found.
811795
"""
812796
import gc
813-
from types import FrameType
814797

815798
def print_path(path):
816799
for i, step in enumerate(path):
@@ -851,7 +834,7 @@ def recurse(obj, start, all, current_path):
851834
# Don't go back through the original list of objects, or
852835
# through temporary references to the object, since those
853836
# are just an artifact of the cycle detector itself.
854-
elif referent is objects or isinstance(referent, FrameType):
837+
elif referent is objects or isinstance(referent, types.FrameType):
855838
continue
856839

857840
# We haven't seen this object before, so recurse
@@ -2006,7 +1989,7 @@ def _warn_external(message, category=None):
20061989
etc.).
20071990
"""
20081991
frame = sys._getframe()
2009-
for stacklevel in itertools.count(1):
1992+
for stacklevel in itertools.count(1): # lgtm[py/unused-loop-variable]
20101993
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.)",
20111994
frame.f_globals["__name__"]):
20121995
break

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ def __init__(self, ax, mappable, **kw):
10561056

10571057
self.mappable = mappable
10581058
kw['cmap'] = cmap = mappable.cmap
1059-
kw['norm'] = norm = mappable.norm
1059+
kw['norm'] = mappable.norm
10601060

10611061
if isinstance(mappable, contour.ContourSet):
10621062
CS = mappable

‎lib/matplotlib/dviread.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,6 @@ def __iter__(self):
964964

965965
@staticmethod
966966
def _parse(file):
967-
result = []
968-
969967
lines = (line.split(b'%', 1)[0].strip() for line in file)
970968
data = b''.join(lines)
971969
beginning = data.find(b'[')

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+9-15Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@
2424

2525
import matplotlib.artist as martist
2626
from matplotlib.artist import Artist, allow_rasterization
27-
2827
import matplotlib.cbook as cbook
29-
30-
from matplotlib.cbook import Stack
31-
32-
from matplotlib import image as mimage
33-
from matplotlib.image import FigureImage
34-
3528
import matplotlib.colorbar as cbar
29+
import matplotlib.image as mimage
3630

3731
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
3832
from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
@@ -57,7 +51,7 @@ def _stale_figure_callback(self, val):
5751
self.figure.stale = val
5852

5953

60-
class AxesStack(Stack):
54+
class AxesStack(cbook.Stack):
6155
"""
6256
Specialization of the `.Stack` to handle all tracking of
6357
`~matplotlib.axes.Axes` in a `.Figure`.
@@ -74,7 +68,7 @@ class AxesStack(Stack):
7468
7569
"""
7670
def __init__(self):
77-
Stack.__init__(self)
71+
super().__init__()
7872
self._ind = 0
7973

8074
def as_list(self):
@@ -108,14 +102,14 @@ def _entry_from_axes(self, e):
108102

109103
def remove(self, a):
110104
"""Remove the axes from the stack."""
111-
Stack.remove(self, self._entry_from_axes(a))
105+
super().remove(self._entry_from_axes(a))
112106

113107
def bubble(self, a):
114108
"""
115109
Move the given axes, which must already exist in the
116110
stack, to the top.
117111
"""
118-
return Stack.bubble(self, self._entry_from_axes(a))
112+
return super().bubble(self._entry_from_axes(a))
119113

120114
def add(self, key, a):
121115
"""
@@ -137,15 +131,15 @@ def add(self, key, a):
137131

138132
a_existing = self.get(key)
139133
if a_existing is not None:
140-
Stack.remove(self, (key, a_existing))
134+
super().remove((key, a_existing))
141135
warnings.warn(
142136
"key {!r} already existed; Axes is being replaced".format(key))
143137
# I don't think the above should ever happen.
144138

145139
if a in self:
146140
return None
147141
self._ind += 1
148-
return Stack.push(self, (key, (self._ind, a)))
142+
return super().push((key, (self._ind, a)))
149143

150144
def current_key_axes(self):
151145
"""
@@ -331,7 +325,7 @@ def __init__(self,
331325
:meth:`.subplot2grid`.)
332326
Defaults to :rc:`figure.constrained_layout.use`.
333327
"""
334-
Artist.__init__(self)
328+
super().__init__()
335329
# remove the non-figure artist _axes property
336330
# as it makes no sense for a figure to be _in_ an axes
337331
# this is used by the property methods in the artist base class
@@ -859,7 +853,7 @@ def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None,
859853
figsize = [x / dpi for x in (X.shape[1], X.shape[0])]
860854
self.set_size_inches(figsize, forward=True)
861855

862-
im = FigureImage(self, cmap, norm, xo, yo, origin, **kwargs)
856+
im = mimage.FigureImage(self, cmap, norm, xo, yo, origin, **kwargs)
863857
im.stale_callback = _stale_figure_callback
864858

865859
im.set_array(X)

‎lib/matplotlib/fontconfig_pattern.py

Copy file name to clipboardExpand all lines: lib/matplotlib/fontconfig_pattern.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ def generate_fontconfig_pattern(d):
175175
pattern string.
176176
"""
177177
props = []
178-
families = ''
179-
size = ''
180178
for key in 'family style variant weight stretch file size'.split():
181179
val = getattr(d, 'get_' + key)()
182180
if val is not None and val != []:

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from matplotlib import rcParams
1717
import matplotlib.artist as martist
18-
from matplotlib.artist import allow_rasterization
1918
from matplotlib.backend_bases import FigureCanvasBase
2019
import matplotlib.colors as mcolors
2120
import matplotlib.cm as cm
@@ -557,7 +556,7 @@ def _check_unsampled_image(self, renderer):
557556
"""
558557
return False
559558

560-
@allow_rasterization
559+
@martist.allow_rasterization
561560
def draw(self, renderer, *args, **kwargs):
562561
# if not visible, declare victory and return
563562
if not self.get_visible():

‎lib/matplotlib/mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mathtext.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,6 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
854854
new_fontname, sym, uniindex),
855855
MathTextWarning)
856856
fontname = 'rm'
857-
new_fontname = fontname
858857
font = self._get_font(fontname)
859858
uniindex = 0xA4 # currency char, for lack of anything better
860859
glyphindex = font.get_char_index(uniindex)
@@ -1168,7 +1167,7 @@ def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
11681167
found_symbol = False
11691168

11701169
if not found_symbol:
1171-
glyph = sym = '?'
1170+
glyph = '?'
11721171
num = ord(glyph)
11731172
symbol_name = font.get_name_char(glyph)
11741173

‎lib/matplotlib/mlab.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mlab.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3447,7 +3447,6 @@ def stineman_interp(xi, x, y, yp=None):
34473447
yp = np.asarray(yp, float)
34483448

34493449
xi = np.asarray(xi, float)
3450-
yi = np.zeros(xi.shape, float)
34513450

34523451
# calculate linear slopes
34533452
dx = x[1:] - x[:-1]

‎lib/matplotlib/patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patches.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,9 +3079,6 @@ def connect(self, posA, posB):
30793079
dd2 = (dx * dx + dy * dy) ** .5
30803080
ddx, ddy = dx / dd2, dy / dd2
30813081

3082-
else:
3083-
dl = 0.
3084-
30853082
arm = max(armA, armB)
30863083
f = self.fraction * dd + arm
30873084

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ def __str__(self):
256256
return "{}({})".format(type(self).__name__, self._resolution)
257257

258258
def transform_path_non_affine(self, path):
259-
vertices = path.vertices
260259
ipath = path.interpolated(self._resolution)
261260
return Path(self.transform(ipath.vertices), ipath.codes)
262261
transform_path_non_affine.__doc__ = \

‎lib/matplotlib/quiver.py

Copy file name to clipboardExpand all lines: lib/matplotlib/quiver.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import matplotlib.transforms as transforms
2525
import matplotlib.text as mtext
2626
import matplotlib.artist as martist
27-
from matplotlib.artist import allow_rasterization
2827
from matplotlib import docstring
2928
import matplotlib.font_manager as font_manager
3029
from matplotlib.cbook import delete_masked_points
@@ -341,7 +340,7 @@ def _text_y(self, y):
341340
else:
342341
return y
343342

344-
@allow_rasterization
343+
@martist.allow_rasterization
345344
def draw(self, renderer):
346345
self._init()
347346
self.vector.draw(renderer)
@@ -540,7 +539,7 @@ def get_datalim(self, transData):
540539
bbox.update_from_data_xy(XY, ignore=True)
541540
return bbox
542541

543-
@allow_rasterization
542+
@martist.allow_rasterization
544543
def draw(self, renderer):
545544
self._init()
546545
verts = self._make_verts(self.U, self.V, self.angles)

‎lib/matplotlib/stackplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/stackplot.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def stackplot(axes, x, *args,
8282
stack += first_line
8383

8484
elif baseline == 'weighted_wiggle':
85-
m, n = y.shape
8685
total = np.sum(y, 0)
8786
# multiply by 1/total (or zero) to avoid infinities in the division:
8887
inv_total = np.zeros_like(total)

‎lib/matplotlib/textpath.py

Copy file name to clipboardExpand all lines: lib/matplotlib/textpath.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def get_glyphs_mathtext(self, prop, s, glyph_map=None,
233233
glyph_ids = []
234234
sizes = []
235235

236-
currx, curry = 0, 0
237236
for font, fontsize, ccode, ox, oy in glyphs:
238237
char_id = self._get_char_id(font, ccode)
239238
if char_id not in glyph_map:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.