Skip to content

Commit

Permalink
Get rid of more SageMath DeprecationWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDunfield committed Jan 20, 2025
1 parent f9aa8dc commit cbbef94
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/exterior_to_link/barycentric_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from ..snap.t3mlite.simplex import *
from .rational_linear_algebra import Matrix, Vector3, Vector4
from .rational_linear_algebra import Matrix, Vector3, Vector4, rational_round
from . import pl_utils


Expand Down Expand Up @@ -185,7 +185,7 @@ def round(self, max_denom=2**32, force=False):
v = []
for y in max_denom * self.vector:
if y != 0:
y = max(y.round(), 1)
y = max(rational_round(y), 1)
v.append(y)

# Should be just Vector4(v)/sum(v)
Expand Down
7 changes: 7 additions & 0 deletions python/exterior_to_link/rational_linear_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
if sage_helper._within_sage and not use_pari_even_inside_sage:
from ..sage_helper import QQ, RR, vector, matrix, VectorSpace

def rational_round(x):
# This is just to suppress a deprecation warning.
return x.round(mode='even')

def rational_sqrt(x):
"""
Given a nonnegative rational x, return a rational r which is close to
Expand Down Expand Up @@ -58,6 +62,9 @@ def Matrix(entries):
from ..snap.t3mlite import linalg
QQ = linalg.pari

def rational_round(x):
return x.round()

def rational_sqrt(x):
"""
Given a nonnegative rational x, return a rational r which is close to
Expand Down
2 changes: 1 addition & 1 deletion python/sage_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def sage_method(function):
from sage.rings.real_mpfr import RealField, RealNumber, RR

from sage.rings.complex_interval_field import ComplexIntervalField
from sage.rings.real_mpfi import is_RealIntervalFieldElement, RealIntervalField
from sage.rings.real_mpfi import RealIntervalFieldElement, RealIntervalField
from sage.rings.real_mpfr import RealNumber, RealField_class
from sage.structure.sage_object import SageObject

Expand Down
4 changes: 2 additions & 2 deletions python/verify/upper_halfspace/finite_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if _within_sage:
import sage
from ...sage_helper import matrix, sqrt, is_RealIntervalFieldElement, Infinity
from ...sage_helper import matrix, sqrt, RealIntervalFieldElement, Infinity

from .extended_matrix import ExtendedMatrix

Expand Down Expand Up @@ -167,7 +167,7 @@ def cosh_dist(self, other):
#
RIF = r.parent()
if _within_sage:
if is_RealIntervalFieldElement(r):
if isinstance(r, RealIntervalFieldElement):
return r.intersection(RIF(1, Infinity))
if r < 1.0:
return RIF(1.0)
Expand Down

0 comments on commit cbbef94

Please sign in to comment.