[sage-devel] Re: including @interact examples in documentation
Robert Bradshaw wrote: > On Oct 21, 2009, at 3:13 PM, Jason Grout wrote: > >> William Stein wrote: >>> On Wed, Oct 21, 2009 at 11:54 AM, Jason Grout >>> wrote: (Yet again) I tried to pull up an @interact from the wiki and it didn't work because it had not been updated to keep up with the changes to syntax in Sage. Are there any objections to making a file of the @interact examples so that it is easy to spot when they need to be updated through normal doctesting? >>> How would it work? What would you put in the file. >>> >>> I think it would be much better to make a while directory in the main >>> Sage tree of examples, along >>> with an organized namespace, e.g., something like >>> >>>sage: interacts. >>>sage: interacts.calculus. >>>sage: interacts.calculus.derivative() >>>up pops the interact >>> >>> Regarding doctesting, that may require some extension to how interact >>> works? I.e., some special function like >>> >>>sage: interacts.calculus.derivative.test() >>> >>> that would do something clever. > > That would be cool. > >> Nice idea! >> >> As things are right now, if I define an interact function >> >> interacts.calculus.vector_motion_2d >> >> then someone could call it up by: >> >> interact(interacts.calculus.vector_motion_2d) > > I'd prefer interacts.calculus.vector_motion_2d() to > interact(interacts.calculus.vector_motion_2d) Two comments: (1) as it is now, interacts.calculus.vector_motion_2d(a=1,b=2) would produce usable output with those parameter values (no sliders, but the function would work), so the function is a nice function as well as an interact. (2) interact() does all of its work when it wraps the function, so the interact system would need some tinkering to make your option work, while interact(interacts.calculus.vector_motion_2d) works now. To take care of option 2, it seems like we could either redo some of the interact functionality, or we could define a library_interact decorator that embeds the interact functionality into the function call, rather than the function definition. However, (1) makes me lean towards what I proposed. Does that change your mind? Thanks, Jason -- Jason Grout --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: including @interact examples in documentation
On Oct 21, 2009, at 3:13 PM, Jason Grout wrote: > > William Stein wrote: >> On Wed, Oct 21, 2009 at 11:54 AM, Jason Grout >> wrote: >>> (Yet again) I tried to pull up an @interact from the wiki and it >>> didn't >>> work because it had not been updated to keep up with the changes to >>> syntax in Sage. Are there any objections to making a file of the >>> @interact examples so that it is easy to spot when they need to be >>> updated through normal doctesting? >> >> How would it work? What would you put in the file. >> >> I think it would be much better to make a while directory in the main >> Sage tree of examples, along >> with an organized namespace, e.g., something like >> >>sage: interacts. >>sage: interacts.calculus. >>sage: interacts.calculus.derivative() >>up pops the interact >> >> Regarding doctesting, that may require some extension to how interact >> works? I.e., some special function like >> >>sage: interacts.calculus.derivative.test() >> >> that would do something clever. That would be cool. > > Nice idea! > > As things are right now, if I define an interact function > > interacts.calculus.vector_motion_2d > > then someone could call it up by: > > interact(interacts.calculus.vector_motion_2d) I'd prefer interacts.calculus.vector_motion_2d() to interact(interacts.calculus.vector_motion_2d) - Robert --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: including @interact examples in documentation
William Stein wrote: > On Wed, Oct 21, 2009 at 11:54 AM, Jason Grout > wrote: >> (Yet again) I tried to pull up an @interact from the wiki and it didn't >> work because it had not been updated to keep up with the changes to >> syntax in Sage. Are there any objections to making a file of the >> @interact examples so that it is easy to spot when they need to be >> updated through normal doctesting? > > How would it work? What would you put in the file. > > I think it would be much better to make a while directory in the main > Sage tree of examples, along > with an organized namespace, e.g., something like > > sage: interacts. > sage: interacts.calculus. > sage: interacts.calculus.derivative() > up pops the interact > > Regarding doctesting, that may require some extension to how interact > works? I.e., some special function like > > sage: interacts.calculus.derivative.test() > > that would do something clever. > Nice idea! As things are right now, if I define an interact function interacts.calculus.vector_motion_2d then someone could call it up by: interact(interacts.calculus.vector_motion_2d) (except that it would also then return the function object, which is kind of ugly at the end of the output) I agree that having a function which tests interacts would be nice. Things could be automated a bit by having an interact control having a random_value method which generates a random value for the control. Then the interact_test function would just construct the appropriate interact control for each argument of a function, ask for a random value, and then pass those random values into the function. I'm not sure exactly what your suggestion for a place for code was, but reading your answer above and replacing "while" with "whole", I agree that a new directory is called for. Shall we call it "interacts", or a more general name like "examples"? Thanks, Jason --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: including @interact examples in documentation
On Wed, Oct 21, 2009 at 11:54 AM, Jason Grout wrote: > > (Yet again) I tried to pull up an @interact from the wiki and it didn't > work because it had not been updated to keep up with the changes to > syntax in Sage. Are there any objections to making a file of the > @interact examples so that it is easy to spot when they need to be > updated through normal doctesting? How would it work? What would you put in the file. I think it would be much better to make a while directory in the main Sage tree of examples, along with an organized namespace, e.g., something like sage: interacts. sage: interacts.calculus. sage: interacts.calculus.derivative() up pops the interact Regarding doctesting, that may require some extension to how interact works? I.e., some special function like sage: interacts.calculus.derivative.test() that would do something clever. I've always planned to do something like the above since when I first wrote interact, but I never found the time. William > > Thanks, > > Jason > > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: including @interact examples in documentation
On Oct 21, 2:54 pm, Jason Grout wrote: > (Yet again) I tried to pull up an @interact from the wiki and it didn't > work because it had not been updated to keep up with the changes to > syntax in Sage. Are there any objections to making a file of the > @interact examples so that it is easy to spot when they need to be > updated through normal doctesting? What a great idea. Tons of interacts are "broken" (not really, but have annoying error messages) because of the deprecation of function- call syntax... It could have a role similar to wester.py in sage/ calculus/, but for interact. Thanks for volunteering! - kcrisman --~--~-~--~~~---~--~~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org -~--~~~~--~~--~--~---