[sage-support] Re: interact input box problem
Hi Jason (Grout), I found a very serious bug sort of similar to the one being discussed in this thread. Namely, if you make an interact like this things go horribly wrong: @interact def f(s=(0,pi,1)): print s I've posted a patch here http://trac.sagemath.org/sage_trac/ticket/5232 Please review it. William On Mon, Feb 9, 2009 at 4:36 PM, kcrisman kcris...@gmail.com wrote: The patch makes it so that u=x^2 works, where it didn't before (it gave you that weird string). What changes is that typing u='x^2' now literally puts 'x^2' (with the quote marks) in the input box, whereas before the patch, only x^2 (without quote marks) would show up in the input box. In short, the patch fixes your original complaint. However, it changes how strings are handled when specified as default values. I see. I should point out again that u=x^2 worked fine in the very recent past. Is there no way to get that both 'x^2' (for presumably lots of code exists that used that; a cursory look at the Wiki reveals at last a few with x^2 or 'x^2') and x^2 (the obvious thing, which most wiki examples use) *both* work as intended? I ask out of ignorance. - kcrisman -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
I should also point out that this does NOT occur (i.e. all is normal in the text input box) on our local server, which is 3.0.6. Could this be related to #4524? Either way, this is now # 5220. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
A workaround is: @interact def plotfunction(f=input_box('x^2')): P=plot(sage_eval(f, locals={'x':x}),0,1) show(P) In general I've found it safer to use string input and then explicitly convert it. Things look fine on 3.2.3, btw, at least on FF3 on linux. -Marshall On Feb 9, 5:31 pm, kcrisman kcris...@gmail.com wrote: I should also point out that this does NOT occur (i.e. all is normal in the text input box) on our local server, which is 3.0.6. Could this be related to #4524? Either way, this is now # 5220. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
kcrisman wrote: Dear Support, On sagenb.org, try making an interact with an input box explicitly defined, e.g. @interact def plotfunction(f=input_box(x^2)): P=plot(f,0,1) show(P) It works fine in the sense that whatever you type in does what it should. But what's up with how the input box appears? It's even worse on my box (PPC OSX.4) - the initial input does not show up *at all* in the box, though again the plot is fine and once you type something in it behaves normally. Any suggestions as to what I'm doing wrong would be appreciated. Or is it still fallout from TinyMCE or something like that? This is a str versus repr problem. I've attached a patch to #5220 which fixes it, but this patch also changes how interact deals with strings. The patch should be discussed before applying, I think, since it changes the way strings work as arguments to interact things. @interact def plotfunction(f=input_box('x^2')): print f before used to give a box with x^2 in it. With the patch at #5220, it gives a box with 'x^2' in it (note it is now explicitly a string). To prevent applying without discussion, I intentionally left the two existing doctests of the affected function broken. I figured that would stop mabshoff from applying the patch until discussion happened and someone cared enough to fix the existing doctests :). I think the correct behavior should be the behavior with the patch. Thanks, Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
I think I disagree with this change in behavior. One (major) point of interact is to be very user-friendly. Needing to input functions as strings is not user-friendly. -Marshall On Feb 9, 10:26 pm, Jason Grout jason-s...@creativetrax.com wrote: kcrisman wrote: Dear Support, On sagenb.org, try making an interact with an input box explicitly defined, e.g. @interact def plotfunction(f=input_box(x^2)): P=plot(f,0,1) show(P) It works fine in the sense that whatever you type in does what it should. But what's up with how the input box appears? It's even worse on my box (PPC OSX.4) - the initial input does not show up *at all* in the box, though again the plot is fine and once you type something in it behaves normally. Any suggestions as to what I'm doing wrong would be appreciated. Or is it still fallout from TinyMCE or something like that? This is a str versus repr problem. I've attached a patch to #5220 which fixes it, but this patch also changes how interact deals with strings. The patch should be discussed before applying, I think, since it changes the way strings work as arguments to interact things. @interact def plotfunction(f=input_box('x^2')): print f before used to give a box with x^2 in it. With the patch at #5220, it gives a box with 'x^2' in it (note it is now explicitly a string). To prevent applying without discussion, I intentionally left the two existing doctests of the affected function broken. I figured that would stop mabshoff from applying the patch until discussion happened and someone cared enough to fix the existing doctests :). I think the correct behavior should be the behavior with the patch. Thanks, Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
Does this mean that all people writing interacts would have to type u='x^2' instead of u=x^2? Does this mean that all people using interacts would have to type 'x^2' instead of x^2? This sounds like what Marshall says the behavior would be. That sounds horrible. Shouldn't there be a way to get this to still work, given that it worked as recently as 3.2.3? Or does #4524 make it impossible to regain the previous behavior? - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
Marshall Hampton wrote: I think I disagree with this change in behavior. One (major) point of interact is to be very user-friendly. Needing to input functions as strings is not user-friendly. The patch changes the behavior so that you *don't* need to input strings. From your statement, it sounds like you actually agree with the change introduced by the patch. However, maybe I'm missing something... I should say that with the patch: @interact def plotfunction(f=input_box(x^2)): print f works Jason -Marshall On Feb 9, 10:26 pm, Jason Grout jason-s...@creativetrax.com wrote: kcrisman wrote: Dear Support, On sagenb.org, try making an interact with an input box explicitly defined, e.g. @interact def plotfunction(f=input_box(x^2)): P=plot(f,0,1) show(P) It works fine in the sense that whatever you type in does what it should. But what's up with how the input box appears? It's even worse on my box (PPC OSX.4) - the initial input does not show up *at all* in the box, though again the plot is fine and once you type something in it behaves normally. Any suggestions as to what I'm doing wrong would be appreciated. Or is it still fallout from TinyMCE or something like that? This is a str versus repr problem. I've attached a patch to #5220 which fixes it, but this patch also changes how interact deals with strings. The patch should be discussed before applying, I think, since it changes the way strings work as arguments to interact things. @interact def plotfunction(f=input_box('x^2')): print f before used to give a box with x^2 in it. With the patch at #5220, it gives a box with 'x^2' in it (note it is now explicitly a string). To prevent applying without discussion, I intentionally left the two existing doctests of the affected function broken. I figured that would stop mabshoff from applying the patch until discussion happened and someone cared enough to fix the existing doctests :). I think the correct behavior should be the behavior with the patch. Thanks, Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
kcrisman wrote: Does this mean that all people writing interacts would have to type u='x^2' instead of u=x^2? Does this mean that all people using interacts would have to type 'x^2' instead of x^2? This sounds like what Marshall says the behavior would be. That sounds horrible. Shouldn't there be a way to get this to still work, given that it worked as recently as 3.2.3? Or does #4524 make it impossible to regain the previous behavior? The patch makes it so that u=x^2 works, where it didn't before (it gave you that weird string). What changes is that typing u='x^2' now literally puts 'x^2' (with the quote marks) in the input box, whereas before the patch, only x^2 (without quote marks) would show up in the input box. In short, the patch fixes your original complaint. However, it changes how strings are handled when specified as default values. Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
The patch makes it so that u=x^2 works, where it didn't before (it gave you that weird string). What changes is that typing u='x^2' now literally puts 'x^2' (with the quote marks) in the input box, whereas before the patch, only x^2 (without quote marks) would show up in the input box. In short, the patch fixes your original complaint. However, it changes how strings are handled when specified as default values. I see. I should point out again that u=x^2 worked fine in the very recent past. Is there no way to get that both 'x^2' (for presumably lots of code exists that used that; a cursory look at the Wiki reveals at last a few with x^2 or 'x^2') and x^2 (the obvious thing, which most wiki examples use) *both* work as intended? I ask out of ignorance. - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-support] Re: interact input box problem
I'm able to reproduce this on sagenb.org on a Mac with FF3. On Sun, Feb 8, 2009 at 11:00 PM, kcrisman kcris...@gmail.com wrote: Dear Support, On sagenb.org, try making an interact with an input box explicitly defined, e.g. @interact def plotfunction(f=input_box(x^2)): P=plot(f,0,1) show(P) It works fine in the sense that whatever you type in does what it should. But what's up with how the input box appears? It's even worse on my box (PPC OSX.4) - the initial input does not show up *at all* in the box, though again the plot is fine and once you type something in it behaves normally. Any suggestions as to what I'm doing wrong would be appreciated. Or is it still fallout from TinyMCE or something like that? Thanks, - kcrisman --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~--~~~~--~~--~--~---