-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Deprecate sorting of Graph vertices and edges by default #22349
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Commit: |
comment:9
What you propose to do is not an easy task. I suspect that many algorithms assume that the vertices are sorted. For sure, many algorithms assume that the ordering is always the same when calling Is your long term plan to remove parameter Many many tests are broken
for instance (random copy/paste)
|
comment:10
Replying to @dcoudert:
I never claimed that it was easy. But it has to be done in order to support Python 3.
It should remain the same, yes.
I don't care much. I guess once the default is
The problem is that you cannot sort arbitrary things in Python 3. For example:
|
comment:11
Now I understand the need for this big change. Is there a way to sort arbitrary things in Python 3 ? some trick ? |
comment:12
Replying to @dcoudert:
Of course there is. The question is: what would you expect from such "arbitrary" sorting? And if it's arbitrary anyway: why would you want to "sort" in the first place? |
comment:13
As far as I understand, there are at least two different issues here:
Additionally, it may well be the case that some algorithms also rely on vertices of a certain type (say tuples of integers) automatically coming out sorted in a particular order, I'm not sure. |
Dependencies: #22383 |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:17
Replying to @dcoudert:
one way is
You could of course use another key function that uses some sorting heuristic (something like the key function used by https://pypi.python.org/pypi/natsort) Display functions in IPython have hooks for nice sorting (used for dicts and sets), so if graphs need to display their keys and edges in a nice way, that's probably the hook to go for. Algorithms that need their edges sorted should either insist on sortable labels or sort by index tuples or something like that (something that is guaranteed to be sortable regardless of what the user decides to use as labels). |
comment:18
Replying to @mezzarobba:
In that case, the best solution is probably to use a custom class for this. It would behave exactly like a Python |
comment:19
Replying to @nbruin:
Nils, I only just saw your comment now. But yes, this was exactly my point too. |
comment:20
Replying to @nbruin:
They could simply sort by |
comment:21
Replying to @mezzarobba:
If you want to sort by |
comment:22
Replying to @jdemeyer:
All I'm saying is that some algorithms do want to access the vertices in some arbitrary deterministic order, typically in order to iterate over the unordered pairs {v,v'}, and, as far as I remember, currently rely on the output of |
Changed keywords from none to richcmp |
comment:78
Replying to @vbraun:
Which part? I believe the "deprecation number" warning is from this change: @@ -12229,7 +12255,8 @@ class GenericGraph(GenericGraph_pyx):
[(0, 1, None), (0, 2, None), (1, 3, None), (2, 3, None), (2, 4, None), (3, 4, None)]
"""
if sort is None:
- deprecation(27408, "parameter 'sort' will be set to False by default in the future")
+ if key is None:
+ deprecation(27408, "parameter 'sort' will be set to False by default in the future")
sort = True
if vertices is not None and vertices in self: and that seems appropriate: no reason to change the ticket number. (That's the only match for "27408" in the changes for this ticket.) The |
comment:79
It is more fundamental: there is a test failing for |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:82
Doctest fixed. |
Changed branch from public/graphs/22349_deprecate_sorting_vertices_and_edges to |
How long it should take until the deprecation warning is removed? |
I hear you - see e.g. here. I think there is still a waiting period for removing them, though - a year, was it? Maybe a new ticket/issue should be opened for that. |
Following sagemath#22349 and sagemath#27408, we finally set parameter `sort` to `False` by default for methods `vertices` and `edges`, and remove the corresponding deprecation warnings. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36073 Reported by: David Coudert Reviewer(s): Matthias Köppe
Why does
Graph.vertices()
need to sort the list of vertices? If the user wants a sorted list, they can always callsorted()
anyway. The same forGraph.edges()
.Sorting is broken badly now that #22029 is merged.
CC: @sagetrac-Stefan @jm58660 @jhpalmieri
Component: graph theory
Keywords: richcmp
Author: John Palmieri, David Coudert
Branch/Commit:
fe93716
Reviewer: David Coudert, John Palmieri
Issue created by migration from https://trac.sagemath.org/ticket/22349
The text was updated successfully, but these errors were encountered: