-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the ipython_display side effect #531
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #531 +/- ##
===========================================
- Coverage 90.16% 90.14% -0.02%
===========================================
Files 101 101
Lines 6291 6302 +11
===========================================
+ Hits 5672 5681 +9
- Misses 619 621 +2
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Matt!
# Conflicts: # .pylintrc
**Context:** Objects with rich ipython displays do not render properly in interactive IPython **Description of the Change:** - Default to the plain repr in interactive IPython - sneak in a workflow fix to avoid code injection via branch name. check the ultralytics issue shared in #software-learning if you're curious **Benefits:** - No more funny HTML-like output for objects in interactive IPython **Possible Drawbacks:** - Perhaps there's a way to show graphics nicely within IPython? this should suffice, and you can open a notebook if you want plotly **Related GitHub Issues:** Fixes #509 ___ Enhancement, Tests ___ - Enhanced `_ipython_display_` methods across multiple modules to check for interactive IPython shell and default to `print(self)` for better display. - Added tests to verify the new behavior of `_ipython_display_` methods in interactive IPython environments. - Updated changelog to reflect the changes made for IPython display enhancements. - Modified GitHub workflows to use environment variables for S3 path handling. ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>6 files</summary><table> <tr> <td> <details> <summary><strong>circuit_components.py</strong><dd><code>Improve IPython display handling for circuit components</code> </dd></summary> <hr> mrmustard/lab_dev/circuit_components.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-05cc8f1f470b3eab23b8a8b1b1a628a97c87852722ea6b5408e1bb70efd4ab72">+4/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>dm.py</strong><dd><code>Enhance IPython display for density matrix class</code> </dd></summary> <hr> mrmustard/lab_dev/states/dm.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-17d0cf9d48cb14fcbaadec367030d4f41d5c782c2a069d5d9342569588e2ba38">+4/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>ket.py</strong><dd><code>Improve IPython display handling for ket class</code> </dd></summary> <hr> mrmustard/lab_dev/states/ket.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-065ae49c98ca8757bb66ef7763a81070e7b0eab2e0899ffebc2b4f2491d6df4e">+4/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>array_ansatz.py</strong><dd><code>Enhance IPython display for array ansatz</code> </dd></summary> <hr> mrmustard/physics/ansatz/array_ansatz.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-0ee29c8e80f195e801b8151282f2373ac1d6e3596bfe63d94391e642b6cb3365">+4/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>polyexp_ansatz.py</strong><dd><code>Improve IPython display handling for polyexp ansatz</code> </dd></summary> <hr> mrmustard/physics/ansatz/polyexp_ansatz.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-7c01e9c60d2d4a82b42f83c1e79989674c8a3a4a215091a23cfbfb7b4feca1c9">+4/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>wires.py</strong><dd><code>Enhance IPython display for wires class</code> </dd></summary> <hr> mrmustard/physics/wires.py <li>Added check for interactive IPython shell in <code>_ipython_display_</code> method.<br> <li> Default to <code>print(self)</code> for interactive shell.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-d2f4eccc13a81234643db11e5fd75e4eaabda4485c3276cdd67e94d5dd8109ea">+4/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td> <details> <summary><strong>test_circuit_components.py</strong><dd><code>Add tests for interactive IPython display in circuit components</code></dd></summary> <hr> tests/test_lab_dev/test_circuit_components.py - Added test for interactive IPython shell display. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-cf594d34002781ecbd6f00d55be035f5d6821af5cfde94038830e0e3ea5f5bc3">+10/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>test_array_ansatz.py</strong><dd><code>Add tests for interactive IPython display in array ansatz</code></dd></summary> <hr> tests/test_physics/test_ansatz/test_array_ansatz.py - Added test for interactive IPython shell display. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-d926ceee5a48b97d221e5d1498e5f0537206cdb274ea677293c3f9317adc1563">+10/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>test_polyexp_ansatz.py</strong><dd><code>Add tests for interactive IPython display in polyexp ansatz</code></dd></summary> <hr> tests/test_physics/test_ansatz/test_polyexp_ansatz.py - Added test for interactive IPython shell display. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-921ac6091261c146640c3b3df644134e8872df68078997207977cb7f4231f158">+10/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>test_wires.py</strong><dd><code>Add tests for interactive IPython display in wires class</code> </dd></summary> <hr> tests/test_physics/test_wires.py - Added test for interactive IPython shell display. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-0cb3b43d3b87f32a5224ac21fcc523336e77bf7ebc8d76fba4663846c3ac8175">+14/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1 files</summary><table> <tr> <td> <details> <summary><strong>CHANGELOG.md</strong><dd><code>Update changelog for IPython display enhancements</code> </dd></summary> <hr> .github/CHANGELOG.md <li>Updated changelog to include changes for interactive IPython display.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-2a22f598a15a364508bc9a475e6ec9df31958a753e9401fabaac8df4db5bd853">+3/-0</a> </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>2 files</summary><table> <tr> <td> <details> <summary><strong>tests_numpy.yml</strong><dd><code>Update S3 path handling in numpy tests workflow</code> </dd></summary> <hr> .github/workflows/tests_numpy.yml - Added environment variable for reference name in S3 path. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-d01653471e6afa1d9bb01bcfdc93e6cb34fc4d45c6143faa64089be7bd816943">+3/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>tests_tensorflow.yml</strong><dd><code>Update S3 path handling in tensorflow tests workflow</code> </dd></summary> <hr> .github/workflows/tests_tensorflow.yml - Added environment variable for reference name in S3 path. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/531/files#diff-5c93d09eab7d2e9e949ef7ad1fc187e89c23f1837f29f822cd5676aaf1e45fc8">+3/-1</a> </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information
User description
Context:
Objects with rich ipython displays do not render properly in interactive IPython
Description of the Change:
Benefits:
Possible Drawbacks:
Related GitHub Issues:
Fixes #509
PR Type
Enhancement, Tests
Description
_ipython_display_
methods across multiple modules to check for interactive IPython shell and default toprint(self)
for better display._ipython_display_
methods in interactive IPython environments.Changes walkthrough 📝
6 files
circuit_components.py
Improve IPython display handling for circuit components
mrmustard/lab_dev/circuit_components.py
_ipython_display_
method.print(self)
for interactive shell.dm.py
Enhance IPython display for density matrix class
mrmustard/lab_dev/states/dm.py
_ipython_display_
method.print(self)
for interactive shell.ket.py
Improve IPython display handling for ket class
mrmustard/lab_dev/states/ket.py
_ipython_display_
method.print(self)
for interactive shell.array_ansatz.py
Enhance IPython display for array ansatz
mrmustard/physics/ansatz/array_ansatz.py
_ipython_display_
method.print(self)
for interactive shell.polyexp_ansatz.py
Improve IPython display handling for polyexp ansatz
mrmustard/physics/ansatz/polyexp_ansatz.py
_ipython_display_
method.print(self)
for interactive shell.wires.py
Enhance IPython display for wires class
mrmustard/physics/wires.py
_ipython_display_
method.print(self)
for interactive shell.4 files
test_circuit_components.py
Add tests for interactive IPython display in circuit components
tests/test_lab_dev/test_circuit_components.py
test_array_ansatz.py
Add tests for interactive IPython display in array ansatz
tests/test_physics/test_ansatz/test_array_ansatz.py
test_polyexp_ansatz.py
Add tests for interactive IPython display in polyexp ansatz
tests/test_physics/test_ansatz/test_polyexp_ansatz.py
test_wires.py
Add tests for interactive IPython display in wires class
tests/test_physics/test_wires.py
1 files
CHANGELOG.md
Update changelog for IPython display enhancements
.github/CHANGELOG.md
2 files
tests_numpy.yml
Update S3 path handling in numpy tests workflow
.github/workflows/tests_numpy.yml
tests_tensorflow.yml
Update S3 path handling in tensorflow tests workflow
.github/workflows/tests_tensorflow.yml