Skip to content

Commit c6bf497

Browse files
author
Release Manager
committed
gh-36985: ModulesWithBasis.ParentMethods.cardinality() for 0 dimensional modules
<!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> Currently this is not handled properly as $\infty^0$ is not well-defined but we know a 0 dimensional free module is $\\{0\\}$ with one element. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36985 Reported by: Travis Scrimshaw Reviewer(s): Darij Grinberg
2 parents 338a8ea + 23bef33 commit c6bf497

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=05115739db242cb5a48ae17f97d06b179fc70334
3-
md5=adc8208885e6be527b089b682079c464
4-
cksum=3321256447
2+
sha1=4fe91fa22748b17eca220ba95748d603003e5d04
3+
md5=05a48b56c39217c02ecfc2fff86b3e78
4+
cksum=743962125
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e95536ccbad199de456e804968a775f2744e4bff
1+
a8b72d73e2c6146ef64e627d7a88732b57952292

src/sage/categories/modules_with_basis.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,10 @@ def cardinality(self):
996996
sage: S = SymmetricGroupAlgebra(QQ, 4)
997997
sage: S.cardinality()
998998
+Infinity
999-
sage: S = SymmetricGroupAlgebra(GF(2), 4) # not tested
1000-
sage: S.cardinality() # not tested
999+
sage: S = SymmetricGroupAlgebra(GF(2), 4)
1000+
sage: S.cardinality()
10011001
16777216
1002-
sage: S.cardinality().factor() # not tested
1002+
sage: S.cardinality().factor()
10031003
2^24
10041004
10051005
sage: # needs sage.modules
@@ -1013,10 +1013,19 @@ def cardinality(self):
10131013
sage: s = SymmetricFunctions(GF(2)).s() # needs sage.combinat sage.modules
10141014
sage: s.cardinality() # needs sage.combinat sage.modules
10151015
+Infinity
1016+
1017+
sage: M = CombinatorialFreeModule(QQ, [])
1018+
sage: M.dimension()
1019+
0
1020+
sage: M.cardinality()
1021+
1
10161022
"""
10171023
from sage.rings.infinity import Infinity
10181024
if self.dimension() == Infinity:
10191025
return Infinity
1026+
if self.dimension() == 0:
1027+
from sage.rings.integer_ring import ZZ
1028+
return ZZ.one()
10201029
return self.base_ring().cardinality() ** self.dimension()
10211030

10221031
def is_finite(self):

0 commit comments

Comments
 (0)