Hi,
Somebody doing differential equations sent me this code, which you can
run in a fresh sage-6.9 session:
var('x,y')
y = function('y')(x)
eqn = diff(x^2+y^2==25,x)
sol0 = solve(eqn, diff(y,x))
sol1 = sol0[0].subs({x:3})
sol1.subs({y(3):4})
The *last line* outputs:
D[0](y)(3) == (-3/4)
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.
exec compile(block+'\n', '', 'single') in namespace, locals
I have some problems with this:
(1) trac #5930 hasn't been touched in *7 years*, and doesn't mention
subs anywhere. Maybe referencing 5930 was a typo?
(2) The actual substitution above is *NOT* function-call syntax --
it's passing in a dictionary, which seems like a very reasonable way
to do substitution in general and should never get deprecated. So why
is that deprecation warning appearing? Is it actually coming from
some other code inside the library?
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
-1 to telling users that a syntax is deprecated and will be removed, but planning to never remove it.
On Tuesday, March 1, 2016 at 8:15:56 AM UTC-8, William wrote:-1 to telling users that a syntax is deprecated and will be removed, but planning to never remove it.+1 to executing the removal.
We can't let a lottery like this:
sage: var('foo,bar')
(foo, bar)
sage: f=foo+bar
sage: f(1)
foo + 1
go silently. The proper solution is raising an error.
We *could* special case the situation where len(f.variables()) == 1 and one argument is given. Apart from no arguments at all, That's the only situation that's unambiguous, as far as I know.
The problem at http://trac.sagemath.org/ticket/12070 is just misuse, so should be resolved by improving documentation.
--
+1 to removing the deprecation and special casing the 1 variable (if it is easy enough to implement).
If I recall correctly, Jason Grout's example for this isx+y-ywhich becomes x but in principle had two variables, so how do you know which one is "right"?
But, proposing that we get rid of symbolic expressions in piecewise
functions is stronger than the proposal to get rid of unnamed arguments.
This works, and accounts for just about every use of piecewise() you'll
find, even the ones in the Sage library:
sage: f = piecewise([[(-1,1),x]])
sage: f.plot()
The proposal would require,
sage: f = piecewise([[(-1,1), x.function(x)]])
which is a little weird and not used anywhere that I've seen.
Some other
odd cases that I ran into were,
f = cos(x).function(x)
f = SR(1).function(x)
But overall I agree that forcing piecewise() to take functions creates a
better mental model. It just may be harder to get rid of than the
unnamed-argument function call syntax alone.
- a way of specifying a piecewise function *using expressions*, i.e., something along the lines of
piecewise([[(-1,1),x],[(1,2),x^2]],arguments=(x,))
as a replacement for
piecewise([[(-1,1),x.function(x)],[(1,2),(x^2).function(x)]])
note that the present situation allows for
piecewise([[(-1,1),x],[(1,2),y^2])
which I think is worth getting rid of.
sage: piecewise([[(-1,1),x],[(1,2),y^2]])
piecewise(x|-->x on (-1, 1), x|-->y^2 on (1, 2); x)
There needs to be some indication somewhere in what way the interval relates to the variables in the expression.