Skip to content

Commit b41248b

Browse files
committed
trac 17447: Deprecation of function('f',x) in favour of function('f')(x)
rationale: function('f') returns a "NewSymbolicFunction" object, whereas function('f')(x) returns a SymbolicExpression obtained by evaluating the function at x. It is confusing that function('f',x) doesn't return a function, so we are better off not providing it.
1 parent 9e13c1b commit b41248b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/sage/symbolic/function_factory.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def function(s, *args, **kwds):
135135
INPUT:
136136
137137
- ``args`` - arguments to the function, if specified returns the new
138-
function evaluated at the given arguments
138+
function evaluated at the given arguments (deprecated as of :trac:`17447`)
139139
- ``nargs=0`` - number of arguments the function accepts, defaults to
140140
variable number of arguments, or 0
141141
- ``latex_name`` - name used when printing in latex mode
@@ -168,9 +168,11 @@ def function(s, *args, **kwds):
168168
169169
EXAMPLES::
170170
171+
sage: from sage.symbolic.function_factory import function
171172
sage: var('a, b')
172173
(a, b)
173-
sage: f = function('cr', a)
174+
sage: cr = function('cr')
175+
sage: f = cr(a)
174176
sage: g = f.diff(a).integral(b)
175177
sage: g
176178
b*D[0](cr)(a)
@@ -303,10 +305,6 @@ def function(s, *args, **kwds):
303305
304306
Make sure that :trac:`15860` is fixed and whitespaces are removed::
305307
306-
sage: function('A, B')
307-
(A, B)
308-
sage: B
309-
B
310308
sage: C, D, E = function(' C D E')
311309
sage: C(D(x))
312310
C(D(x))
@@ -328,6 +326,8 @@ def function(s, *args, **kwds):
328326
funcs = [function_factory(name, **kwds) for name in names]
329327

330328
if len(args) > 0:
329+
from sage.misc.superseded import deprecation
330+
deprecation(17447, "Calling function('f',x) is deprecated. Use function('f')(x) instead.")
331331
res = [f(*args) for f in funcs]
332332
else:
333333
res = funcs

0 commit comments

Comments
 (0)