Conversation
|
|
There was a problem hiding this comment.
I left many comments:
- We control all the code, please don't
panic!orunwrap. ReturnResult<T, E>. - Python tests live in
tests/. We only use#[cfg(test)]inrustworkx-core. Either migrate the tests or remove them - For universal functions, please use
_rustworkx_dispatch. We don't need Python modules forgraph6,digraph6, andsparse6.
Please take a look at https://github.com/Qiskit/rustworkx/blob/main/CONTRIBUTING.md, especially for formatting, tests, and adding type annotations.
tests/test_graph6.py
Outdated
|
|
||
| def test_read_graph6_file(self): | ||
| """Test reading a graph from a graph6 file.""" | ||
| with tempfile.NamedTemporaryFile(mode="w", delete=False) as fd: |
There was a problem hiding this comment.
I don't see why the whole test couldn't exist within the with statement. I'd rather not have a os.remove statement and let tempfile deal with it
Example:
tests/test_graph6.py
Outdated
| content = f.read() | ||
| self.assertEqual(content, "C~") | ||
| finally: | ||
| os.remove(path) |
There was a problem hiding this comment.
Same comment for all occurrences
| def test_write_and_read_triangle(self): | ||
| g = rx.PyGraph() | ||
| g.add_nodes_from([None, None, None]) | ||
| g.add_edges_from([(0, 1, None), (1, 2, None), (0, 2, None)]) |
There was a problem hiding this comment.
or the directed equivalent.
https://www.rustworkx.org/dev/apiref/rustworkx.generators.complete_graph.html works as well for n=3
| with self.assertRaises(rx.Graph6ParseError): | ||
| rx.parse_graph6_size(bad_hdr) | ||
|
|
||
| def test_overflow(self): |
There was a problem hiding this comment.
A comment explaining this test would be great, especially bitwise manipulations
tests/test_sparse6.py
Outdated
| self.assertEqual(g2.num_edges(), g.num_edges()) | ||
|
|
||
|
|
||
| if __name__ == '__main__': # pragma: no cover |
There was a problem hiding this comment.
this is not necessary, you can remove it from all files. we use stestr python -m unittest also handles it AFAIK in our release
| @@ -0,0 +1,48 @@ | |||
| features: | |||
There was a problem hiding this comment.
Please read https://docs.openstack.org/reno/latest/user/usage.html#editing-a-release-note for the correct format of release notes
There was a problem hiding this comment.
used reno to generate one with nox -e docs compatible doc
src/graph6.rs
Outdated
| DiGraph(DiGraph), | ||
| } | ||
|
|
||
| let wrapped = std::panic::catch_unwind(|| { |
There was a problem hiding this comment.
Do not use std::panic::catch_unwind. If you need to return an error use, Result as a return type with Err. Not panic! or unwrap.
This will likely break with WASM.
rustworkx/digraph6.py
Outdated
| @@ -0,0 +1,30 @@ | |||
| """digraph6 format helpers. | |||
There was a problem hiding this comment.
Right now, this wrapper is pointless:
- For writing, see for the correct pattern
rustworkx/rustworkx/__init__.py
Line 2285 in 7318a80
- For reading, if the file format contains the hint: use the same pattern from . If it doesn't, then just have two functions
Line 1248 in 7318a80
digraph_read_graph6andgraph_read_graph6
There was a problem hiding this comment.
Removed graph6.py, digraph6.py, sparse6.py and use a write_graph6 function in init with _rustworkx_dispatch
src/digraph6.rs
Outdated
|
|
||
| #[pyfunction] | ||
| #[pyo3(signature=(digraph, path))] | ||
| pub fn digraph_write_graph6_file(digraph: Py<crate::digraph::PyDiGraph>, path: &str) -> PyResult<()> { |
There was a problem hiding this comment.
Just call the methods that write to file *_write_graph6, *_write_sparse6, etc. For methods that write to string, use to_str or from_str.
There was a problem hiding this comment.
The naming is now graph_write_graph6 digraph_write_graph6
|
Thanks @IvanIsCoding for all the suggestion |
https://github.com/Qiskit/rustworkx/issues/1496