Ask Your Question
1

Where has _circle_embedding gone?

asked 2018-11-27 09:59:33 +0100

Gordon gravatar image

updated 2020-01-12 13:32:50 +0100

FrédéricC gravatar image

After nearly killing myself (in frustration) installing Sage 8.4 from source on OSX 10.14.1 (Mojave), I discover that a graph plotting command that I frequently use has vanished, breaking a number of my own programs.

Previously (on SageMath up to 8.2) I would do

from sage.graphs.graph_plot import _circle_embedding

in order to access this.

Now I just get

ImportError: cannot import name _circle_embedding

I can relatively easily replace this particular function myself, but if it were something more complicated, I would be at a loss to know how to track down the cause for its disappearance and figure out how to get it back.

So I guess the questions are: has it only vanished for me due to a botched or incomplete installation, or has it somehow been removed from Sage? In either case, how can I recover it?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2018-11-27 11:55:00 +0100

slelievre gravatar image

In such a case you can inspect the source code repository, which is under version control.

One way to do that is at GitHub, where a copy of the version controlled repository exists.

Since the import was

from sage.graphs.graph_plot import _circle_embedding

one can visit

and see the file

The "History" button reveals commits that changed this file.

The last of those is "trac #22050: move methods to generic_graph.py and update usage" and by clicking it you can see how the usage of _circle_embedding has evolved.

In particular, _circle_embedding is now a method you can apply to any graph directly without a need to import it.

For example, instead of doing:

sage: g = Graph('HKN?Yeb')
sage: from sage.graphs.graph_plot import _circle_embedding
sage: _circle_embedding(g, [1, 2, 4, 3, 0, 5])

the usage is now more direct, without import:

sage: g = Graph('HKN?Yeb')
sage: g._circle_embedding([1, 2, 4, 3, 0, 5])

Note that functions or methods starting with a single underscore _ are "private methods" and there is not much guarantee on them, including that they will still exist, or stay the same, or stay in the same place.

edit flag offensive delete link more

Comments

A perfect answer I think, covering exactly what I needed to know. Awesome.

Gordon gravatar imageGordon ( 2018-11-27 12:33:41 +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

1 follower

Stats

Asked: 2018-11-27 09:59:33 +0100

Seen: 359 times

Last updated: Nov 27 '18