Ask Your Question
0

Script stops working when imported to sage terminal ("plot" not defined)

asked 2012-03-21 18:46:24 +0200

fakaff gravatar image

updated 2012-03-21 19:19:39 +0200

EDIT: OK, so basically, the Sage command line is not recognizing any sage commands (sqrt, etc) when they are contained in an imported .sage file. It's as if when I import a file to Sage, it doesn't read it using the Sage library. Is there something I have to add to the header of a .sage file for it to be read properly?


Old message:

So everything works fine in the sage notebook, and even if I pretty much rewrite the same commands in the Sage terminal. So it can't be a problem with the script.

But when I copy, paste and save the whole script as a standalone file.sage, and then try

run file.sage

... suddenly:

---> 30 multiPlot = plot(graphs, (x, 0, times[len(times)-1]+3), ymin=0)
    31 
    32 

NameError: name 'plot' is not defined

Why doesn't it read "plot" correctly and expect me to define it?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-03-21 19:21:41 +0200

Shashank gravatar image

use

run -i file.sage

that should work

edit flag offensive delete link more

Comments

Now it's giving me error for using `^` instead of `**`. It seems to be completely ignoring the fact that it's sage code, not 100% python... even though I am inside the sage command line thingy and the exact same script works perfectly if I just copy in paste it.

fakaff gravatar imagefakaff ( 2012-03-21 19:47:36 +0200 )edit

Yeah I am getting the same problem. I normally don't use run command. Instead I just type sage file.sage. That way you don't face that problem. Is there some reason you want to use run instead of sage file.sage?

Shashank gravatar imageShashank ( 2012-03-21 20:03:22 +0200 )edit

That works here too. -- no reason in particular, just bugging me that it doesn't work and I might need it in the future.

fakaff gravatar imagefakaff ( 2012-03-21 20:16:17 +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

Stats

Asked: 2012-03-21 18:46:24 +0200

Seen: 1,088 times

Last updated: Mar 21 '12