| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ | |||
| 12 | 12 | from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED | |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | - #fname = '/usr/share/fonts/sfd/FreeSans.ttf' | ||
| 16 | 15 | fname = matplotlib.get_data_path() + '/fonts/ttf/DejaVuSans.ttf' | |
| 17 | 16 | font = FT2Font(fname) | |
| 18 | 17 | font.set_charmap(0) | |
@@ -36,7 +35,7 @@ | |||
| 36 | 35 | ||
| 37 | 36 | code = coded['A'] | |
| 38 | 37 | glyph = font.load_char(code) | |
| 39 | - #print(glyph.bbox) | ||
| 38 | + print(glyph.bbox) | ||
| 40 | 39 | print(glyphd['A'], glyphd['V'], coded['A'], coded['V']) | |
| 41 | 40 | print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_DEFAULT)) | |
| 42 | 41 | print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNFITTED)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,8 +467,7 @@ def parse_options(): | |||
| 467 | 467 | switches=switches) | |
| 468 | 468 | if 'pylab_examples' in result.dirs: | |
| 469 | 469 | result.dirs[result.dirs.index('pylab_examples')] = 'pylab' | |
| 470 | - #print(result) | ||
| 471 | - return (result) | ||
| 470 | + return result | ||
| 472 | 471 | ||
| 473 | 472 | if __name__ == '__main__': | |
| 474 | 473 | times = {} | |
@@ -507,9 +506,8 @@ def parse_options(): | |||
| 507 | 506 | failures[backend] = \ | |
| 508 | 507 | drive(backend, options.dirs, python, options.switches) | |
| 509 | 508 | t1 = time.time() | |
| 510 | - times[backend] = (t1 - t0)/60.0 | ||
| 509 | + times[backend] = (t1 - t0) / 60 | ||
| 511 | 510 | ||
| 512 | - #print(times) | ||
| 513 | 511 | for backend, elapsed in times.items(): | |
| 514 | 512 | print('Backend %s took %1.2f minutes to complete' % (backend, elapsed)) | |
| 515 | 513 | failed = failures[backend] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,8 +12,7 @@ | |||
| 12 | 12 | (4, 2)) | |
| 13 | 13 | # dash_style = | |
| 14 | 14 | # 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). | ||
| 17 | 16 | dash_style = ( | |
| 18 | 17 | (0, 20, -15, 30, 10), | |
| 19 | 18 | (1, 30, 0, 15, 10), | |
@@ -27,7 +26,6 @@ | |||
| 27 | 26 | for i in range(len(DATA)): | |
| 28 | 27 | (x, y) = DATA[i] | |
| 29 | 28 | (dd, dl, r, dr, dp) = dash_style[i] | |
| 30 | - # print('dashlen call %d' % dl) | ||
| 31 | 29 | t = ax.text(x, y, str((x, y)), withdash=True, | |
| 32 | 30 | dashdirection=dd, | |
| 33 | 31 | dashlength=dl, | |
@@ -36,7 +34,7 @@ | |||
| 36 | 34 | dashpush=dp, | |
| 37 | 35 | ) | |
| 38 | 36 | ||
| 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)) | ||
| 41 | 39 | ||
| 42 | 40 | plt.show() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1049,7 +1049,6 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid', | |||
| 1049 | 1049 | ||
| 1050 | 1050 | verts = [((thisx, thisymin), (thisx, thisymax)) | |
| 1051 | 1051 | for thisx, thisymin, thisymax in zip(x, ymin, ymax)] | |
| 1052 | - #print 'creating line collection' | ||
| 1053 | 1052 | lines = mcoll.LineCollection(verts, colors=colors, | |
| 1054 | 1053 | linestyles=linestyles, label=label) | |
| 1055 | 1054 | self.add_collection(lines, autolim=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,14 +205,13 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): | |||
| 205 | 205 | font.set_text(s, 0, flags=flags) | |
| 206 | 206 | font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased']) | |
| 207 | 207 | 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. | ||
| 209 | 209 | xo, yo = font.get_bitmap_offset() | |
| 210 | 210 | xo /= 64.0 | |
| 211 | 211 | yo /= 64.0 | |
| 212 | 212 | xd = -d * sin(radians(angle)) | |
| 213 | 213 | yd = d * cos(radians(angle)) | |
| 214 | 214 | ||
| 215 | - #print x, y, int(x), int(y), s | ||
| 216 | 215 | self._renderer.draw_text_image( | |
| 217 | 216 | font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc) | |
| 218 | 217 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2364,8 +2364,8 @@ def delta(self, other): | |||
| 2364 | 2364 | ours = getattr(self, p) | |
| 2365 | 2365 | theirs = getattr(other, p) | |
| 2366 | 2366 | 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 | ||
| 2369 | 2369 | else: | |
| 2370 | 2370 | different = bool(ours != theirs) | |
| 2371 | 2371 | except ValueError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -364,7 +364,6 @@ def get_text_width_height_descent(self, s, prop, ismath): | |||
| 364 | 364 | h /= 64.0 | |
| 365 | 365 | d = font.get_descent() | |
| 366 | 366 | d /= 64.0 | |
| 367 | - #print s, w, h | ||
| 368 | 367 | return w, h, d | |
| 369 | 368 | ||
| 370 | 369 | def flipy(self): | |
@@ -456,7 +455,6 @@ def draw_image(self, gc, x, y, im, transform=None): | |||
| 456 | 455 | yscale = 1.0 | |
| 457 | 456 | ||
| 458 | 457 | figh = self.height * 72 | |
| 459 | - #print 'values', origin, flipud, figh, h, y | ||
| 460 | 458 | ||
| 461 | 459 | bbox = gc.get_clip_rectangle() | |
| 462 | 460 | clippath, clippath_trans = gc.get_clip_path() | |
@@ -470,7 +468,6 @@ def draw_image(self, gc, x, y, im, transform=None): | |||
| 470 | 468 | clip.append('%s' % id) | |
| 471 | 469 | clip = '\n'.join(clip) | |
| 472 | 470 | ||
| 473 | - #y = figh-(y+h) | ||
| 474 | 471 | ps = """gsave | |
| 475 | 472 | %(clip)s | |
| 476 | 473 | %(x)s %(y)s translate | |
@@ -726,7 +723,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): | |||
| 726 | 723 | self.set_font(ps_name, prop.get_size_in_points()) | |
| 727 | 724 | ||
| 728 | 725 | lastgind = None | |
| 729 | - #print 'text', s | ||
| 730 | 726 | lines = [] | |
| 731 | 727 | thisx = 0 | |
| 732 | 728 | thisy = 0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -998,7 +998,6 @@ def _onKeyDown(self, evt): | |||
| 998 | 998 | def _onKeyUp(self, evt): | |
| 999 | 999 | """Release key.""" | |
| 1000 | 1000 | key = self._get_key(evt) | |
| 1001 | - # print 'release key', key | ||
| 1002 | 1001 | evt.Skip() | |
| 1003 | 1002 | FigureCanvasBase.key_release_event(self, key, guiEvent=evt) | |
| 1004 | 1003 | ||
@@ -1059,7 +1058,6 @@ def _onLeftButtonUp(self, evt): | |||
| 1059 | 1058 | """End measuring on an axis.""" | |
| 1060 | 1059 | x = evt.GetX() | |
| 1061 | 1060 | y = self.figure.bbox.height - evt.GetY() | |
| 1062 | - # print 'release button', 1 | ||
| 1063 | 1061 | evt.Skip() | |
| 1064 | 1062 | self._set_capture(False) | |
| 1065 | 1063 | FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt) | |
@@ -1086,7 +1084,6 @@ def _onMiddleButtonUp(self, evt): | |||
| 1086 | 1084 | """End measuring on an axis.""" | |
| 1087 | 1085 | x = evt.GetX() | |
| 1088 | 1086 | y = self.figure.bbox.height - evt.GetY() | |
| 1089 | - # print 'release button', 1 | ||
| 1090 | 1087 | evt.Skip() | |
| 1091 | 1088 | self._set_capture(False) | |
| 1092 | 1089 | FigureCanvasBase.button_release_event(self, x, y, 2, guiEvent=evt) | |
@@ -1102,7 +1099,6 @@ def _onMouseWheel(self, evt): | |||
| 1102 | 1099 | delta = evt.GetWheelDelta() | |
| 1103 | 1100 | rotation = evt.GetWheelRotation() | |
| 1104 | 1101 | rate = evt.GetLinesPerAction() | |
| 1105 | - # print "delta,rotation,rate",delta,rotation,rate | ||
| 1106 | 1102 | step = rate * float(rotation) / delta | |
| 1107 | 1103 | ||
| 1108 | 1104 | # Done handling event | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -974,7 +974,6 @@ def add_lines(self, CS, erase=True): | |||
| 974 | 974 | # to make one object track another automatically. | |
| 975 | 975 | #tcolors = [col.get_colors()[0] for col in CS.collections] | |
| 976 | 976 | #tlinewidths = [col.get_linewidth()[0] for lw in CS.collections] | |
| 977 | - #print 'tlinewidths:', tlinewidths | ||
| 978 | 977 | ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths, | |
| 979 | 978 | erase=erase) | |
| 980 | 979 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2582,21 +2582,17 @@ def push_state(self): | |||
| 2582 | 2582 | self._state_stack.append(self.get_state().copy()) | |
| 2583 | 2583 | ||
| 2584 | 2584 | def main(self, s, loc, toks): | |
| 2585 | - #~ print "finish", toks | ||
| 2586 | 2585 | return [Hlist(toks)] | |
| 2587 | 2586 | ||
| 2588 | 2587 | def math_string(self, s, loc, toks): | |
| 2589 | - # print "math_string", toks[0][1:-1] | ||
| 2590 | 2588 | return self._math_expression.parseString(toks[0][1:-1]) | |
| 2591 | 2589 | ||
| 2592 | 2590 | def math(self, s, loc, toks): | |
| 2593 | - #~ print "math", toks | ||
| 2594 | 2591 | hlist = Hlist(toks) | |
| 2595 | 2592 | self.pop_state() | |
| 2596 | 2593 | return [hlist] | |
| 2597 | 2594 | ||
| 2598 | 2595 | def non_math(self, s, loc, toks): | |
| 2599 | - #~ print "non_math", toks | ||
| 2600 | 2596 | s = toks[0].replace(r'\$', '$') | |
| 2601 | 2597 | symbols = [Char(c, self.get_state(), math=False) for c in s] | |
| 2602 | 2598 | hlist = Hlist(symbols) | |
@@ -2630,7 +2626,7 @@ def _make_space(self, percentage): | |||
| 2630 | 2626 | r'\!' : -0.16667, # -3/18 em = -3 mu | |
| 2631 | 2627 | } | |
| 2632 | 2628 | def space(self, s, loc, toks): | |
| 2633 | - assert(len(toks)==1) | ||
| 2629 | + assert len(toks)==1 | ||
| 2634 | 2630 | num = self._space_widths[toks[0]] | |
| 2635 | 2631 | box = self._make_space(num) | |
| 2636 | 2632 | return [box] | |
@@ -2639,7 +2635,6 @@ def customspace(self, s, loc, toks): | |||
| 2639 | 2635 | return [self._make_space(float(toks[0]))] | |
| 2640 | 2636 | ||
| 2641 | 2637 | def symbol(self, s, loc, toks): | |
| 2642 | - # print "symbol", toks | ||
| 2643 | 2638 | c = toks[0] | |
| 2644 | 2639 | try: | |
| 2645 | 2640 | char = Char(c, self.get_state()) | |
@@ -2691,7 +2686,6 @@ def symbol(self, s, loc, toks): | |||
| 2691 | 2686 | snowflake = symbol | |
| 2692 | 2687 | ||
| 2693 | 2688 | def unknown_symbol(self, s, loc, toks): | |
| 2694 | - # print "symbol", toks | ||
| 2695 | 2689 | c = toks[0] | |
| 2696 | 2690 | raise ParseFatalException(s, loc, "Unknown symbol: %s" % c) | |
| 2697 | 2691 | ||
@@ -2768,7 +2762,7 @@ def c_over_c(self, s, loc, toks): | |||
| 2768 | 2762 | ) (set(_accent_map)) | |
| 2769 | 2763 | ||
| 2770 | 2764 | def accent(self, s, loc, toks): | |
| 2771 | - assert(len(toks)==1) | ||
| 2765 | + assert len(toks)==1 | ||
| 2772 | 2766 | state = self.get_state() | |
| 2773 | 2767 | thickness = state.font_output.get_underline_thickness( | |
| 2774 | 2768 | state.font, state.fontsize, state.dpi) | |
@@ -2792,7 +2786,6 @@ def accent(self, s, loc, toks): | |||
| 2792 | 2786 | ]) | |
| 2793 | 2787 | ||
| 2794 | 2788 | def function(self, s, loc, toks): | |
| 2795 | - #~ print "function", toks | ||
| 2796 | 2789 | self.push_state() | |
| 2797 | 2790 | state = self.get_state() | |
| 2798 | 2791 | state.font = 'rm' | |
@@ -2830,7 +2823,7 @@ def end_group(self, s, loc, toks): | |||
| 2830 | 2823 | return [] | |
| 2831 | 2824 | ||
| 2832 | 2825 | def font(self, s, loc, toks): | |
| 2833 | - assert(len(toks)==1) | ||
| 2826 | + assert len(toks)==1 | ||
| 2834 | 2827 | name = toks[0] | |
| 2835 | 2828 | self.get_state().font = name | |
| 2836 | 2829 | return [] | |
@@ -2856,7 +2849,7 @@ def is_between_brackets(self, s, loc): | |||
| 2856 | 2849 | return False | |
| 2857 | 2850 | ||
| 2858 | 2851 | def subsuper(self, s, loc, toks): | |
| 2859 | - assert(len(toks)==1) | ||
| 2852 | + assert len(toks)==1 | ||
| 2860 | 2853 | ||
| 2861 | 2854 | nucleus = None | |
| 2862 | 2855 | sub = None | |
@@ -3086,14 +3079,14 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den): | |||
| 3086 | 3079 | return result | |
| 3087 | 3080 | ||
| 3088 | 3081 | 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 | ||
| 3091 | 3084 | ||
| 3092 | 3085 | return self._genfrac(*tuple(toks[0])) | |
| 3093 | 3086 | ||
| 3094 | 3087 | 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 | ||
| 3097 | 3090 | state = self.get_state() | |
| 3098 | 3091 | ||
| 3099 | 3092 | thickness = state.font_output.get_underline_thickness( | |
@@ -3104,8 +3097,8 @@ def frac(self, s, loc, toks): | |||
| 3104 | 3097 | self._math_style_dict['textstyle'], num, den) | |
| 3105 | 3098 | ||
| 3106 | 3099 | 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 | ||
| 3109 | 3102 | state = self.get_state() | |
| 3110 | 3103 | ||
| 3111 | 3104 | thickness = state.font_output.get_underline_thickness( | |
@@ -3116,23 +3109,22 @@ def dfrac(self, s, loc, toks): | |||
| 3116 | 3109 | self._math_style_dict['displaystyle'], num, den) | |
| 3117 | 3110 | ||
| 3118 | 3111 | 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 | ||
| 3121 | 3114 | num, den = toks[0] | |
| 3122 | 3115 | ||
| 3123 | 3116 | return self._genfrac('', '', 0.0, | |
| 3124 | 3117 | self._math_style_dict['textstyle'], num, den) | |
| 3125 | 3118 | ||
| 3126 | 3119 | 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 | ||
| 3129 | 3122 | num, den = toks[0] | |
| 3130 | 3123 | ||
| 3131 | 3124 | return self._genfrac('(', ')', 0.0, | |
| 3132 | 3125 | self._math_style_dict['textstyle'], num, den) | |
| 3133 | 3126 | ||
| 3134 | 3127 | def sqrt(self, s, loc, toks): | |
| 3135 | - #~ print "sqrt", toks | ||
| 3136 | 3128 | root, body = toks[0] | |
| 3137 | 3129 | state = self.get_state() | |
| 3138 | 3130 | thickness = state.font_output.get_underline_thickness( | |
@@ -3177,8 +3169,8 @@ def sqrt(self, s, loc, toks): | |||
| 3177 | 3169 | return [hlist] | |
| 3178 | 3170 | ||
| 3179 | 3171 | 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 | ||
| 3182 | 3174 | ||
| 3183 | 3175 | body = toks[0][0] | |
| 3184 | 3176 | ||
@@ -3222,7 +3214,6 @@ def _auto_sized_delimiter(self, front, middle, back): | |||
| 3222 | 3214 | return hlist | |
| 3223 | 3215 | ||
| 3224 | 3216 | def auto_delim(self, s, loc, toks): | |
| 3225 | - #~ print "auto_delim", toks | ||
| 3226 | 3217 | front, middle, back = toks | |
| 3227 | 3218 | ||
| 3228 | 3219 | return self._auto_sized_delimiter(front, middle.asList(), back) | |
@@ -3320,7 +3311,7 @@ def to_mask(self, texstr, dpi=120, fontsize=14): | |||
| 3320 | 3311 | - depth is the offset of the baseline from the bottom of the | |
| 3321 | 3312 | image in pixels. | |
| 3322 | 3313 | """ | |
| 3323 | - assert(self._output=="bitmap") | ||
| 3314 | + assert self._output == "bitmap" | ||
| 3324 | 3315 | prop = FontProperties(size=fontsize) | |
| 3325 | 3316 | ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop) | |
| 3326 | 3317 | ||
@@ -3402,7 +3393,7 @@ def get_depth(self, texstr, dpi=120, fontsize=14): | |||
| 3402 | 3393 | *fontsize* | |
| 3403 | 3394 | The font size in points | |
| 3404 | 3395 | """ | |
| 3405 | - assert(self._output=="bitmap") | ||
| 3396 | + assert self._output=="bitmap" | ||
| 3406 | 3397 | prop = FontProperties(size=fontsize) | |
| 3407 | 3398 | ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop) | |
| 3408 | 3399 | return depth | |
| Back | FazBrowse Home | New Git URL |
0 commit comments