Ask Your Question
0

DeprecationWarning on SageCell (Python 3)

asked 2020-01-03 11:00:05 +0200

ortollj gravatar image

updated 2020-01-03 20:35:01 +0200

FrédéricC gravatar image

this code was ok few months ago but ko now, I suppose because of the missing parenthesis around the string: I need to write print (" caracteristic polynomial p(x)") ?, it stop running now. is it possible to update a sagecell code keeping the same link ?, or need I change the link and in this case is it possible to delete the old code ?

<input>:60: DeprecationWarning: invalid escape sequence \d

  File "<ipython-input-1-89c4ce1b89cc>", line 85
    print " caracteristic polynomial p(x)"

code on sage cell ^

SyntaxError: invalid syntax

edit retag flag offensive close merge delete

Comments

strange because this sageCell code is ok when I copy past it in my notebook 8.9 on Ubuntu 18.04.3 !

What's wrong ?

ortollj gravatar imageortollj ( 2020-01-03 11:33:45 +0200 )edit
1

1 Answer

Sort by » oldest newest most voted
1

answered 2020-01-03 14:03:35 +0200

eric_g gravatar image

It's because SageMathCell is now running SageMath 9.0, which is based on Python 3. So you need to replace all Python-2 print statements by the print() function.

Moreover, the deprecation warning is caused by the \d in the following code line:

nL=re.findall("[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", recurrenceEq)

Maybe you should change the string to a raw string, i.e. prefix it by r:

nL=re.findall(r"[-+]?[.]?[\d]+(?:,\d\d\d)*[\.]?\d*(?:[eE][-+]?\d+)?", recurrenceEq)
edit flag offensive delete link more

Comments

It means that all the different codes I put on SageCell are now obsolete !

Maybe it should have been an option button on sageCell : run with 8.9 or run with 9.0 or superior ?

but this version of SageMath 9.0 is not yet available for Linux Ubuntu ? :

SageMath Download Binaries

ortollj gravatar imageortollj ( 2020-01-03 16:03:25 +0200 )edit
1

Yes, it is unfortunate that Py2/Py3 have some incompatibilities. However, Py2 is now officially unsupported, so I don't think anyone running a public-facing SageCell server will be willing to run Py2 on it. SageCell already allows for different kernels, so setting it up with both 8.9 and 9.0 is technically definitely possible.

The Ubuntu binary should become available soon now -- 9.0 has just come out. You can build from source if you don't want to wait for that (you'll be waiting for your local build to finish, though ...)

nbruin gravatar imagenbruin ( 2020-01-03 21:13:37 +0200 )edit

the 3 adaptations, I had to do for SageMath 9.0 :

print  "toto" ==> print( "toto") 
if a <> 0 : ==> if a != 0 :
add r in front of some strings (with \d in it),   "toto"=> r"toto"

ortollj : 2019/01/04 saturday, adapted , Sagemath 8.9 (Python 2) to Sagemath 9 (Python 3)

ortollj gravatar imageortollj ( 2020-01-04 16:00:51 +0200 )edit

About another subject, I don't think it is normal the fact that in my code, if we choose p = 2 (line 9), and if we replace the 6th line of code starting from the end (line 377) with if p! = 127 : (trying so to calculate the limit when p = 2) it crashes my PC (notebook 9.0,UBUNTU 18.04) without generating any error messages !.

ortollj gravatar imageortollj ( 2020-01-04 18:35:23 +0200 )edit

Regarding your last comment, probably you should open a different question about that, otherwise it will confuse people coming to this question who will also have the same question you have - I predict many!

kcrisman gravatar imagekcrisman ( 2020-01-06 16:08:25 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-01-03 11:00:05 +0200

Seen: 812 times

Last updated: Jan 03 '20