Skip to content

Commit 056c849

Browse files
author
Release Manager
committed
gh-39303: let the categories handle "is_commutative" for rings This makes sure that the method `is_commutative` for rings is handled by the category framework and not by the auld `Ring` class. Also adding annotations on some `is_commutative` methods ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. URL: #39303 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents d2e5f02 + d373f69 commit 056c849

File tree

12 files changed

+30
-35
lines changed

12 files changed

+30
-35
lines changed

src/doc/en/thematic_tutorials/coercion_and_categories.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ This base class provides a lot more methods than a general parent::
130130
'gen',
131131
'gens',
132132
'integral_closure',
133-
'is_commutative',
134133
'is_field',
135134
'krull_dimension',
136135
'ngens',

src/sage/algebras/clifford_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def one_basis(self):
844844
"""
845845
return FrozenBitset()
846846

847-
def is_commutative(self):
847+
def is_commutative(self) -> bool:
848848
"""
849849
Check if ``self`` is a commutative algebra.
850850

src/sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def is_associative(self):
497497
return True
498498

499499
@cached_method
500-
def is_commutative(self):
500+
def is_commutative(self) -> bool:
501501
"""
502502
Return ``True`` if ``self`` is commutative.
503503

src/sage/algebras/iwahori_hecke_algebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ def is_field(self, proof=True):
766766
"""
767767
return False
768768

769-
def is_commutative(self):
769+
def is_commutative(self) -> bool:
770770
"""
771771
Return whether this Iwahori-Hecke algebra is commutative.
772772

src/sage/algebras/steenrod/steenrod_algebra.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,10 +2827,12 @@ def gen(self, i=0):
28272827
tot += 1
28282828
return test
28292829

2830-
def is_commutative(self):
2830+
def is_commutative(self) -> bool:
28312831
r"""
28322832
Return ``True`` if ``self`` is graded commutative, as determined by the
2833-
profile function. In particular, a sub-Hopf algebra of the
2833+
profile function.
2834+
2835+
In particular, a sub-Hopf algebra of the
28342836
mod 2 Steenrod algebra is commutative if and only if there is
28352837
an integer `n>0` so that its profile function `e` satisfies
28362838

src/sage/categories/commutative_rings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ class CommutativeRings(CategoryWithAxiom):
4646
4747
sage: GroupAlgebra(CyclicPermutationGroup(3), QQ) in CommutativeRings() # not implemented, needs sage.groups sage.modules
4848
True
49+
50+
Some tests for the method ``is_commutative``::
51+
52+
sage: QQ.is_commutative()
53+
True
54+
sage: ZpCA(7).is_commutative() # needs sage.rings.padics
55+
True
56+
sage: A = QuaternionAlgebra(QQ, -1, -3, names=('i','j','k')); A # needs sage.combinat sage.modules
57+
Quaternion Algebra (-1, -3) with base ring Rational Field
58+
sage: A.is_commutative() # needs sage.combinat sage.modules
59+
False
4960
"""
5061
class ParentMethods:
5162
def is_commutative(self) -> bool:

src/sage/categories/finite_dimensional_algebras_with_basis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ def is_identity_decomposition_into_orthogonal_idempotents(self, l):
11431143
for f in l[:i]))
11441144

11451145
@cached_method
1146-
def is_commutative(self):
1146+
def is_commutative(self) -> bool:
11471147
"""
11481148
Return whether ``self`` is a commutative algebra.
11491149
@@ -1158,7 +1158,7 @@ def is_commutative(self):
11581158
True
11591159
"""
11601160
B = list(self.basis())
1161-
try: # See if 1 is a basis element, if so, remove it
1161+
try: # See if 1 is a basis element, if so, remove it
11621162
B.remove(self.one())
11631163
except ValueError:
11641164
pass

src/sage/categories/lie_algebras.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,11 @@ def is_abelian(self):
589589
zero = self.zero()
590590
return all(x._bracket_(y) == zero for x in G for y in G)
591591

592-
def is_commutative(self):
592+
def is_commutative(self) -> bool:
593593
"""
594-
Return if ``self`` is commutative. This is equivalent to ``self``
595-
being abelian.
594+
Return if ``self`` is commutative.
595+
596+
This is equivalent to ``self`` being abelian.
596597
597598
EXAMPLES::
598599

src/sage/categories/magmas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def is_field(self, proof=True):
398398
class Commutative(CategoryWithAxiom):
399399

400400
class ParentMethods:
401-
def is_commutative(self):
401+
def is_commutative(self) -> bool:
402402
"""
403403
Return ``True``, since commutative magmas are commutative.
404404

src/sage/rings/quotient_ring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def _latex_(self):
589589
"""
590590
return "%s/%s" % (latex.latex(self.cover_ring()), latex.latex(self.defining_ideal()))
591591

592-
def is_commutative(self):
592+
def is_commutative(self) -> bool:
593593
"""
594594
Tell whether this quotient ring is commutative.
595595

0 commit comments

Comments
 (0)