@@ -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
0 commit comments