Repository navigation
Add text output to the Express drawing API - #112
Conversation
* Removed `cimport cython` since `@cython.embedsignature(False)` directive overrides are not necessary to exclude the "private" methods from the generated docs
* __**NOTE:**__ I had previously been worried that including `cimport cython` and using the `@cython.embedsignature(False)` directive would cause an `ImportError` when a consuming Python application is run in an environment without Cython installed, but local testing shows this doesn't appear to be the case. This is because when we `pip install`, the isolated build environment has `cython` installed as build dependency due to `requires` in `pyproject.toml`, and so the extensions get cythonized, so Cython isn't a runtime dependency.
* Restored `PGraph.ascii()` method and `ascii()` function docstrings with deprecation warning
* Removed hash-led copy of `PGraph.ascii()` docstring from `PGraph._draw_as_text()` with a note to copy the docstring over when we remove `PGraph.ascii()` method
* `PGraph.ascii()` now calls `PGraph.draw()` with `label_type='index'` and `output_type='text/plain'` rather than directly calling `PGraph._draw_as_text()`
* Reordered keyword arguments in calls to `PGraph.draw()` method and `draw()` function to match their function signatures
* Moved `PGraph._draw_as_text()` to reside between `PGraph.draw()` and `PGraph._draw_as_image()`
* Made sure to add cross-references to various methods and functions in docstrings
|
Hey @wheevu ! Thank you for your contribution; after merging in I'm going to have to pick up this review on Monday just to make sure I understand the added tests, because in particular I'm a bit confused by the check for the Can you verify that you're trying to ensure that if an Thank you for your patience, and again, thank you for tackling this work! 🎉 |
|
Hi @wbkboyer! Thank you for the warm welcome! 😄 The check prevents filename truncation in the C layer. Without the check,
Hope that clears things up a bit. Thanks again for your time! |
… indicate `ascii()` method and function are deprecated (but then filter those warnings in `pytest` using `pyproject.toml` `tool.pytest` section) When indicating a function is deprecated, use `version-deprecated` rather than `deprecated` because as of version 9.0 of sphinx, `deprecated` was deprecated and maintained as an alias for backwards compatibility (lol).
Oh right the heck on, that makes sense that since both (For my future reference) Python Null Character ( I think there's a couple other places this same safeguard (e.g. I've made a couple other fixes to docstrings in I still want to double-check the tests; thanks for your patience with this process! 🎉 <3 |
…)` to match method/function signature
…d some docstrings to tests to clarify underlying assumptions of the tests.
wbkboyer
left a comment
There was a problem hiding this comment.
Thank you again for your patience with this process, @wheevu ! I hope you can forgive me for all the suggested test name changes; I was trying to make sure they're consistent, and that they indicate precisely which path they're hitting, but please let me know what you think (e.g. more concise, consistent, and descriptive alternatives) 🎉
Also, if you think there's any subtleties that are hard to succinctly capture in the test names, may you please add short docstring that describes the various parameterizations or any assumptions that might be baked into the test?
Hi Josh (@wheevu), Wanda and I have talked through the comments, and Wanda is just going to make a few small changes documented in the comments, to expedite completion of this PR. I think we should leave out the docstring requirement for now because it's not on any of the other tests, and in these tests we have a good idea of what is being tested from the good method names being used. There were some very cool tests in here, Josh (also noted in the comments, some of which you'll have to dig into because the conversations are resolved). Thank you for taking on this enhancement (and the issues in your other PRs). |
Thanks, John and Wanda! I'll take some time to read through all the comments properly. There's a lot for me to learn from the discussion. I really appreciate you both working through this and taking care of the final changes. Glad the tests were useful! 😄 |
No worries at all; it's my (and our) pleasure!! It's wonderful to have help coming on on these issues, and your null byte detection and handling + unicode filename support are excellent finds! I'll go through and make the remainder of these small changes, then will get this merged in, so no need to do anything on your end <3 I'll keep ya posted if we need anything on the subsequent PRs 🎉 Thank you again, Josh (@wheevu ) |
Changed order of parameters so that `labels` comes after `output_type`which comes after `outfileName` in `PGraph.draw()` parameterization, so I updated all callers to this method, docstring order, tests, etc. Also updated all tests and examples calling `draw()` that include image configuration options so that they appear in the same order as the docstring + code. Added info for how to suppress DeprecationWarning in ascii() warning messages. Rearranged `Raises` blocks to try to capture the order in which one might encounter those exceptions in the code. Added extra assert to `test_label_type_index_matches_mapping_and_text_drawing()` since we know that when `outfileName` is `None`, we expect to receive a string.
Resolves #94
Adds
output_type='text/plain'to bothdraw()APIs.Text is returned as a string or written to a file.
Images stay the default, and
ascii()still works.Type of change
Changes
Added
tests/test_express_api_draw_text.pycovers text output, files, errors, and compatibility.tests/test_express_api_draw_documentation.pykeeps private helpers out of the API docs.Updated
ascii.pyis renamed todraw_as_text.py.Testing
pytest -vv: 118 passed on Python 3.11 and 3.14, macOS ARM64.Linux, Windows, Python 3.12, and Python 3.13 were not tested locally.