@@ -279,7 +279,7 @@ cdef class Farey:
279279 [ -3 1 ]
280280 [-40 13 ]
281281 """
282- gens_dict = {g:i+ 1 for i,g in enumerate (self .generators())}
282+ gens_dict = {g: i+ 1 for i, g in enumerate (self .generators())}
283283 ans = []
284284 for pm in self .pairing_matrices():
285285 a, b, c, d = pm.matrix().list()
@@ -331,7 +331,7 @@ cdef class Farey:
331331 sage: ( -g. matrix( )) . is_one( )
332332 True
333333 """
334- for i,g in enumerate (self .generators()):
334+ for i, g in enumerate (self .generators()):
335335 m = g.matrix()
336336 if (- m).is_one():
337337 return [i + 1 ]
@@ -342,15 +342,17 @@ cdef class Farey:
342342 return 3 * [i + 1 ]
343343 return []
344344
345- def word_problem (self , M , output = ' standard' , check = True ):
345+ def word_problem (self , M , output = ' standard' , check = True ):
346346 r """
347347 Solve the word problem ( up to sign) using this Farey symbol.
348348
349349 INPUT:
350350
351351 - ``M`` -- an element `M` of `\S L_2( \Z Z) `
352- - ``output`` -- ( default: ``'standard'``) should be one of ``'standard'``,
353- ``'syllables'``, ``'gens'``.
352+
353+ - ``output`` -- ( default: ``'standard'``) should be one of
354+ ``'standard'``, ``'syllables'``, ``'gens'``.
355+
354356 - ``check`` -- boolean ( default: ``True``) ; whether to check for
355357 correct input and output
356358
@@ -359,17 +361,17 @@ cdef class Farey:
359361 A solution to the word problem for the matrix `M`.
360362 The format depends on the ``output`` parameter, as follows.
361363
362- - ``standard`` returns the so called the Tietze representation,
363- consists of a tuple of nonzero integers `i`, where if `i` > 0
364- then it indicates the `i`-th generator ( that is, ``self . generators ( ) [ 0 ]``
365- would correspond to `i` = 1 ) , and if `i` < 0 then it indicates
366- the inverse of the `i`-th generator.
367- - ``syllables`` returns a tuple of tuples of the form ` ( i,n ) `, where
368- `( i,n) ` represents ``self. generators( ) [i ] ^ n``,
364+ - ``' standard' `` returns the so called Tietze representation,
365+ which consists of a tuple of nonzero integers. A positive
366+ integer `i` indicates the `i`-th generator ( that is,
367+ ``self . generators ( ) [ i-1 ]`` ) , while a negative integer `i`
368+ indicates the inverse of the `i`-th generator.
369+ - ``' syllables' `` returns a tuple of tuples of the form
370+ `( i, n ) `, where ` ( i, n) ` represents ``self. generators( ) [i ] ^ n``,
369371 whose product equals `M` up to sign.
370- - ``gens`` returns tuple of tuples of the form `( g,n) `,
371- ` ( g,n ) ` such that the product of the matrices `g ^ n`
372- equals `M` up to sign.
372+ - ``' gens' `` returns a tuple of pairs `( g, n) `, where `g` is a
373+ matrix and `n` an integer, such that the product of the
374+ matrices `g ^ n` equals `M` up to sign.
373375
374376 EXAMPLES::
375377
@@ -385,7 +387,7 @@ cdef class Farey:
385387 sage: g
386388 [-5048053 586303 ]
387389 [-5558280 645563 ]
388- sage: F. word_problem( g, output = 'gens')
390+ sage: F. word_problem( g, output= 'gens')
389391 ((
390392 [109 -10 ]
391393 [120 -11 ], 1
@@ -402,7 +404,7 @@ cdef class Farey:
402404 [17 -2 ]
403405 [60 -7 ], 1
404406 ))
405- sage: F. word_problem( g, output = 'syllables')
407+ sage: F. word_problem( g, output= 'syllables')
406408 (( 3, 1) , ( 10, 2) , ( 8, -1) , ( 5, 1))
407409
408410 TESTS:
@@ -413,7 +415,7 @@ cdef class Farey:
413415 sage: G = Gamma0( 10)
414416 sage: F = G. farey_symbol( )
415417 sage: g = G( [-701,-137,4600,899 ])
416- sage: g1 = prod( F. generators( ) [i ]** a for i,a in F. word_problem( g, output = 'syllables'))
418+ sage: g1 = prod( F. generators( ) [i ]** a for i, a in F. word_problem( g, output= 'syllables'))
417419 sage: g == g1
418420 True
419421
@@ -426,15 +428,16 @@ cdef class Farey:
426428 Check that :issue:`20347` is solved::
427429
428430 sage: from sage. misc. misc_c import prod
429- sage: G = ArithmeticSubgroup_Permutation( S2="( 1,2) ( 3,4) ",S3="( 1,2,3) ")
431+ sage: G = ArithmeticSubgroup_Permutation( S2="( 1,2) ( 3,4) ", S3="( 1,2,3) ")
430432 sage: S = G. farey_symbol( )
431- sage: g1,g2 = S. generators( )
433+ sage: g1, g2 = S. generators( )
432434 sage: g = g1^ 3 * g2^ -2 * g1 * g2
433435 sage: S. word_problem( g)
434436 ( 2, 2, 2, 1, 1, 1, 2, 1, 2)
435- sage: h = prod( S. generators( ) [i ]** a for i,a in S. word_problem( g, output = 'syllables'))
437+ sage: h = prod( S. generators( ) [i ]** a for i, a in S. word_problem( g, output= 'syllables'))
436438 sage: g == h
437439 True
440+
438441 """
439442 if output not in [' standard' , ' syllables' , ' gens' ]:
440443 raise ValueError (' Unrecognized output format' )
@@ -464,7 +467,7 @@ cdef class Farey:
464467 if sgn == - 1 :
465468 beta, mbeta = mbeta, beta
466469
467- gens_dict = {g:i+ 1 for i,g in enumerate (self .generators())}
470+ gens_dict = {g: i+ 1 for i, g in enumerate (self .generators())}
468471 extra_tietze = []
469472 if beta.is_one():
470473 found = True
@@ -501,13 +504,13 @@ cdef class Farey:
501504 for i in range (len (tietze)):
502505 t = tietze[i]
503506 tmp = tmp * gens[t- 1 ] if t > 0 else tmp * gens[- t- 1 ]**- 1
504- assert tmp.matrix() == M.matrix(),' %s %s %s ' % (tietze, tmp.matrix(),M.matrix())
507+ assert tmp.matrix() == M.matrix(), ' %s %s %s ' % (tietze, tmp.matrix(), M.matrix())
505508 if output == ' standard' :
506509 return tuple (tietze)
507510 if output == ' syllables' :
508- return tuple ((a- 1 ,len (list (g))) if a > 0 else (- a- 1 ,- len (list (g))) for a,g in groupby(tietze))
511+ return tuple ((a- 1 , len (list (g))) if a > 0 else (- a- 1 , - len (list (g))) for a, g in groupby(tietze))
509512 else : # output == 'gens'
510- return tuple ((gens[a- 1 ],len (list (g))) if a > 0 else (gens[- a- 1 ],- len (list (g))) for a, g in groupby(tietze))
513+ return tuple ((gens[a- 1 ], len (list (g))) if a > 0 else (gens[- a- 1 ], - len (list (g))) for a, g in groupby(tietze))
511514
512515 def __contains__ (self , M ):
513516 r """
@@ -594,9 +597,9 @@ cdef class Farey:
594597
595598 EXAMPLES::
596599
597- sage: FareySymbol( Gamma0( 11)) . _latex_( forced_format = 'plain')
600+ sage: FareySymbol( Gamma0( 11)) . _latex_( forced_format= 'plain')
598601 '\\ left( -\\ infty\\ underbrace{\\ quad}_{1} 0\\ underbrace{\\ quad}_{2} \\ frac{1}{3} \\ underbrace{\\ quad}_{3} \\ frac{1}{2} \\ underbrace{\\ quad}_{2} \\ frac{2}{3} \\ underbrace{\\ quad}_{3} 1\\ underbrace{\\ quad}_{1} \\ infty\\ right) '
599- sage: FareySymbol( Gamma0( 11)) . _latex_( forced_format = 'xymatrix')
602+ sage: FareySymbol( Gamma0( 11)) . _latex_( forced_format= 'xymatrix')
600603 '\\ begin{xy}\\ xymatrix{& -\\ infty \\ ar@{-}@/_1pc/[r ]_{1} & 0 \\ ar@{-}@/_1pc/[r ]_{2} & \\ frac{1}{3} \\ ar@{-}@/_1pc/[r ]_{3} & \\ frac{1}{2} \\ ar@{-}@/_1pc/[r ]_{2} & \\ frac{2}{3} \\ ar@{-}@/_1pc/[r ]_{3} & 1 \\ ar@{-}@/_1pc/[r ]_{1} & \\ infty }\\ end{xy}'
601604
602605 sage: 'xymatrix' in FareySymbol( Gamma0( 11)) . _latex_( )
0 commit comments