Ask Your Question
0

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

asked 2012-03-21 12:46:24 -0500

fakaff gravatar image

updated 2012-03-21 13:19:39 -0500

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 13:21:41 -0500

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 13:47:36 -0500 )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 14:03:22 -0500 )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 14:16:17 -0500 )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 12:46:24 -0500

Seen: 566 times

Last updated: Mar 21 '12