Ask Your Question

temp22.sobj is not UTF-8 encoded

asked 2018-04-06 19:33:52 +0200

standardtrickyness gravatar image

I get a temp22.sobj is not UTF-8 encoded after trying to open this file I saved by using save(G.allsimplecycles, 'temp22') what am I doing wrong?

edit retag flag offensive close merge delete


Please provide a reproducible example. Here, we don't have G to try your code.

slelievre gravatar imageslelievre ( 2018-04-06 19:49:13 +0200 )edit

I am trying to do something alike. This is of course a hazard guess. For me

sage: P = graphs.PetersenGraph().to_directed()
sage: V = P.vertices()
sage: V[5] = 'fünf'
sage: V
[0, 1, 2, 3, 4, 'f\xc3\xbcnf', 6, 7, 8, 9]
sage: W = [ (V[k], V[n], '%s%s'%(V[k],V[n])) for k, n, nonelabel in P.edges() ]
sage: G = DiGraph( [V, W], format='vertices_and_edges' )
sage: save( G.all_simple_cycles(), 'temp22' )

produces the file,

-rw-rw-r--  1 dan dan   745 Apr  7 15:05 temp22.sobj

and then

sage: G_reloaded = load( r'/home/dan/temp22' )
sage: G_reloaded == G.all_simple_cycles()

This is an old linux machine running

sage: version()
'SageMath version 7.5.1, Release Date: 2017-01-15'

Please try to describe in a similar way the problem.

dan_fulea gravatar imagedan_fulea ( 2018-04-07 15:17:58 +0200 )edit

Okay just do A=Matrix([[0,1],[1,0]]) G=Digraph(A)
I'm not sure what save does or where it get's saved to

standardtrickyness gravatar imagestandardtrickyness ( 2018-04-09 23:07:51 +0200 )edit

Please edit your question to provide a complete reproducible example.

slelievre gravatar imageslelievre ( 2018-04-15 19:04:10 +0200 )edit

To display inline code, like z = x*y, use backticks.

To display blocks of code or error messages, skip a line above and below, and do one of the following (all give the same result):

  • indent all code lines with 4 spaces
  • select all code lines and click the "code" button (the icon with '101 010')
  • select all code lines and hit ctrl-K

For instance, typing

If we define `f` by

    def f(x, y):
        return (x, y)

then `f(2, 3)` returns `(2, 3)` but `f(2)` gives:

    TypeError: f() takes exactly 2 arguments (1 given)


If we define f by

def f(x, y):
    return (x, y)

then f(2, 3) returns (2, 3) but f(2) gives:

TypeError: f() takes exactly 2 arguments (1 given)

Please edit your question to do that.

slelievre gravatar imageslelievre ( 2018-04-15 19:04:17 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-04-15 19:02:30 +0200

slelievre gravatar image

Having defined A and G as follows,

sage: A = Matrix([[0, 1], [1, 0]])
sage: G = DiGraph(A)

we have a directed graph G, which has a method all_simple_cycles.

The following only refers to the method itself

sage: G.all_simple_cycles
<bound method DiGraph.all_simple_cycles of Digraph on 2 vertices>

while the following is the result of applying the method to G.

sage: G.all_simple_cycles()
[[0, 1, 0]]

So if we save the method itself,

sage: save(G.all_simple_cycles, 'temp22')

we can then reload it:

sage: asc = load('temp22')
sage: asc
<bound method ?.all_simple_cycles of Digraph on 2 vertices>

and possibly apply it to G:

sage: asc(G)
[[0, 1, 0]]

while if we save the result of applying the method to G,

sage: save(G.all_simple_cycles(), 'temp22')

then reloading it gets us the list of all simple cycles of G:

sage: ascG = load('temp22')
sage: ascG
[[0, 1, 0]]
edit flag offensive delete link more

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


Asked: 2018-04-06 19:33:52 +0200

Seen: 430 times

Last updated: Apr 15 '18