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

Ensure returned degree of multivariate polynomial is type Integer for MPolynomialRing_libsingular class #37605

Merged
merged 3 commits into from
Mar 31, 2024

Conversation

GiacomoPope
Copy link
Contributor

@GiacomoPope GiacomoPope commented Mar 13, 2024

Previously the degree of multivariate polynomials was returned as a python int instead of a SageMath Integer resulting in ugly ZZ(f.degree()) calls in various places.

This PR only focuses on the case of MPolynomialRing_libsingular to keep the noise of the PR as low as possible.

Future work: This same issue is in MPolynomial_polydict, I am happy to also do the work here, or make a new PR -- really I don't like sage returning a int when we dont have to.

Edit

This follow up work has been done in PR: #37611

Copy link
Contributor

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@GiacomoPope GiacomoPope changed the title Ensure returned degree of multivariate polynomial is an Integer Ensure returned degree of multivariate polynomial is type Integer for MPolynomialRing_libsingular class Mar 14, 2024
Copy link

Documentation preview for this PR (built with commit 49c34c4; changes) is ready! 🎉

vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 30, 2024
…e for `MPolynomial_polydict` class

    
This is a follow up PR to sagemath#37605
which ensures that `degree()` and `total_degree()` return a sage
`Integer` type instead of a python `int` for the `MPolynomial_polydict`
class.

However, `f.degrees()` returns something of type
`sage.rings.polynomial.polydict.ETuple` which has elements as `int`. I
am loathed to change this to return `Integer` in case of performance
regression, so the following status of `MPolynomial_polydict` is the
following:

```py
sage: R.<x, y> = PolynomialRing(QQbar)
sage: f = 1 + x + y^2
sage: type(f.degree())
<class 'sage.rings.integer.Integer'>
sage: type(f.degree(x))
<class 'sage.rings.integer.Integer'>
sage: type(f.degree(y))
<class 'sage.rings.integer.Integer'>
sage: type(f.total_degree())
<class 'sage.rings.integer.Integer'>
sage: type(f.degrees())
<class 'sage.rings.polynomial.polydict.ETuple'>
sage: type(f.degrees()[0])
<class 'int'>
```

I would like advice on how to proceed with the `degrees()` function. Is
leaving it in it's current state OK?

Fixes sagemath#37603
    
URL: sagemath#37611
Reported by: Giacomo Pope
Reviewer(s): Giacomo Pope, grhkm21
@vbraun vbraun merged commit 3ee8402 into sagemath:develop Mar 31, 2024
13 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 31, 2024
@GiacomoPope GiacomoPope deleted the multivariate_degree_as_integer branch April 1, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants