Ask Your Question
0

Color nodes of poset

asked 2022-07-11 19:35:26 +0100

OliverP gravatar image

I have a poset Q and an element alpha[4] of Q. If I type "alpha[4] in Q", Sage correctly responds "True".

However, when I ask Sage to plot Q with alpha[4] in a special color, I get a KeyError that looks like it can no longer identify alpha[4] as an element of Q. What is going on?

I can't attach screenshots, so here's the error message in text:

Q.plot(element_colors={"blue":[alpha[4]]})


KeyError Traceback (most recent call last) <ipython-input-27-a224aeb4e328> in <module> ----> 1 Q.plot(element_colors={"blue":[alpha[Integer(4)]]})

/ext/sage/9.4/local/lib/python3.9/site-packages/sage/combinat/posets/posets.py in plot(self, label_elements, element_labels, layout, cover_labels, *kwds) 2061 cover_labels = False 2062 -> 2063 return graph.plot(vertex_labels=label_elements, 2064 edge_labels=cover_labels, 2065 layout=layout, /ext/sage/9.4/local/lib/python3.9/site-packages/sage/misc/decorators.py in wrapper(args, *kwds) 489 options['__original_opts'] = kwds 490 options.update(kwds) --> 491 return func(args, *options) 492 493 #Add the options specified by @options to the signature of the wrapped /ext/sage/9.4/local/lib/python3.9/site-packages/sage/graphs/generic_graph.py in plot(self, *options) 19991 ['black', 'purple', 'yellow', 'yellow'] 19992 """

19993 return self.graphplot(*options).plot() 19994 19995 def show(self, method="matplotlib", *kwds): /ext/sage/9.4/local/lib/python3.9/site-packages/sage/graphs/generic_graph.py in graphplot(self, *options) 19639 """ 19640 from sage.graphs.graph_plot import GraphPlot 19641 return GraphPlot(graph=self, options=options) 19642 19643 def _rich_repr_(self, display_manager, *kwds): /ext/sage/9.4/local/lib/python3.9/site-packages/sage/graphs/graph_plot.py in __init__(self, graph, options) 304 305 self.set_pos() --> 306 self.set_vertices() 307 self.set_edges() 308 /ext/sage/9.4/local/lib/python3.9/site-packages/sage/graphs/graph_plot.py in set_vertices(self, **vertex_options) 492 colors = [] 493 for i in vertex_colors: --> 494 pos.extend([self._pos[j] for j in vertex_colors[i]]) 495 colors.extend([i] * len(vertex_colors[i])) 496 /ext/sage/9.4/local/lib/python3.9/site-packages/sage/graphs/graph_plot.py in <listcomp>(.0) 492 colors = [] 493 for i in vertex_colors: --> 494 pos.extend([self._pos[j] for j in vertex_colors[i]]) 495 colors.extend([i] * len(vertex_colors[i])) 496 KeyError: alpha[4]

edit retag flag offensive close merge delete

Comments

possibly related: although "alpha[4] in Q" is True, "alpha[4] in list(Q)" is apparently False. I think this must be a bug?

OliverP gravatar imageOliverP ( 2022-07-11 19:38:25 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-11 19:50:34 +0100

OliverP gravatar image

The solution is to build the poset with an explicit "facade = True", even though this should have been the default. I still think this is a bug.

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

Stats

Asked: 2022-07-11 19:35:26 +0100

Seen: 216 times

Last updated: Jul 11 '22