17
17
# https://www.gnu.org/licenses/
18
18
# ****************************************************************************
19
19
from __future__ import annotations
20
- from sage . combinat . free_module import CombinatorialFreeModule
20
+
21
21
from sage .categories .algebras import Algebras
22
- from sage .misc . cachefunc import cached_method
22
+ from sage .combinat . free_module import CombinatorialFreeModule
23
23
from sage .combinat .integer_vector_weighted import WeightedIntegerVectors
24
- from sage .rings .ring import Algebra
25
- from sage .misc .functional import is_odd , is_even
26
- from sage .sets .disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets
27
- from sage .sets .condition_set import ConditionSet
24
+ from sage .misc .cachefunc import cached_method
25
+ from sage .misc .functional import is_even
28
26
from sage .rings .integer_ring import ZZ
27
+ from sage .sets .condition_set import ConditionSet
28
+ from sage .sets .disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets
29
29
30
30
31
- class FiniteGCAlgebra (CombinatorialFreeModule , Algebra ):
31
+ class FiniteGCAlgebra (CombinatorialFreeModule ):
32
32
r"""
33
33
Finite dimensional graded commutative algebras.
34
34
@@ -165,7 +165,7 @@ def __classcall_private__(cls, base, names=None, degrees=None,
165
165
raise ValueError ("You must specify names or degrees" )
166
166
else :
167
167
n = len (degrees )
168
- names = tuple ('x{}' . format ( i ) for i in range (n ))
168
+ names = tuple (f 'x{ i } ' for i in range (n ))
169
169
elif isinstance (names , str ):
170
170
names = tuple (names .split (',' ))
171
171
n = len (names )
@@ -194,7 +194,6 @@ def __init__(self, base, names, degrees, max_degree,
194
194
sage: TestSuite(A).run()
195
195
sage: A = GradedCommutativeAlgebra(QQ, ('x','y','z','t'), [1,2,3,4], max_degree=10)
196
196
sage: TestSuite(A).run()
197
-
198
197
"""
199
198
from sage .arith .misc import gcd
200
199
@@ -220,7 +219,7 @@ def __init__(self, base, names, degrees, max_degree,
220
219
sorting_key = sorting_key ,
221
220
category = category )
222
221
223
- def _valid_index (self , w ):
222
+ def _valid_index (self , w ) -> bool :
224
223
r"""
225
224
Return whether ``w`` is a valid index; no multiple powers in odd
226
225
degrees.
@@ -234,11 +233,10 @@ def _valid_index(self, w):
234
233
True
235
234
sage: A._valid_index(w2)
236
235
False
237
-
238
236
"""
239
- return not any (i > 1 for i , d in zip (w , self ._degrees ) if is_odd ( d ) )
237
+ return not any (i > 1 for i , d in zip (w , self ._degrees ) if d % 2 )
240
238
241
- def _repr_ (self ):
239
+ def _repr_ (self ) -> str :
242
240
"""
243
241
Return the string representation of ``self``.
244
242
@@ -249,7 +247,6 @@ def _repr_(self):
249
247
"Graded commutative algebra with generators ('x', 'y', 'z') in degrees (1, 2, 3) with maximal degree 8"
250
248
sage: A # indirect doctest
251
249
Graded commutative algebra with generators ('x', 'y', 'z') in degrees (1, 2, 3) with maximal degree 8
252
-
253
250
"""
254
251
desc = f'Graded commutative algebra with generators { self ._names } in '
255
252
desc += f'degrees { self ._degrees } with maximal degree { self ._max_deg } '
@@ -264,7 +261,6 @@ def ngens(self):
264
261
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(4,8,2), max_degree=10)
265
262
sage: A.ngens()
266
263
3
267
-
268
264
"""
269
265
return self .__ngens
270
266
@@ -327,7 +323,6 @@ def product_on_basis(self, w1, w2):
327
323
x*y^2*z
328
324
sage: A.product_on_basis(w2, w1)
329
325
-x*y^2*z
330
-
331
326
"""
332
327
grading = self ._weighted_vectors .grading
333
328
deg_left = grading (w1 )
@@ -375,11 +370,10 @@ def degree_on_basis(self, i):
375
370
sage: i = A._weighted_vectors([1,1,0])
376
371
sage: A.degree_on_basis(i)
377
372
6
378
-
379
373
"""
380
374
return self ._weighted_vectors .grading (i )
381
375
382
- def _repr_term (self , w ):
376
+ def _repr_term (self , w ) -> str :
383
377
r"""
384
378
Return the string representation of basis with index ``w``.
385
379
@@ -400,7 +394,6 @@ def _repr_term(self, w):
400
394
'x⌣y^2⌣z'
401
395
sage: x*y^2*z # indirect doctest
402
396
x⌣y^2⌣z
403
-
404
397
"""
405
398
# Trivial case:
406
399
if sum (w ) == 0 :
@@ -416,7 +409,7 @@ def _repr_term(self, w):
416
409
terms .append (self ._names [i ] + f'^{ w [i ]} ' )
417
410
return self ._mul_symbol .join (terms )
418
411
419
- def _latex_term (self , w ):
412
+ def _latex_term (self , w ) -> str :
420
413
r"""
421
414
Return the LaTeX representation of basis with index ``w``.
422
415
@@ -436,7 +429,6 @@ def _latex_term(self, w):
436
429
'x\\smile y^{2}\\smile z'
437
430
sage: latex(x*y^2*z) # indirect doctest
438
431
x\smile y^{2}\smile z
439
-
440
432
"""
441
433
# Trivial case:
442
434
if sum (w ) == 0 :
@@ -463,10 +455,8 @@ def algebra_generators(self):
463
455
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(4,8,2), max_degree=10)
464
456
sage: A.algebra_generators()
465
457
Family (x, y, z)
466
-
467
458
"""
468
459
from sage .sets .family import Family
469
-
470
460
return Family (self .gens ())
471
461
472
462
@cached_method
@@ -483,7 +473,6 @@ def one_basis(self):
483
473
1
484
474
sage: A.one() # indirect doctest
485
475
1
486
-
487
476
"""
488
477
n = len (self ._degrees )
489
478
return self ._weighted_vectors ([0 for _ in range (n )])
@@ -521,7 +510,6 @@ def gen(self, i):
521
510
y
522
511
sage: A.gen(2)
523
512
z
524
-
525
513
"""
526
514
return self .gens ()[i ]
527
515
@@ -534,7 +522,6 @@ def maximal_degree(self):
534
522
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=(1,2,3), max_degree=8)
535
523
sage: A.maximal_degree()
536
524
8
537
-
538
525
"""
539
526
return self ._max_deg
540
527
0 commit comments