Can you please explain what this warning is?

asked 2021-09-29 16:19:37 +0100

aakkbb gravatar image

updated 2021-10-05 10:37:13 +0100

When I ran the code

f = x^2;

[f(x) for x in range(1,10)]

I got the following warning,

opt/sagemath-9.2/local/lib/python3.7/site-packages/sage/repl/ipython_kernel/__main__.py:23: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...) See http://trac.sagemath.org/5930 for details.

When I visited the given link I did not understand much. Can you please explain how can I modify the above code so that I do not get the warning.

edit retag flag offensive close merge delete

Comments

1

Just read carefully the sentence in the warning :

sage: f=x^2
sage: [f(x=k) for k in range(5)]
[0, 1, 4, 9, 16]
FrédéricC gravatar imageFrédéricC ( 2021-09-29 16:53:44 +0100 )edit

f(x) = x^2 and it is ok

ortollj gravatar imageortollj ( 2021-09-29 18:53:24 +0100 )edit
1

This particular deprecation has been acted on in 9.5.beta2 :

sage: f=x^2
sage: f(2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[ Snip... ]

TypeError: Substitution using function-call syntax and unnamed arguments has been removed. You can use named arguments instead, like EXPR(x=..., y=...)

You were warned...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-09-30 10:21:04 +0100 )edit