Ask Your Question
0

What broke?

asked 12 years ago

dazedANDconfused gravatar image

This code worked in Sage 4.8 and I show it working in the Sage Cell server back in July:

@interact 
def _GoldbachConj(Number = slider(4,600,2,4, label="Number"),FigureSize =  slider([1..21],default = 9, label="figure size"),Calculation = selector(['check one number','all numbers up to a number'],default = 'check one number', label = "Calculation choice")):
html('<h2 align=center>%s</h2>'%"Goldbach's Conjecture")
if (Calculation=='check one number'):  
    for i in range(2,Number/2+1):
        if is_prime(i) and is_prime(Number-i):
            print i, " + ", Number-i, " = ", Number
elif (Calculation=='all numbers up to a number'): 
    for i in range(4,Number+1,2):
        for j in range(2,i/2+1):
            if (is_prime(j) and is_prime(i-j)):
                print j, " + ", i-j, " = ", i

image description

This code no longer works for the current Sage Cell server, giving an error message for invalid syntax (line 2). What's broken and how do I fix it?

Preview: (hide)

Comments

If you can edit the question title to something more informative, it might help other folks who run into the same problem down the road.

benjaminfjones gravatar imagebenjaminfjones ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

Alex Kramer gravatar image

updated 12 years ago

The problem (which is definitely a regression on our end), is stemming from FigureSize using a generator for a list.

For now, if you change the relevant portion to:

FigureSize =  slider([i +1 for i in xrange(20)], default = 9, label="figure size")

the code works as expected. I've opened a bug report here: https://github.com/sagemath/sagecell/...

Preview: (hide)
link

Comments

Thanks for your help!

dazedANDconfused gravatar imagedazedANDconfused ( 12 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 542 times

Last updated: Sep 23 '12