@@ -2365,16 +2365,16 @@ def _make_space(self, percentage):
2365
2365
}
2366
2366
2367
2367
def space (self , s , loc , toks ):
2368
- assert len ( toks ) == 1
2369
- num = self ._space_widths [toks [ 0 ] ]
2368
+ tok , = toks
2369
+ num = self ._space_widths [tok ]
2370
2370
box = self ._make_space (num )
2371
2371
return [box ]
2372
2372
2373
2373
def customspace (self , s , loc , toks ):
2374
2374
return [self ._make_space (float (toks [0 ]))]
2375
2375
2376
2376
def symbol (self , s , loc , toks ):
2377
- c = toks [ 0 ]
2377
+ c , = toks
2378
2378
try :
2379
2379
char = Char (c , self .get_state ())
2380
2380
except ValueError as err :
@@ -2414,7 +2414,7 @@ def symbol(self, s, loc, toks):
2414
2414
accentprefixed = symbol
2415
2415
2416
2416
def unknown_symbol (self , s , loc , toks ):
2417
- c = toks [ 0 ]
2417
+ c , = toks
2418
2418
raise ParseFatalException (s , loc , "Unknown symbol: %s" % c )
2419
2419
2420
2420
_char_over_chars = {
@@ -2425,7 +2425,7 @@ def unknown_symbol(self, s, loc, toks):
2425
2425
}
2426
2426
2427
2427
def c_over_c (self , s , loc , toks ):
2428
- sym = toks [ 0 ]
2428
+ sym , = toks
2429
2429
state = self .get_state ()
2430
2430
thickness = state .font_output .get_underline_thickness (
2431
2431
state .font , state .fontsize , state .dpi )
@@ -2491,13 +2491,10 @@ def c_over_c(self, s, loc, toks):
2491
2491
])(set (_accent_map ))
2492
2492
2493
2493
def accent (self , s , loc , toks ):
2494
- assert len (toks ) == 1
2495
2494
state = self .get_state ()
2496
2495
thickness = state .font_output .get_underline_thickness (
2497
2496
state .font , state .fontsize , state .dpi )
2498
- if len (toks [0 ]) != 2 :
2499
- raise ParseFatalException ("Error parsing accent" )
2500
- accent , sym = toks [0 ]
2497
+ (accent , sym ), = toks
2501
2498
if accent in self ._wide_accents :
2502
2499
accent_box = AutoWidthChar (
2503
2500
'\\ ' + accent , sym .width , state , char_class = Accent )
@@ -2516,7 +2513,7 @@ def accent(self, s, loc, toks):
2516
2513
2517
2514
def function (self , s , loc , toks ):
2518
2515
hlist = self .operatorname (s , loc , toks )
2519
- hlist .function_name = toks [ 0 ]
2516
+ hlist .function_name , = toks
2520
2517
return hlist
2521
2518
2522
2519
def operatorname (self , s , loc , toks ):
@@ -2564,8 +2561,7 @@ def end_group(self, s, loc, toks):
2564
2561
return []
2565
2562
2566
2563
def font (self , s , loc , toks ):
2567
- assert len (toks ) == 1
2568
- name = toks [0 ]
2564
+ name , = toks
2569
2565
self .get_state ().font = name
2570
2566
return []
2571
2567
@@ -2821,45 +2817,32 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
2821
2817
return result
2822
2818
2823
2819
def genfrac (self , s , loc , toks ):
2824
- assert len (toks ) == 1
2825
- assert len (toks [0 ]) == 6
2826
-
2827
- return self ._genfrac (* tuple (toks [0 ]))
2820
+ args , = toks
2821
+ return self ._genfrac (* args )
2828
2822
2829
2823
def frac (self , s , loc , toks ):
2830
- assert len (toks ) == 1
2831
- assert len (toks [0 ]) == 2
2832
2824
state = self .get_state ()
2833
-
2834
2825
thickness = state .font_output .get_underline_thickness (
2835
2826
state .font , state .fontsize , state .dpi )
2836
- num , den = toks [0 ]
2837
-
2827
+ (num , den ), = toks
2838
2828
return self ._genfrac ('' , '' , thickness , self ._MathStyle .TEXTSTYLE ,
2839
2829
num , den )
2840
2830
2841
2831
def dfrac (self , s , loc , toks ):
2842
- assert len (toks ) == 1
2843
- assert len (toks [0 ]) == 2
2844
2832
state = self .get_state ()
2845
-
2846
2833
thickness = state .font_output .get_underline_thickness (
2847
2834
state .font , state .fontsize , state .dpi )
2848
- num , den = toks [0 ]
2849
-
2835
+ (num , den ), = toks
2850
2836
return self ._genfrac ('' , '' , thickness , self ._MathStyle .DISPLAYSTYLE ,
2851
2837
num , den )
2852
2838
2853
2839
def binom (self , s , loc , toks ):
2854
- assert len (toks ) == 1
2855
- assert len (toks [0 ]) == 2
2856
- num , den = toks [0 ]
2857
-
2840
+ (num , den ), = toks
2858
2841
return self ._genfrac ('(' , ')' , 0.0 , self ._MathStyle .TEXTSTYLE ,
2859
2842
num , den )
2860
2843
2861
2844
def sqrt (self , s , loc , toks ):
2862
- root , body = toks [ 0 ]
2845
+ ( root , body ), = toks
2863
2846
state = self .get_state ()
2864
2847
thickness = state .font_output .get_underline_thickness (
2865
2848
state .font , state .fontsize , state .dpi )
@@ -2899,10 +2882,7 @@ def sqrt(self, s, loc, toks):
2899
2882
return [hlist ]
2900
2883
2901
2884
def overline (self , s , loc , toks ):
2902
- assert len (toks ) == 1
2903
- assert len (toks [0 ]) == 1
2904
-
2905
- body = toks [0 ][0 ]
2885
+ (body ,), = toks
2906
2886
2907
2887
state = self .get_state ()
2908
2888
thickness = state .font_output .get_underline_thickness (
0 commit comments