Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/symbolic/callable.py: Deprecate is_CallableSymbolicExpressio…
Browse files Browse the repository at this point in the history
…n, remove remaining uses
  • Loading branch information
Matthias Koeppe committed Jul 24, 2022
1 parent 7f71494 commit dad5253
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/sage/sets/image_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()))
Expand Down
6 changes: 6 additions & 0 deletions src/sage/symbolic/callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/sage/symbolic/expression_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit dad5253

Please sign in to comment.