>
>
> >>> Harder example:
>
> >>> @interact
> >>> def _(f=x^2, a=(3,[2..10]), c = (2,6)):
> >>> g(x)=f+a
> >>> show(plot(g,(x,-c,c)))
>
> >> This is harder since when the interact is run, ``a`` is a single number
> >> (by the autoguessing), but when the function itself is run, ``a`` is a
> >> tuple. Same problem for c. Maybe we should actually change the
> >> function that is returned to substitute in the default arguments,
> >> instead of just returning the function. That would be doable and
> >> reasonable, I think.
>
> There's hacks that you could do (call the autoguessing function
> yourself, then call the default method on each control returned)...how
> desperate are you?
Oh, it would be really nice. My use case would be to get at least
simple interacts to be extractable automatically using sws2tex and
then evaluated using SageTeX - but then I would need to modify the
code in a cell to get something like what we are discussing.
Unfortunately, it will still be hackish - since I'll have to guess on
the fly whether the output includes a plot and do \begin/end{sageplot}
accordingly. I don't know whether I'll be able to do that well enough
to make it worthwhile.
If only SageTeX knew automatically that a command returned a plot and
turned a \sage*{} thing into a plot in those cases ... :)
> I looked at this for a bit. Does anyone know if it's all right to just
> replace g.func_defaults? Or are there problems with just outright
> setting that tuple?
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org