ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 02 Aug 2012 19:26:19 -0500Sagecell kwargs no longer workshttps://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/A week or so ago, I spent quite a lot of time with some sagecell code, but it no longer seems to work.
In particular, if I ran the following code on aleph:
@interact
def f(denominator=2):
print "denominator must be an even integer"
assert type(denominator) == Integer
assert denominator % 2 == 0
@interact(controls=[('t', (-1/2,1,1/denominator))])
def s(multiplier=2, **kwargs):
assert multiplier > 0
print kwargs.keys()
I would now get an empty list, whereas a week or 10 days ago, I got 't'. As a result, my code is now irretrievably broken.
What changed and how can I either fix it or restore the old version?
Tue, 31 Jul 2012 09:24:00 -0500https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/Comment by kcrisman for <p>A week or so ago, I spent quite a lot of time with some sagecell code, but it no longer seems to work.</p>
<p>In particular, if I ran the following code on aleph:</p>
<pre><code>@interact
def f(denominator=2):
print "denominator must be an even integer"
assert type(denominator) == Integer
assert denominator % 2 == 0
@interact(controls=[('t', (-1/2,1,1/denominator))])
def s(multiplier=2, **kwargs):
assert multiplier > 0
print kwargs.keys()
</code></pre>
<p>I would now get an empty list, whereas a week or 10 days ago, I got 't'. As a result, my code is now irretrievably broken.</p>
<p>What changed and how can I either fix it or restore the old version?</p>
https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?comment=19304#post-id-19304I'm sure Alex or Jason or one of the other Sage cell developers will address this, but my gut is that you are really using undocumented behavior with the `**kwargs` bit there - I'm sure that they are still working out bugs with nested interacts. I did see a couple of commits on github that seemed perhaps connected.Tue, 31 Jul 2012 09:48:35 -0500https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?comment=19304#post-id-19304Comment by Jason Grout for <p>A week or so ago, I spent quite a lot of time with some sagecell code, but it no longer seems to work.</p>
<p>In particular, if I ran the following code on aleph:</p>
<pre><code>@interact
def f(denominator=2):
print "denominator must be an even integer"
assert type(denominator) == Integer
assert denominator % 2 == 0
@interact(controls=[('t', (-1/2,1,1/denominator))])
def s(multiplier=2, **kwargs):
assert multiplier > 0
print kwargs.keys()
</code></pre>
<p>I would now get an empty list, whereas a week or 10 days ago, I got 't'. As a result, my code is now irretrievably broken.</p>
<p>What changed and how can I either fix it or restore the old version?</p>
https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?comment=19290#post-id-19290This works now, thanks to this pull request from Ira Hanson: https://github.com/sagemath/sagecell/pull/353Thu, 02 Aug 2012 19:26:19 -0500https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?comment=19290#post-id-19290Answer by Alex Kramer for <p>A week or so ago, I spent quite a lot of time with some sagecell code, but it no longer seems to work.</p>
<p>In particular, if I ran the following code on aleph:</p>
<pre><code>@interact
def f(denominator=2):
print "denominator must be an even integer"
assert type(denominator) == Integer
assert denominator % 2 == 0
@interact(controls=[('t', (-1/2,1,1/denominator))])
def s(multiplier=2, **kwargs):
assert multiplier > 0
print kwargs.keys()
</code></pre>
<p>I would now get an empty list, whereas a week or 10 days ago, I got 't'. As a result, my code is now irretrievably broken.</p>
<p>What changed and how can I either fix it or restore the old version?</p>
https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?answer=13877#post-id-13877I *think* this is an issue related to a change we made regarding how defining controls in the interact decorator works. I've opened an issue about that behavior here: https://github.com/sagemath/sagecell/issues/353
In the meantime, since t is being defined in the function globals, you can access it from there (or just by the variable t). One thing you might want to do for now to ensure consistent behavior with local variables and kwargs for the function is to either define all interacted variables in the interact decorator or define all interacted variables in the function itself until the issue is resolved.Tue, 31 Jul 2012 10:30:35 -0500https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?answer=13877#post-id-13877Answer by Jason Grout for <p>A week or so ago, I spent quite a lot of time with some sagecell code, but it no longer seems to work.</p>
<p>In particular, if I ran the following code on aleph:</p>
<pre><code>@interact
def f(denominator=2):
print "denominator must be an even integer"
assert type(denominator) == Integer
assert denominator % 2 == 0
@interact(controls=[('t', (-1/2,1,1/denominator))])
def s(multiplier=2, **kwargs):
assert multiplier > 0
print kwargs.keys()
</code></pre>
<p>I would now get an empty list, whereas a week or 10 days ago, I got 't'. As a result, my code is now irretrievably broken.</p>
<p>What changed and how can I either fix it or restore the old version?</p>
https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?answer=13883#post-id-13883Alex is correct; there was a change in the new experimental options dealing with defining controls in the ``interact`` part. We (on the sagecell dev team) talked about this a few weeks ago, and we realized that this change has unintended consequences, so we'll be changing it back. For now, you can use aleph1.sagemath.org (which uses our code from last year).Wed, 01 Aug 2012 04:21:03 -0500https://ask.sagemath.org/question/9198/sagecell-kwargs-no-longer-works/?answer=13883#post-id-13883