New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
py3: bug with canonical_label #26800
Comments
This comment has been minimized.
This comment has been minimized.
comment:2
Ouch.. This may also explain why the code in cluster_quiver fails so badly.. |
comment:3
We must investigate deeper to find the cause of the issue. Do we have an expert in this part of the code ? |
comment:4
on the other hand, in python3:
|
comment:5
Let's summarize:
So the canonical label works after the second application. EDIT:
EDIT:
|
comment:6
This is really weird. |
comment:7
Maybe an issue in graph6_string...
|
comment:8
With py3, we have
So the mapping But with py2, the 2 mappings are the same. I suspect that the order in which vertices are added to the graph is not the same. May be a loop over the keys of a dictionary as this order is not necessarily the same in py2 and in py3? |
comment:10
Looks like it could (maybe) be fixed (or disappear in some way) by using Python 3.7 (#25680)... |
comment:11
Let's hope so. |
comment:12
I've done some investigation. The issue seems to be that in Python 3.6+ dictionaries are iterated over in 'insertion order' rather than in the Python 2.7 '(hash of) key order'. In the above code the problem arises in the This bug indicates that at least some sage graph code silently relies on Python 2.7-style dict iteration rather than 'insertion order' as in Python 3.6+. The new behaviour was standardised for 3.7 so I don't think the bug will magically disappear in the future. I think it is probably too costly in time/memory to sort every time vertices are iterated over (by adding self.vertex_ints = new_vx_ints with self.vertex_ints = dict(sorted(new_vx_ints.items())) on line 1965 of |
comment:13
Replying to @ed359:
We cannot do that. The keys of dictionary |
comment:14
Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually) |
comment:15
#27695 seems to fix this as well. Shall we close this ticket or is there any |
comment:16
We can close this one. |
The following doctest of
petersen_family
infamilies.py
fails with with Python3:Some investigation suggests that the issue comes from
canonical_label
. Consider the following example (part of the code ofpetersen_family
).With Python 2, we get:
With Python 3, we get:
so the
canonical_label
method seems broken with Python 3.EDIT: fixed by #27695
Component: graph theory
Issue created by migration from https://trac.sagemath.org/ticket/26800
The text was updated successfully, but these errors were encountered: