Skip to content

Commit 99fd4f4

Browse files
author
Release Manager
committed
gh-37283: Fix RegularSequence.subsequence for zero sequence <!-- ^^^^^ 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 --> <!-- 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. --> Fixes #37282 ### 📝 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. - [ ] 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! --> Cc: @dkrenn URL: #37283 Reported by: cheuberg Reviewer(s): cheuberg, Sebastian A. Spindler
2 parents 9a1a964 + 6b3480e commit 99fd4f4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sage/combinat/regular_sequence.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,12 @@ def subsequence(self, a, b):
762762
763763
sage: S.regenerated().subsequence(1, -4)
764764
2-regular sequence 0, 0, 0, 0, 1, 3, 6, 9, 12, 18, ...
765+
766+
Check that the zero sequence is handled correctly (issue:`37282`)
767+
::
768+
769+
sage: Seq2.zero().subsequence(1, 1)
770+
2-regular sequence 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
765771
"""
766772
from itertools import chain
767773
from sage.rings.integer_ring import ZZ
@@ -835,14 +841,16 @@ def matrix_row(r, c):
835841
d, f = rule[r, c]
836842
return [self.mu[f] if d == j else zero_M for j in kernel]
837843

844+
# We explicitly set the ring when creating vectors in order to avoid
845+
# problems with the zero sequence, see issue:`37282`.
838846
result = P.element_class(
839847
P,
840848
{r: Matrix.block([matrix_row(r, c) for c in kernel])
841849
for r in A},
842-
vector(chain.from_iterable(
850+
vector(P.coefficient_ring(), chain.from_iterable(
843851
b.get(c, 0) * self.left
844852
for c in kernel)),
845-
vector(chain.from_iterable(
853+
vector(P.coefficient_ring(), chain.from_iterable(
846854
(self.coefficient_of_n(c, multiply_left=False) if c >= 0 else zero_R)
847855
for c in kernel)))
848856

0 commit comments

Comments
 (0)