Skip to content

Commit c3e76e1

Browse files
author
Release Manager
committed
gh-37306: Fix random test failures in `number_field_element_quadratic` Fix #37296. Add `warnings.filterwarnings` to ignore `DeprecationWarning` in the failing doctest, since it is an unrelated issue and does not affect correctness of the test. To be more specific, the warning only appears when the rounding error will change, i.e. on $n + \frac{1}{2}$ (I believe). Here are some runs: ```python sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) <ipython-input-12-179149e36f01>:1: DeprecationWarning: the default rounding for rationals, currently `away`, will be changed to `even`. See #35473 for details. a = QQ.random_element(Integer(3), Integer(3)); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) <ipython-input-14-179149e36f01>:1: DeprecationWarning: the default rounding for rationals, currently `away`, will be changed to `even`. See #35473 for details. a = QQ.random_element(Integer(3), Integer(3)); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) sage: a = QQ.random_element(3, 3); _ = round(a) ``` URL: #37306 Reported by: grhkm21 Reviewer(s): Sebastian A. Spindler
2 parents c1f5625 + fdc7fd7 commit c3e76e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sage/rings/number_field/number_field_element_quadratic.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,8 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
23872387
23882388
TESTS::
23892389
2390+
sage: import warnings
2391+
sage: warnings.filterwarnings("ignore", category=DeprecationWarning)
23902392
sage: K2.<sqrt2> = QuadraticField(2)
23912393
sage: K3.<sqrt3> = QuadraticField(3)
23922394
sage: K5.<sqrt5> = QuadraticField(5)
@@ -2399,8 +2401,6 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
23992401
....: assert round(a+b*sqrt(2.)) == round(a+b*sqrt2), (a, b)
24002402
....: assert round(a+b*sqrt(3.)) == round(a+b*sqrt3), (a, b)
24012403
....: assert round(a+b*sqrt(5.)) == round(a+b*sqrt5), (a, b)
2402-
doctest...: DeprecationWarning: the default rounding for rationals, currently `away`, will be changed to `even`.
2403-
See https://github.com/sagemath/sage/issues/35473 for details.
24042404
"""
24052405
n = self.floor()
24062406
test = 2 * (self - n).abs()

0 commit comments

Comments
 (0)