Skip to content

Commit

Permalink
Fix selfloop_edges AttributeError in algo/graph/mixin_helpers.py
Browse files Browse the repository at this point in the history
When running the test
`wbia/algo/graph/mixin_dynamic.py::NonDynamicUpdate.apply_nondynamic_update:0`:

```
Traceback (most recent call last):
  File "/virtualenv/env3/lib/python3.6/site-packages/xdoctest/doctest_example.py", line 556, in run
    exec(code, test_globals)
  File "<doctest:/wbia/wildbook-ia/wbia/algo/graph/mixin_dynamic.py::NonDynamicUpdate.apply_nondynamic_update:0>", line rel: 9, abs: 1298, in <module>
    >>> infr.assert_neg_metagraph()
  File "/wbia/wildbook-ia/wbia/algo/graph/mixin_helpers.py", line 716, in assert_neg_metagraph
    [ne[0] for ne in list(infr.neg_metagraph.selfloop_edges())]
AttributeError: 'NiceGraph' object has no attribute 'selfloop_edges'
```

This is because networkx has moved some methods from the base graph class into
the main namespace.  See
https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html.

So need to change

```
infr.neg_metagraph.selfloop_edges()
```

to

```
nx.selfloop_edges(infr.neg_metagraph)
```
  • Loading branch information
karenc authored and bluemellophone committed Jul 24, 2020
1 parent fee14a5 commit a3467a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wbia/algo/graph/mixin_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def assert_neg_metagraph(infr):

# Self loops should correspond to the number of inconsistent components
neg_self_loop_nids = sorted(
[ne[0] for ne in list(infr.neg_metagraph.selfloop_edges())]
[ne[0] for ne in list(nx.selfloop_edges(infr.neg_metagraph))]
)
incon_nids = sorted(infr.nid_to_errors.keys())
assert neg_self_loop_nids == incon_nids
Expand Down

0 comments on commit a3467a3

Please sign in to comment.