From dad5253df5cca0d5a4d376a347ffdad8b9e85d3c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 24 Jul 2022 14:44:28 -0700 Subject: [PATCH] src/sage/symbolic/callable.py: Deprecate is_CallableSymbolicExpression, remove remaining uses --- src/sage/sets/image_set.py | 4 ++-- src/sage/symbolic/callable.py | 6 ++++++ src/sage/symbolic/expression_conversions.py | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sage/sets/image_set.py b/src/sage/sets/image_set.py index c5dbef90866..2de224762ba 100644 --- a/src/sage/sets/image_set.py +++ b/src/sage/sets/image_set.py @@ -25,7 +25,7 @@ from sage.categories.enumerated_sets import EnumeratedSets from sage.rings.integer import Integer from sage.modules.free_module import FreeModule -from sage.symbolic.callable import is_CallableSymbolicExpression +from sage.structure.element import Expression from .set import Set_base, Set_add_sub_operators, Set_boolean_operators @@ -60,7 +60,7 @@ def __init__(self, map, domain_subset, *, category=None, is_injective=None): if not is_Map(map) and not isinstance(map, PoorManMap): map_name = f"The map {map}" - if is_CallableSymbolicExpression(map): + if isinstance(map, Expression) and map.is_callable(): domain = map.parent().base() if len(map.arguments()) != 1: domain = FreeModule(domain, len(map.arguments())) diff --git a/src/sage/symbolic/callable.py b/src/sage/symbolic/callable.py index 1b1cf8d5bb1..b1411260884 100644 --- a/src/sage/symbolic/callable.py +++ b/src/sage/symbolic/callable.py @@ -108,6 +108,10 @@ def is_CallableSymbolicExpression(x): (a, x, y, z) sage: f(x,y) = a + 2*x + 3*y + z sage: is_CallableSymbolicExpression(f) + doctest:warning... + DeprecationWarning: is_CallableSymbolicExpression is deprecated; + use isinstance(..., Expression) and ....is_callable() instead + See https://trac.sagemath.org/34215 for details. True sage: is_CallableSymbolicExpression(a+2*x) False @@ -116,6 +120,8 @@ def is_CallableSymbolicExpression(x): sage: is_CallableSymbolicExpression(foo) False """ + from sage.misc.superseded import deprecation + deprecation(34215, 'is_CallableSymbolicExpression is deprecated; use isinstance(..., Expression) and ....is_callable() instead') from sage.structure.element import Expression return isinstance(x, Expression) and isinstance(x.parent(), CallableSymbolicExpressionRing_class) diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index e681f480589..c5a8240cda0 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -18,7 +18,7 @@ import operator as _operator from sage.rings.rational_field import QQ from sage.symbolic.ring import SR -from sage.symbolic.callable import is_CallableSymbolicExpression +from sage.structure.element import Expression from sage.functions.all import exp from sage.symbolic.operators import arithmetic_operators, relation_operators, FDerivativeOperator, add_vararg, mul_vararg from sage.rings.number_field.number_field_element_quadratic import NumberFieldElement_gaussian @@ -701,7 +701,7 @@ def __call__(self, ex=None): sage: s(f) Lambda((x, y), x**2 + y**2) """ - if is_CallableSymbolicExpression(ex): + if isinstance(ex, Expression) and ex.is_callable(): from sympy import Symbol, Lambda return Lambda(tuple(Symbol(str(arg)) for arg in ex.arguments()), super().__call__(ex))