sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 478 forks source link

Multivariate polynomial ring ideal reduce() method does not work on integer #38560

Open user202729 opened 2 months ago

user202729 commented 2 months ago

Steps To Reproduce

sage: R.<x, y> = QQ[]
sage: R.ideal(x, y).reduce(1)

Expected Behavior

Returns 1.

Actual Behavior

AttributeError: 'sage.rings.integer.Integer' object has no attribute 'reduce'

Additional Information

No response

Environment

- **OS**: Linux
- **Sage Version**: `'SageMath version 10.4, Release Date: 2024-07-19'`

Checklist

maxale commented 2 months ago

It's not a bug since reduce() here expects a polynomial not a number. Use R(1) or R.one() instead of 1.

user202729 commented 2 months ago

But 1 can be naturally converted to R(1). Besides, it does work with univariate polynomial ring

sage: R.<x> = QQ[]
sage: R.ideal(x).reduce(1)
1

In any case I see no harm converting the argument to an element of R inside .reduce() if it isn't already one. Would make it more convenient to use.

maxale commented 2 months ago

Then it should be RFE not a bug.