Skip to content

Commit 47657aa

Browse files
author
Release Manager
committed
sagemathgh-40927: fix issue 40885: restore correct setting of attribute `_embedding` Fixes sagemath#40885. We restore the correct setting of attribute `_embedding` after the call to `is_planar` in method `faces` of graphs. The attribute is modified only when the graph is planar. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#40927 Reported by: David Coudert Reviewer(s): Frédéric Chapoton
2 parents 4c2d033 + 06058b3 commit 47657aa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/sage/graphs/generic_graph.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6947,6 +6947,15 @@ def faces(self, embedding=None):
69476947

69486948
sage: graphs.PathGraph(3).faces()
69496949
[[(0, 1), (1, 2), (2, 1), (1, 0)]]
6950+
6951+
Check that :issue:`40885` is fixed::
6952+
6953+
sage: g = graphs.CycleGraph(3)
6954+
sage: hasattr(g, '_embedding')
6955+
False
6956+
sage: F = g.faces()
6957+
sage: hasattr(g, '_embedding')
6958+
False
69506959
"""
69516960
if not self.order() or not self.size():
69526961
return []
@@ -6957,9 +6966,13 @@ def faces(self, embedding=None):
69576966
else:
69586967
embedding = self.get_embedding()
69596968
if embedding is None:
6969+
has_attribute = hasattr(self, '_embedding')
69606970
if self.is_planar(set_embedding=True):
69616971
embedding = self._embedding
6962-
self._embedding = None
6972+
if has_attribute:
6973+
self._embedding = None
6974+
else:
6975+
del self._embedding
69636976
else:
69646977
raise ValueError("no embedding is provided and the graph is not planar")
69656978

0 commit comments

Comments
 (0)