First time here? Check out the FAQ!

Ask Your Question
0

DeprecationWarning on SageCell (Python 3)

asked 5 years ago

ortollj gravatar image

updated 5 years ago

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

Preview: (hide)

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 ( 5 years ago )
1

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

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)
Preview: (hide)
link

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 ( 5 years ago )
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 ( 5 years ago )

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 ( 5 years ago )

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 ( 5 years ago )

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 ( 5 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

1 follower

Stats

Asked: 5 years ago

Seen: 981 times

Last updated: Jan 03 '20