Skip to content

Commit

Permalink
gh-36985: ModulesWithBasis.ParentMethods.cardinality() for 0 dimensio…
Browse files Browse the repository at this point in the history
…nal 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
  • Loading branch information
Release Manager committed Jan 13, 2024
2 parents 338a8ea + 23bef33 commit c6bf497
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=05115739db242cb5a48ae17f97d06b179fc70334
md5=adc8208885e6be527b089b682079c464
cksum=3321256447
sha1=4fe91fa22748b17eca220ba95748d603003e5d04
md5=05a48b56c39217c02ecfc2fff86b3e78
cksum=743962125
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e95536ccbad199de456e804968a775f2744e4bff
a8b72d73e2c6146ef64e627d7a88732b57952292
15 changes: 12 additions & 3 deletions src/sage/categories/modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,10 @@ def cardinality(self):
sage: S = SymmetricGroupAlgebra(QQ, 4)
sage: S.cardinality()
+Infinity
sage: S = SymmetricGroupAlgebra(GF(2), 4) # not tested
sage: S.cardinality() # not tested
sage: S = SymmetricGroupAlgebra(GF(2), 4)
sage: S.cardinality()
16777216
sage: S.cardinality().factor() # not tested
sage: S.cardinality().factor()
2^24
sage: # needs sage.modules
Expand All @@ -1013,10 +1013,19 @@ def cardinality(self):
sage: s = SymmetricFunctions(GF(2)).s() # needs sage.combinat sage.modules
sage: s.cardinality() # needs sage.combinat sage.modules
+Infinity
sage: M = CombinatorialFreeModule(QQ, [])
sage: M.dimension()
0
sage: M.cardinality()
1
"""
from sage.rings.infinity import Infinity
if self.dimension() == Infinity:
return Infinity
if self.dimension() == 0:
from sage.rings.integer_ring import ZZ
return ZZ.one()
return self.base_ring().cardinality() ** self.dimension()

def is_finite(self):
Expand Down

0 comments on commit c6bf497

Please sign in to comment.