Skip to content

Commit

Permalink
♻️ Fixed DeprecationWarning.
Browse files Browse the repository at this point in the history
  - Changed the use of is_FractionField to isinstance(..., FractionField_generic)
  - See sagemath/sage#38128 for details
  • Loading branch information
Antonio-JP committed Jul 8, 2024
1 parent f14f7b1 commit 7203841
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dalgebra/commutators/ideals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from sage.categories.pushout import pushout
from sage.misc.cachefunc import cached_method
from sage.parallel.multiprocessing_sage import Pool
from sage.rings.fraction_field import is_FractionField
from sage.rings.fraction_field import FractionField_generic
from sage.rings.integer_ring import ZZ
from sage.rings.ideal import Ideal_generic as Ideal, Ideal as ideal
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
Expand Down Expand Up @@ -151,7 +151,7 @@ def diff_parent(self, origin):
r'''Recreate the differential structure over the :func:`final_parent` for this solution branch.'''
if is_DPolynomialRing(origin):
output = DPolynomialRing(self.diff_parent(origin.base()), origin.variable_names())
elif is_FractionField(origin) and origin in _DRings:
elif isinstance(origin, FractionField_generic) and origin in _DRings:
output = self.diff_parent(origin.base()).fraction_field()
else:
imgs_of_gens = {str(v): self.parent()(origin(str(v)).derivative()) if v in origin else 0 for v in self.final_parent().gens()}
Expand All @@ -178,7 +178,7 @@ def eval(self, element):
return element(**self.__solution) # this should evaluate coefficients and monomials

# case of coefficients
if is_FractionField(element.parent()): # case of fractions
if isinstance(element.parent(), FractionField_generic): # case of fractions
numer = self.eval(element.numerator())
denom = self.eval(element.denominator())
return numer / denom
Expand Down
10 changes: 5 additions & 5 deletions dalgebra/commutators/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from collections.abc import Sequence as ListType

from sage.arith.misc import GCD as gcd
from sage.rings.fraction_field import is_FractionField
from sage.rings.fraction_field import FractionField_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.polynomial_element_generic import Polynomial
from sage.rings.polynomial.multi_polynomial_element import MPolynomial
Expand Down Expand Up @@ -113,11 +113,11 @@ def spectral_operators(L: DPolynomial, P: DPolynomial, name_lambda: str = "lambd
raise TypeError(f"[spectral] Method only implemented with same parent for operators.")

## We extract the main polynomial ring / base field
PR = DR.base() # this is a wrapped of `F[x]`
R = PR.wrapped # we removed the differential structure
PR = DR.base() # this is a wrapped of `F[x]` or a Fraction Field of such thing
R = PR.base().wrapped if isinstance(PR, FractionField_generic) else PR.wrapped # we removed the differential structure

## We check if the ring `R` is a FractionField or not
was_fraction_field = is_FractionField(R)
was_fraction_field = isinstance(R, FractionField_generic)
R = R.base() if was_fraction_field else R

## We treat the base ring `R`
Expand Down Expand Up @@ -151,7 +151,7 @@ def spectral_operators(L: DPolynomial, P: DPolynomial, name_lambda: str = "lambd
def __simplify(element, curve):
r'''Reduces the element with the generator of a curve'''
P = element.parent()
if is_FractionField(P): # element is a rational function
if isinstance(P, FractionField_generic): # element is a rational function
return __simplify(element.numerator(), curve) / __simplify(element.denominator(), curve)
return element % curve

Expand Down

0 comments on commit 7203841

Please sign in to comment.