Repository navigation
Move and generalize the Express graph conversion functions - #116
Conversation
Moves networkx_graph() and pgraph_graph() from planarity_networkx.py to planarity_functions.py, adds convert_to_pgraph() and convert_from_pgraph(pgraph, to_type) covering the networkx, edgelist, dictofdicts, dictofsets, and dictoflists formats, and keeps the original names working as compatibility entry points. Resolves graph-algorithms#77
convert_from_pgraph() forwards the DrawPlanar vertex and edge info into the networkx.Graph, matching networkx_graph()'s behavior before the move. The existing tests compare two empty-attribute graphs, so they cannot catch a dropped include_drawplanar flag.
* fixed intersphinx syntax and description of implementation details in `ascii()` docstring (missed in prior passes), * added `# pylint: disable=import-outside-toplevel` to disable `pylint` complaints in `kuratowski_subgraph()` and `convert_from_pgraph()` * updated `ImportError` exception handling to re-raise `networkx_import_error` in `kuratowski_subgraph()` and `convert_from_pgraph()`, * restored docstrings for `pgraph_graph() and `networkx_graph()` to include deprecation warnings with instructions for new functions to use, * added `warnings.warn(category=DeprecationWarning)` to `pgraph_graph() and `networkx_graph()` functions.
wbkboyer
left a comment
There was a problem hiding this comment.
Looking great so far, Josh (@wheevu)! In addition to the changes requested, could you locally run
pylint --disable="invalid-name,missing-class-docstring,missing-function-docstring,missing-module-docstring,import-error" tests/test_express_api_conversions.py
And resolve the warnings? For the global-statement, undefined-variable, and import-outside-toplevel, if there's no better way to handle testing for networkx in the test environment and skipping the test if it's not present, then you can # pylint: disable=... on those lines!
|
Thanks, Wanda @wbkboyer! 😄 I addressed your comments in |
…cit dependencies such as networkx, matplotlib, or PIL (pillow) are installed in the test environment. `@pytest.mark.skipif()` can be used to decorate individual tests or a class of tests so that these skips appear in the `pytest -vvv` output. The alternative, `pytest.importorskip()`, will cause the entire test module to be skipped, and to only report the skips during the *collection* phase rather than when running *only if* you run `pytest` using flags `-rs`)
Right on, thank you for addressing those issues, @wheevu 🎉 I ended up making some additional changes ( |
Resolves #77
Type of change
Changes
convert_to_pgraph()andconvert_from_pgraph()for NetworkX, edge lists, and dictionaries of dictionaries, sets, or lists.planarity_functions.py, preserving the top-levelpgraph_graph()andnetworkx_graph()entry points.Direct imports of the old helpers from
planarity.express.planarity_networkxno longer work, as requested by the move.Top-level imports remain supported.
The compatibility comments omit the sentence about future docstrings because the new converters already have full docstrings.
Testing
The unchanged
tests/test_express_api_networkx.pypasses before and after:Before, master at 92e63d1
After