Ask Your Question
0

Traceback error

asked 2016-05-19 21:56:50 +0100

JEA gravatar image

updated 2017-01-08 12:02:27 +0100

FrédéricC gravatar image

Hello,

I am new to Sage Math and new to this forum. Basically, I have written code to generate a specific graph on 10 vertices from its adjacency matrix. I am receiving an error (pasted below), but when my advisor runs the same exact code on his machine, he does not receive an error. I do not know how to resolve this situation. I've pasted my code below, and the error that I receive follows. Any insight would be much appreciated, and let me know if you need more details (e.g., information about the machine I'm using, operating system, etc.).

sage: M = Matrix([(0,0,1,0,1,1,1,0,1,1), (0,0,0,1,1,1,0,1,1,1), \
(1,0,0,1,1,1,1,0,0,0), (0,1,1,0,1,1,0,1,0,0), (1,1,1,1,0,1,0,0,1,0), \
(1,1,1,1,1,0,0,0,0,1), (1,0,1,0,0,0,0,1,1,1), (0,1,0,1,0,0,1,0,1,1), \
(1,1,0,0,1,0,1,1,0,1), (1,1,0,0,0,1,1,1,1,0)])
sage: M
[0 0 1 0 1 1 1 0 1 1]
[0 0 0 1 1 1 0 1 1 1]
[1 0 0 1 1 1 1 0 0 0]
[0 1 1 0 1 1 0 1 0 0]
[1 1 1 1 0 1 0 0 1 0]
[1 1 1 1 1 0 0 0 0 1]
[1 0 1 0 0 0 0 1 1 1]
[0 1 0 1 0 0 1 0 1 1]
[1 1 0 0 1 0 1 1 0 1]
[1 1 0 0 0 1 1 1 1 0]
sage: G = Graph(M); G
Graph on 10 vertices
sage: G.plot().show()

Here is the error.

Traceback (most recent call last):    [0 0 0 1 1 1 0 1 1 1]
  File "", line 1, in <module>

  File "/private/var/folders/sw/0pqlf1452k58z_jbk3_yv5m97h2tyd/T/tmpabbyzH/___code___.py", line 5
    G = Graph(M); G
    ^
SyntaxError: invalid syntax
edit retag flag offensive close merge delete

Comments

Could you please give us some informations so that someone can try to reproduce your problem:

  • which version of Sage did you use ?
  • which OS ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage yourself ?
  • which notebook did you use (Sage notebook or jupyter notebook) ?
  • did you use the command line ?
tmonteil gravatar imagetmonteil ( 2016-05-20 18:13:38 +0100 )edit

The first line of the traceback looks strange. It contains a line of the result of printing the matrix M. Did you copy paste the output of sage: M ?

FrédéricC gravatar imageFrédéricC ( 2016-05-20 19:07:39 +0100 )edit

I am sorry for my late reply. Here is the information. To answer @tmonteil:

  • I am using SageMath-7.1
  • OS X El Capitan
  • I don't know if Sage was installed from the binaries. The IT support staff for the department installed SageMath on these (department) computers.
  • Did I compile Sage myself? I'm sorry, I don't know what you mean.
  • I used Sage notebook
  • No, I did not use the command line.

To answer @FrédéricC: No, to my knowledge there was no output of sage M.

JEA gravatar imageJEA ( 2016-05-23 18:17:43 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-05-22 22:34:44 +0100

As indicated by @FrédéricC, make sure your input does not include previous output results. Here's an example on the SageMathCell server showing just the three inputs and the final graph. This server does not show the sage: command line prompt, but that should be the only difference from what you're doing.

You can also copy all three inputs on one line if you include semicolons between them, as in this example.

I've learned through trial and error that you don't need Python line continuation indicators when the arguments of a SageMath function take multiple line. In your case it's the backslashes "\" in the definition of M, which I've removed just to make it look a bit cleaner.

edit flag offensive delete link more

Comments

Ahh, thank you! This helps a lot! And thanks to @FrédéricC and also to @tmonteil for their time.

JEA gravatar imageJEA ( 2016-05-23 18:25:47 +0100 )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: 2016-05-19 21:56:50 +0100

Seen: 608 times

Last updated: May 22 '16