Skip to content
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

EdgesView.__repr__ fails for non sortable vertices #35897

Closed
2 tasks done
videlec opened this issue Jul 4, 2023 · 2 comments
Closed
2 tasks done

EdgesView.__repr__ fails for non sortable vertices #35897

videlec opened this issue Jul 4, 2023 · 2 comments

Comments

@videlec
Copy link
Contributor

videlec commented Jul 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: any
- **Sage Version**: 10.0

Steps To Reproduce

Graph([('A','B'),(1,2)]).edges()

Expected Behavior

Either

[('A', 'B'), (1, 2)]

or

[(1, 2), ('A', 'B')]

Actual Behavior

<repr(<sage.graphs.views.EdgesView at 0x7fe9a43c0a00>) failed:
TypeError: unsupported operand parent(s) for <: 'Integer Ring' and
'<class 'str'>'>

Additional Information

No response

@dcoudert
Copy link
Contributor

dcoudert commented Jul 4, 2023

The description of this issue is not fair. It omits the deprecation warning (still active in 10.1.beta5).

sage: Graph([('A','B'),(1,2)]).edges()
<ipython-input-1-266d02e19563>:1: DeprecationWarning: parameter 'sort' will be set to False by default in the future
See https://github.com/sagemath/sage/issues/27408 for details.
  Graph([('A','B'),(Integer(1),Integer(2))]).edges()
<repr(<sage.graphs.views.EdgesView at 0x1511698a0>) failed: TypeError: unsupported operand parent(s) for <: 'Integer Ring' and '<class 'str'>'>

After reading this deprecation warning and the documentation of the edges method, one may do:

sage: G = Graph([('A','B'),(1,2)])
sage: G.edges(sort=False)
[('A', 'B', None), (1, 2, None)]
sage: G.edges(sort=False, labels=False)
[('A', 'B'), (1, 2)]
sage: G.edges(sort=True, key=str)
[('A', 'B', None), (1, 2, None)]
sage: G.edges(sort=True, key=str, labels=False)
[('A', 'B'), (1, 2)]

@dcoudert
Copy link
Contributor

Now that #36073 has been merged, the deprecation warnings introduced in #22349 and #27408 have been removed and so vertices and edges are no longer sorted by default.

With 10.1.rc0:

sage: Graph([('A','B'),(1,2)]).edges()
[('A', 'B', None), (1, 2, None)]
sage: G = Graph([('A', 'B'), (1, 2), ('A', 1), (2, 'B'), (3, 'C')])
sage: G.vertices()
['A', 'B', 1, 2, 3, 'C']
sage: G.edges()
[('A', 'B', None), (1, 'A', None), (2, 'B', None), (1, 2, None), ('C', 3, None)]

We can certainly close this issue.

@videlec videlec closed this as completed Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants