Skip to content

Commit b2a9e10

Browse files
authored
Merge pull request matplotlib#10333 from anntzer/debug-prints
Remove some commented out debug prints.
2 parents f68f9a1 + 291b995 commit b2a9e10

22 files changed

+37
-74
lines changed

examples/misc/font_indexing.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED
1313

1414

15-
#fname = '/usr/share/fonts/sfd/FreeSans.ttf'
1615
fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans.ttf'
1716
font = FT2Font(fname)
1817
font.set_charmap(0)
@@ -36,7 +35,7 @@
3635

3736
code = coded['A']
3837
glyph = font.load_char(code)
39-
#print(glyph.bbox)
38+
print(glyph.bbox)
4039
print(glyphd['A'], glyphd['V'], coded['A'], coded['V'])
4140
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_DEFAULT))
4241
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNFITTED))

examples/tests/backend_driver_sgskip.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,7 @@ def parse_options():
467467
switches=switches)
468468
if 'pylab_examples' in result.dirs:
469469
result.dirs[result.dirs.index('pylab_examples')] = 'pylab'
470-
#print(result)
471-
return (result)
470+
return result
472471

473472
if __name__ == '__main__':
474473
times = {}
@@ -507,9 +506,8 @@ def parse_options():
507506
failures[backend] = \
508507
drive(backend, options.dirs, python, options.switches)
509508
t1 = time.time()
510-
times[backend] = (t1 - t0)/60.0
509+
times[backend] = (t1 - t0) / 60
511510

512-
#print(times)
513511
for backend, elapsed in times.items():
514512
print('Backend %s took %1.2f minutes to complete' % (backend, elapsed))
515513
failed = failures[backend]

examples/text_labels_and_annotations/dashpointlabel.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
(4, 2))
1313
# dash_style =
1414
# direction, length, (text)rotation, dashrotation, push
15-
# (The parameters are varied to show their effects,
16-
# not for visual appeal).
15+
# (The parameters are varied to show their effects, not for visual appeal).
1716
dash_style = (
1817
(0, 20, -15, 30, 10),
1918
(1, 30, 0, 15, 10),
@@ -27,7 +26,6 @@
2726
for i in range(len(DATA)):
2827
(x, y) = DATA[i]
2928
(dd, dl, r, dr, dp) = dash_style[i]
30-
# print('dashlen call %d' % dl)
3129
t = ax.text(x, y, str((x, y)), withdash=True,
3230
dashdirection=dd,
3331
dashlength=dl,
@@ -36,7 +34,7 @@
3634
dashpush=dp,
3735
)
3836

39-
ax.set_xlim((0.0, 5.0))
40-
ax.set_ylim((0.0, 5.0))
37+
ax.set_xlim((0, 5))
38+
ax.set_ylim((0, 5))
4139

4240
plt.show()

lib/matplotlib/axes/_axes.py

-1
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
10491049

10501050
verts = [((thisx, thisymin), (thisx, thisymax))
10511051
for thisx, thisymin, thisymax in zip(x, ymin, ymax)]
1052-
#print 'creating line collection'
10531052
lines = mcoll.LineCollection(verts, colors=colors,
10541053
linestyles=linestyles, label=label)
10551054
self.add_collection(lines, autolim=False)

lib/matplotlib/backends/backend_agg.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,13 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
205205
font.set_text(s, 0, flags=flags)
206206
font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased'])
207207
d = font.get_descent() / 64.0
208-
# The descent needs to be adjusted for the angle
208+
# The descent needs to be adjusted for the angle.
209209
xo, yo = font.get_bitmap_offset()
210210
xo /= 64.0
211211
yo /= 64.0
212212
xd = -d * sin(radians(angle))
213213
yd = d * cos(radians(angle))
214214

215-
#print x, y, int(x), int(y), s
216215
self._renderer.draw_text_image(
217216
font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc)
218217

lib/matplotlib/backends/backend_pdf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2364,8 +2364,8 @@ def delta(self, other):
23642364
ours = getattr(self, p)
23652365
theirs = getattr(other, p)
23662366
try:
2367-
if (ours is None or theirs is None):
2368-
different = bool(not(ours is theirs))
2367+
if ours is None or theirs is None:
2368+
different = ours is not theirs
23692369
else:
23702370
different = bool(ours != theirs)
23712371
except ValueError:

lib/matplotlib/backends/backend_ps.py

-4
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ def get_text_width_height_descent(self, s, prop, ismath):
364364
h /= 64.0
365365
d = font.get_descent()
366366
d /= 64.0
367-
#print s, w, h
368367
return w, h, d
369368

370369
def flipy(self):
@@ -456,7 +455,6 @@ def draw_image(self, gc, x, y, im, transform=None):
456455
yscale = 1.0
457456

458457
figh = self.height * 72
459-
#print 'values', origin, flipud, figh, h, y
460458

461459
bbox = gc.get_clip_rectangle()
462460
clippath, clippath_trans = gc.get_clip_path()
@@ -470,7 +468,6 @@ def draw_image(self, gc, x, y, im, transform=None):
470468
clip.append('%s' % id)
471469
clip = '\n'.join(clip)
472470

473-
#y = figh-(y+h)
474471
ps = """gsave
475472
%(clip)s
476473
%(x)s %(y)s translate
@@ -726,7 +723,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
726723
self.set_font(ps_name, prop.get_size_in_points())
727724

728725
lastgind = None
729-
#print 'text', s
730726
lines = []
731727
thisx = 0
732728
thisy = 0

lib/matplotlib/backends/backend_wx.py

-4
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ def _onKeyDown(self, evt):
998998
def _onKeyUp(self, evt):
999999
"""Release key."""
10001000
key = self._get_key(evt)
1001-
# print 'release key', key
10021001
evt.Skip()
10031002
FigureCanvasBase.key_release_event(self, key, guiEvent=evt)
10041003

@@ -1059,7 +1058,6 @@ def _onLeftButtonUp(self, evt):
10591058
"""End measuring on an axis."""
10601059
x = evt.GetX()
10611060
y = self.figure.bbox.height - evt.GetY()
1062-
# print 'release button', 1
10631061
evt.Skip()
10641062
self._set_capture(False)
10651063
FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
@@ -1086,7 +1084,6 @@ def _onMiddleButtonUp(self, evt):
10861084
"""End measuring on an axis."""
10871085
x = evt.GetX()
10881086
y = self.figure.bbox.height - evt.GetY()
1089-
# print 'release button', 1
10901087
evt.Skip()
10911088
self._set_capture(False)
10921089
FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt)
@@ -1102,7 +1099,6 @@ def _onMouseWheel(self, evt):
11021099
delta = evt.GetWheelDelta()
11031100
rotation = evt.GetWheelRotation()
11041101
rate = evt.GetLinesPerAction()
1105-
# print "delta,rotation,rate",delta,rotation,rate
11061102
step = rate * float(rotation) / delta
11071103

11081104
# Done handling event

lib/matplotlib/colorbar.py

-1
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ def add_lines(self, CS, erase=True):
974974
# to make one object track another automatically.
975975
#tcolors = [col.get_colors()[0] for col in CS.collections]
976976
#tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
977-
#print 'tlinewidths:', tlinewidths
978977
ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths,
979978
erase=erase)
980979

lib/matplotlib/mathtext.py

+18-27
Original file line numberDiff line numberDiff line change
@@ -2582,21 +2582,17 @@ def push_state(self):
25822582
self._state_stack.append(self.get_state().copy())
25832583

25842584
def main(self, s, loc, toks):
2585-
#~ print "finish", toks
25862585
return [Hlist(toks)]
25872586

25882587
def math_string(self, s, loc, toks):
2589-
# print "math_string", toks[0][1:-1]
25902588
return self._math_expression.parseString(toks[0][1:-1])
25912589

25922590
def math(self, s, loc, toks):
2593-
#~ print "math", toks
25942591
hlist = Hlist(toks)
25952592
self.pop_state()
25962593
return [hlist]
25972594

25982595
def non_math(self, s, loc, toks):
2599-
#~ print "non_math", toks
26002596
s = toks[0].replace(r'\$', '$')
26012597
symbols = [Char(c, self.get_state(), math=False) for c in s]
26022598
hlist = Hlist(symbols)
@@ -2630,7 +2626,7 @@ def _make_space(self, percentage):
26302626
r'\!' : -0.16667, # -3/18 em = -3 mu
26312627
}
26322628
def space(self, s, loc, toks):
2633-
assert(len(toks)==1)
2629+
assert len(toks)==1
26342630
num = self._space_widths[toks[0]]
26352631
box = self._make_space(num)
26362632
return [box]
@@ -2639,7 +2635,6 @@ def customspace(self, s, loc, toks):
26392635
return [self._make_space(float(toks[0]))]
26402636

26412637
def symbol(self, s, loc, toks):
2642-
# print "symbol", toks
26432638
c = toks[0]
26442639
try:
26452640
char = Char(c, self.get_state())
@@ -2691,7 +2686,6 @@ def symbol(self, s, loc, toks):
26912686
snowflake = symbol
26922687

26932688
def unknown_symbol(self, s, loc, toks):
2694-
# print "symbol", toks
26952689
c = toks[0]
26962690
raise ParseFatalException(s, loc, "Unknown symbol: %s" % c)
26972691

@@ -2768,7 +2762,7 @@ def c_over_c(self, s, loc, toks):
27682762
) (set(_accent_map))
27692763

27702764
def accent(self, s, loc, toks):
2771-
assert(len(toks)==1)
2765+
assert len(toks)==1
27722766
state = self.get_state()
27732767
thickness = state.font_output.get_underline_thickness(
27742768
state.font, state.fontsize, state.dpi)
@@ -2792,7 +2786,6 @@ def accent(self, s, loc, toks):
27922786
])
27932787

27942788
def function(self, s, loc, toks):
2795-
#~ print "function", toks
27962789
self.push_state()
27972790
state = self.get_state()
27982791
state.font = 'rm'
@@ -2830,7 +2823,7 @@ def end_group(self, s, loc, toks):
28302823
return []
28312824

28322825
def font(self, s, loc, toks):
2833-
assert(len(toks)==1)
2826+
assert len(toks)==1
28342827
name = toks[0]
28352828
self.get_state().font = name
28362829
return []
@@ -2856,7 +2849,7 @@ def is_between_brackets(self, s, loc):
28562849
return False
28572850

28582851
def subsuper(self, s, loc, toks):
2859-
assert(len(toks)==1)
2852+
assert len(toks)==1
28602853

28612854
nucleus = None
28622855
sub = None
@@ -3086,14 +3079,14 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
30863079
return result
30873080

30883081
def genfrac(self, s, loc, toks):
3089-
assert(len(toks) == 1)
3090-
assert(len(toks[0]) == 6)
3082+
assert len(toks) == 1
3083+
assert len(toks[0]) == 6
30913084

30923085
return self._genfrac(*tuple(toks[0]))
30933086

30943087
def frac(self, s, loc, toks):
3095-
assert(len(toks) == 1)
3096-
assert(len(toks[0]) == 2)
3088+
assert len(toks) == 1
3089+
assert len(toks[0]) == 2
30973090
state = self.get_state()
30983091

30993092
thickness = state.font_output.get_underline_thickness(
@@ -3104,8 +3097,8 @@ def frac(self, s, loc, toks):
31043097
self._math_style_dict['textstyle'], num, den)
31053098

31063099
def dfrac(self, s, loc, toks):
3107-
assert(len(toks) == 1)
3108-
assert(len(toks[0]) == 2)
3100+
assert len(toks) == 1
3101+
assert len(toks[0]) == 2
31093102
state = self.get_state()
31103103

31113104
thickness = state.font_output.get_underline_thickness(
@@ -3116,23 +3109,22 @@ def dfrac(self, s, loc, toks):
31163109
self._math_style_dict['displaystyle'], num, den)
31173110

31183111
def stackrel(self, s, loc, toks):
3119-
assert(len(toks) == 1)
3120-
assert(len(toks[0]) == 2)
3112+
assert len(toks) == 1
3113+
assert len(toks[0]) == 2
31213114
num, den = toks[0]
31223115

31233116
return self._genfrac('', '', 0.0,
31243117
self._math_style_dict['textstyle'], num, den)
31253118

31263119
def binom(self, s, loc, toks):
3127-
assert(len(toks) == 1)
3128-
assert(len(toks[0]) == 2)
3120+
assert len(toks) == 1
3121+
assert len(toks[0]) == 2
31293122
num, den = toks[0]
31303123

31313124
return self._genfrac('(', ')', 0.0,
31323125
self._math_style_dict['textstyle'], num, den)
31333126

31343127
def sqrt(self, s, loc, toks):
3135-
#~ print "sqrt", toks
31363128
root, body = toks[0]
31373129
state = self.get_state()
31383130
thickness = state.font_output.get_underline_thickness(
@@ -3177,8 +3169,8 @@ def sqrt(self, s, loc, toks):
31773169
return [hlist]
31783170

31793171
def overline(self, s, loc, toks):
3180-
assert(len(toks)==1)
3181-
assert(len(toks[0])==1)
3172+
assert len(toks)==1
3173+
assert len(toks[0])==1
31823174

31833175
body = toks[0][0]
31843176

@@ -3222,7 +3214,6 @@ def _auto_sized_delimiter(self, front, middle, back):
32223214
return hlist
32233215

32243216
def auto_delim(self, s, loc, toks):
3225-
#~ print "auto_delim", toks
32263217
front, middle, back = toks
32273218

32283219
return self._auto_sized_delimiter(front, middle.asList(), back)
@@ -3320,7 +3311,7 @@ def to_mask(self, texstr, dpi=120, fontsize=14):
33203311
- depth is the offset of the baseline from the bottom of the
33213312
image in pixels.
33223313
"""
3323-
assert(self._output=="bitmap")
3314+
assert self._output == "bitmap"
33243315
prop = FontProperties(size=fontsize)
33253316
ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop)
33263317

@@ -3402,7 +3393,7 @@ def get_depth(self, texstr, dpi=120, fontsize=14):
34023393
*fontsize*
34033394
The font size in points
34043395
"""
3405-
assert(self._output=="bitmap")
3396+
assert self._output=="bitmap"
34063397
prop = FontProperties(size=fontsize)
34073398
ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop)
34083399
return depth

lib/matplotlib/tests/test_axes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -226,20 +226,20 @@ def test_inverted_cla():
226226
fig = plt.figure(0)
227227
ax = fig.gca()
228228
# 1. test that a new axis is not inverted per default
229-
assert not(ax.xaxis_inverted())
230-
assert not(ax.yaxis_inverted())
229+
assert not ax.xaxis_inverted()
230+
assert not ax.yaxis_inverted()
231231
img = np.random.random((100, 100))
232232
ax.imshow(img)
233233
# 2. test that a image axis is inverted
234-
assert not(ax.xaxis_inverted())
234+
assert not ax.xaxis_inverted()
235235
assert ax.yaxis_inverted()
236236
# 3. test that clearing and plotting a line, axes are
237237
# not inverted
238238
ax.cla()
239239
x = np.linspace(0, 2*np.pi, 100)
240240
ax.plot(x, np.cos(x))
241-
assert not(ax.xaxis_inverted())
242-
assert not(ax.yaxis_inverted())
241+
assert not ax.xaxis_inverted()
242+
assert not ax.yaxis_inverted()
243243

244244
# 4. autoscaling should not bring back axes to normal
245245
ax.cla()
@@ -5494,7 +5494,7 @@ def test_twinx_knows_limits():
54945494
ax2.axvspan(1, 2)
54955495
ax2.plot([0, 0.5], [1, 2])
54965496

5497-
assert((xtwin.viewLim.intervalx == ax2.viewLim.intervalx).all())
5497+
assert_array_equal(xtwin.viewLim.intervalx, ax2.viewLim.intervalx)
54985498

54995499

55005500
@pytest.mark.style('mpl20')

lib/matplotlib/tests/test_colors.py

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_colormap_endian():
6767
for dt in ["f2", "f4", "f8"]:
6868
anative = np.ma.masked_invalid(np.array(a, dtype=dt))
6969
aforeign = anative.byteswap().newbyteorder()
70-
#print(anative.dtype.isnative, aforeign.dtype.isnative)
7170
assert_array_equal(cmap(anative), cmap(aforeign))
7271

7372

0 commit comments

Comments
 (0)