26
26
from sage .sets .family import Family
27
27
from sage .sets .non_negative_integers import NonNegativeIntegers
28
28
29
+
29
30
class QuantumOscillatorAlgebra (CombinatorialFreeModule ):
30
31
r"""
31
32
The quantum oscillator algebra.
@@ -159,7 +160,7 @@ def __init__(self, q, R):
159
160
CombinatorialFreeModule .__init__ (self , R , indices , category = cat )
160
161
self ._assign_names (('ap' , 'am' , 'k' , 'ki' ))
161
162
162
- def _repr_ (self ):
163
+ def _repr_ (self ) -> str :
163
164
r"""
164
165
Return a string representation of ``self``.
165
166
@@ -217,7 +218,7 @@ def algebra_generators(self):
217
218
return Family (d )
218
219
219
220
@cached_method
220
- def gens (self ):
221
+ def gens (self ) -> tuple :
221
222
r"""
222
223
Return the generators of ``self``.
223
224
@@ -230,7 +231,7 @@ def gens(self):
230
231
return tuple (self .algebra_generators ())
231
232
232
233
@cached_method
233
- def one_basis (self ):
234
+ def one_basis (self ) -> tuple :
234
235
r"""
235
236
Return the index of the basis element of `1`.
236
237
@@ -242,7 +243,7 @@ def one_basis(self):
242
243
"""
243
244
return (ZZ .zero (), ZZ .zero ())
244
245
245
- def some_elements (self ):
246
+ def some_elements (self ) -> tuple :
246
247
r"""
247
248
Return some elements of ``self``.
248
249
@@ -275,7 +276,7 @@ def fock_space_representation(self):
275
276
"""
276
277
return FockSpaceRepresentation (self )
277
278
278
- def _repr_term (self , m ):
279
+ def _repr_term (self , m ) -> str :
279
280
r"""
280
281
Return a string representation of the basis element indexed by ``m``.
281
282
@@ -438,7 +439,7 @@ def product_on_basis(self, ml, mr):
438
439
return self .element_class (self , {(a , kl + kr + i ): c * coeff for i , c in enumerate (kp ) if c })
439
440
440
441
class Element (CombinatorialFreeModule .Element ):
441
- def inverse (self ):
442
+ def __invert__ (self ):
442
443
r"""
443
444
Return the inverse if ``self`` is a basis element.
444
445
@@ -474,16 +475,14 @@ def inverse(self):
474
475
O = self .parent ()
475
476
return O .element_class (O , {(a , - k ): coeff .inverse_of_unit ()})
476
477
477
- __invert__ = inverse
478
-
479
478
480
479
class FockSpaceRepresentation (CombinatorialFreeModule ):
481
- """
480
+ r """
482
481
The unique Fock space representation of the
483
482
:class:`~sage.algebras.quantum_oscillator.QuantumOscillatorAlgebra`.
484
483
"""
485
484
def __init__ (self , O ):
486
- """
485
+ r """
487
486
Initialize ``self``.
488
487
489
488
EXAMPLES::
@@ -498,7 +497,7 @@ def __init__(self, O):
498
497
latex_bracket = [r'\lvert' , r'\rangle' ])
499
498
500
499
def _test_representation (self , ** options ):
501
- """
500
+ r """
502
501
Test that ``self`` is a representation of the quantum
503
502
oscillator algebra.
504
503
@@ -519,8 +518,8 @@ def _test_representation(self, **options):
519
518
return
520
519
tester .assertEqual ((a * b )* elt , a * (b * elt ))
521
520
522
- def _repr_ (self ):
523
- """
521
+ def _repr_ (self ) -> str :
522
+ r """
524
523
Return a string representation of ``self``.
525
524
526
525
EXAMPLES::
@@ -559,7 +558,7 @@ def vacuum(self):
559
558
return self .basis ()[0 ]
560
559
561
560
def some_elements (self ):
562
- """
561
+ r """
563
562
Return some elements of ``self``.
564
563
565
564
EXAMPLES::
@@ -574,7 +573,7 @@ def some_elements(self):
574
573
575
574
class Element (CombinatorialFreeModule .Element ):
576
575
def _acted_upon_ (self , scalar , self_on_left = True ):
577
- """
576
+ r """
578
577
Return the action of ``scalar`` on ``self``.
579
578
580
579
EXAMPLES::
0 commit comments