-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
DiGraph in_edges returns wrong view when using nbunch #4745
Copy link
Copy link
Closed
Description
Current Behavior
g.in_edges(nbunch=<node(s)>) returns an InEdgeDataView if nbunch is supplied aka is not None.
Else (nbunch is None), it returns an InEdgeView.
Expected Behavior
g.in_edges(nbunch=<node(s)>) returns an InEdgeView.
This would be more consistent and would enable the chaining of .data() call in all cases.
(It should be noted that this is duplicate behaviour compared by using the parameter data=True)
Moreover, the returned InEdgeDataView doesn't contain any data if not asked (with data=True)
Steps to Reproduce
>>> g = nx.DiGraph()
>>> g.add_edge(1,2,color='blue')
>>> g.in_edges() # == g.in_edges(nbunch=None)
InEdgeView([(1, 2)])
>>> g.in_edges(2) # == g.in_edges(nbunch=2)
InEdgeDataView([(1, 2)])more observations
>>> g.in_edges().data()
InEdgeDataView([(1, 2, {'color': 'blue'})])
>>> g.in_edges(2)
InEdgeDataView([(1, 2)])
>>> g.in_edges(2, data=True)
InEdgeDataView([(1, 2, {'color': 'blue'})])Environment
Python version: 3.8.5
NetworkX version: 2.5
Tested in IPython
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels