Skip to content

Commit

Permalink
sagemathgh-38289: Deprecate is_FunctionFieldElement, `is_FunctionFi…
Browse files Browse the repository at this point in the history
…eldElement`

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Part of:
- sagemath#32414

### 📝 Checklist

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

- [x] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [x] 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

<!-- 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#38289
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Aug 1, 2024
2 parents ec91fb2 + 53863a1 commit 9cec969
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class initialization directly.
from sage.rings.finite_rings.integer_mod_ring import Zmod
from sage.rings.fraction_field import FractionField, FractionField_generic, FractionField_1poly_field
from sage.rings.fraction_field_element import FractionFieldElement
from sage.rings.function_field.function_field import is_FunctionField
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.flatten import FlatteningMorphism, UnflatteningMorphism
Expand Down Expand Up @@ -4534,7 +4533,7 @@ def preperiodic_points(self, m, n, **kwds):
else:
f_sub = self.change_ring(R)
R = f_sub.base_ring() #in the case when R is an embedding
if isinstance(R, FractionField_1poly_field) or is_FunctionField(R):
if isinstance(R, FractionField_1poly_field) or R in FunctionFields():
raise NotImplementedError('Periodic points not implemented for function fields; '
'clear denominators and use the polynomial ring instead')
CR = f_sub.coordinate_ring()
Expand Down Expand Up @@ -4872,7 +4871,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari
else:
f_sub = self.change_ring(R)
R = f_sub.base_ring() #in the case when R is an embedding
if isinstance(R, FractionField_1poly_field) or is_FunctionField(R):
if isinstance(R, FractionField_1poly_field) or R in FunctionFields():
raise NotImplementedError('periodic points not implemented for fraction function fields; '
'clear denominators and use the polynomial ring instead')
if isinstance(R, FractionField_generic):
Expand Down
17 changes: 14 additions & 3 deletions src/sage/rings/function_field/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ AUTHORS:
# https://www.gnu.org/licenses/
# *****************************************************************************

from sage.structure.element cimport FieldElement
from sage.categories.function_fields import FunctionFields
from sage.misc.cachefunc import cached_method
from sage.structure.element cimport FieldElement


def is_FunctionFieldElement(x):
Expand All @@ -76,14 +77,24 @@ def is_FunctionFieldElement(x):
sage: t = FunctionField(QQ,'t').gen()
sage: sage.rings.function_field.element.is_FunctionFieldElement(t)
doctest:warning...
DeprecationWarning: The function is_FunctionFieldElement is deprecated;
use '....parent() in FunctionFields()' instead.
See https://github.com/sagemath/sage/issues/38289 for details.
True
sage: sage.rings.function_field.element.is_FunctionFieldElement(0)
False
"""
from sage.misc.superseded import deprecation_cython
deprecation_cython(38289,
"The function is_FunctionFieldElement is deprecated; "
"use '....parent() in FunctionFields()' instead.")
if isinstance(x, FunctionFieldElement):
return True
from sage.rings.function_field.function_field import is_FunctionField
return is_FunctionField(x.parent())
from sage.rings.function_field.function_field import FunctionField
if isinstance(x.parent(), FunctionField):
return True
return x.parent() in FunctionFields()


def make_FunctionFieldElement(parent, element_class, representing_element):
Expand Down
9 changes: 8 additions & 1 deletion src/sage/rings/function_field/function_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,17 @@ def is_FunctionField(x):
sage: from sage.rings.function_field.function_field import is_FunctionField
sage: is_FunctionField(QQ)
doctest:warning...
DeprecationWarning: The function is_FunctionField is deprecated; use '... in FunctionFields()' instead.
See https://github.com/sagemath/sage/issues/38289 for details.
False
sage: is_FunctionField(FunctionField(QQ, 't'))
True
"""
from sage.misc.superseded import deprecation
deprecation(38289,
"The function is_FunctionField is deprecated; "
"use '... in FunctionFields()' instead.")
if isinstance(x, FunctionField):
return True
return x in FunctionFields()
Expand Down Expand Up @@ -840,7 +847,7 @@ def _intermediate_fields(self, base):
...
TypeError: base must be a function field
"""
if not is_FunctionField(base):
if base not in FunctionFields():
raise TypeError("base must be a function field")

ret = [self]
Expand Down
15 changes: 7 additions & 8 deletions src/sage/schemes/berkovich/berkovich_cp_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@

import sage.rings.abc

from sage.categories.function_fields import FunctionFields
from sage.misc.lazy_import import lazy_import
from sage.rings.infinity import Infinity
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RR, RealNumber
from sage.rings.real_mpfr import RealNumber, RR
from sage.schemes.projective.projective_point import SchemeMorphism_point_projective_field
from sage.schemes.projective.projective_space import ProjectiveSpace
from sage.structure.element import Element, Expression
Expand Down Expand Up @@ -84,7 +85,6 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, space_type=
sage: B(4)
Type I point centered at 4 + O(5^20)
"""
from sage.rings.function_field.element import is_FunctionFieldElement
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.rings.fraction_field_element import FractionFieldElement_1poly_field
self._type = None
Expand All @@ -109,8 +109,7 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, space_type=
if not error_check:
return

# is_FunctionFieldElement calls .parent
elif hasattr(center, "parent") and hasattr(radius, 'parent'):
elif isinstance(center, Element) and isinstance(radius, Element):
from sage.rings.polynomial.multi_polynomial import MPolynomial
if isinstance(center, MPolynomial):
try:
Expand All @@ -119,10 +118,10 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, space_type=
raise TypeError('center was %s, a multivariable polynomial' % center)

# check if the radius and the center are functions
center_func_check = is_FunctionFieldElement(center) or isinstance(center, Polynomial) or\
isinstance(center, FractionFieldElement_1poly_field) or isinstance(center, Expression)
radius_func_check = is_FunctionFieldElement(radius) or isinstance(radius, Polynomial) or\
isinstance(radius, FractionFieldElement_1poly_field) or isinstance(radius, Expression)
center_func_check = center.parent() in FunctionFields() or \
isinstance(center, (Polynomial, FractionFieldElement_1poly_field, Expression))
radius_func_check = radius.parent() in FunctionFields() or \
isinstance(radius, (Polynomial, FractionFieldElement_1poly_field, Expression))

if center_func_check:
# check that both center and radii are supported univariate function
Expand Down

0 comments on commit 9cec969

Please sign in to comment.