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

Finish changing Rational's round method default rounding to even #39486

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

user202729
Copy link
Contributor

Follow-up to #35756 .

(As is, the warning cannot be suppressed)

Related: #37306, #21935

There's a little (large??) problem: previously K2.<sqrt2> = QuadraticField(2); K2(9/2).round() returns 5 without a warning (because #35756 forget to print the deprecation). Should we add the deprecation first then change this next year?

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Feb 10, 2025

Documentation preview for this PR (built with commit 774b89d; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@vneiger
Copy link
Contributor

vneiger commented Feb 10, 2025

In fact, I would say the deprecation acts as intended, cf DeprecationWarning :
Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by code in main).

Therefore, since it has been about 18 months since the deprecation introduced in #35756, it could indeed be the right time to actually make the change (from default away to even).

@vneiger
Copy link
Contributor

vneiger commented Feb 10, 2025

It seems to me that the failing doctests are not linked to the changes here (one I cannot reproduce, and the other one I can reproduce but already without the changes of this PR). The changes look good to me.

@vneiger
Copy link
Contributor

vneiger commented Feb 10, 2025

Another set of eyes may be useful before a positive review. Maybe @mezzarobba who had also contributed to #35756 ?

@mezzarobba
Copy link
Member

No objections!

@vneiger vneiger added s: positive review sd128 tickets of Sage Days 128 Le Teich and removed s: needs review labels Feb 11, 2025
vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 18, 2025
sagemathgh-39486: Finish changing Rational's round method default rounding to even
    
Follow-up to sagemath#35756 .

(As is, the warning cannot be suppressed)

Related: sagemath#37306,
sagemath#21935

There's a little (large??) problem: previously `K2.<sqrt2> =
QuadraticField(2); K2(9/2).round()` returns `5` **without** a warning
(because sagemath#35756 forget to print the deprecation). Should we add the
deprecation first **then** change this next year?

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [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#39486
Reported by: user202729
Reviewer(s): Vincent Neiger
@vbraun vbraun merged commit 34b7f90 into sagemath:develop Feb 21, 2025
20 of 23 checks passed
@user202729
Copy link
Contributor Author

Check failure on line 2408 in src/sage/rings/number_field/number_field_element_quadratic.pyx


GitHub Actions
/ Conda (ubuntu, Python 3.12)
Failed example:
Failed example:: Exception raised:
Traceback (most recent call last):
  File "/home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 729, in _run
    self.compile_and_execute(example, compiler, test.globs)
  File "/home/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1153, in compile_and_execute
    exec(compiled, globs)
  File "<doctest sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic.round[8]>", line 7, in <module>
    assert round(a+b*sqrt(RealNumber('2.'))) == round(a+b*sqrt2), (a, b)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: (-989/2, 0)

From CI: https://github.com/sagemath/sage/pull/39687/files

More investigation needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sd128 tickets of Sage Days 128 Le Teich
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants