Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate_neg() fails on LaurentSeriesRing(QQ) when valuation is positive #39710

Closed
user202729 opened this issue Mar 15, 2025 · 3 comments · Fixed by #39711
Closed

truncate_neg() fails on LaurentSeriesRing(QQ) when valuation is positive #39710

user202729 opened this issue Mar 15, 2025 · 3 comments · Fixed by #39711

Comments

@user202729
Copy link
Contributor

sage: S.<t> = LaurentSeriesRing(QQ)
sage: (t^-2+t^-1+1+t+t^2).truncate_neg(-1)
t^-1 + 1 + t + t^2
sage: (t^-2+t^-1+1+t+t^2).truncate_neg(1)
t + t^2
sage: (t+t^2).truncate_neg(-1)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[40], line 1
----> 1 (t+t**Integer(2)).truncate_neg(-Integer(1))

File laurent_series_ring_element.pyx:1085, in sage.rings.laurent_series_ring_element.LaurentSeries.t
runcate_neg()

File power_series_poly.pyx:614, in sage.rings.power_series_poly.PowerSeries_poly.__rshift__()

File polynomial_rational_flint.pyx:827, in sage.rings.polynomial.polynomial_rational_flint.Polynomia
l_rational_flint.__rshift__()

OverflowError: can't convert negative value to unsigned long


sage: (t+t^2).truncate_neg(1)
t + t^2
@tscrim
Copy link
Collaborator

tscrim commented Mar 17, 2025

The problem is that truncate_neg is starting from a point less than the valuation (in which case, it should just return the original series).

@5iri
Copy link

5iri commented Mar 17, 2025

Hi!

What exactly is left to be done here?

@tscrim
Copy link
Collaborator

tscrim commented Mar 17, 2025

The optimization noted in #39711.

vbraun pushed a commit to vbraun/sage that referenced this issue Mar 19, 2025
sagemathgh-39711: Allow negative shift for flint rational polynomial
    
Fixes sagemath#39710

Note that the behavior is compatible with the existing behavior of e.g.
`ZZ[]`.

### 📝 Checklist

- [x] The title is concise and informative.
- [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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39711
Reported by: user202729
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 22, 2025
sagemathgh-39711: Allow negative shift for flint rational polynomial
    
Fixes sagemath#39710

Note that the behavior is compatible with the existing behavior of e.g.
`ZZ[]`.

### 📝 Checklist

- [x] The title is concise and informative.
- [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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39711
Reported by: user202729
Reviewer(s): Travis Scrimshaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants