Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BtoQ and BtoPS inverse, adjoint and dual (#497)
### **User description** **Context:** Currently. methods such as `inverse`, `adjoint` and `dual` do not return CircuitComponents of the same type. This can be an issue for things such as `BtoQ` and `BtoPS` where we want to still keep track that a representation change is happening. The solution presented here is to override these methods to return the appropriate type. **Description of the Change:** Override `inverse`, `dual` and `adjoint` on `BtoQ` and `BtoPS` such that they return the appropriate object types. Separated out `test_circuit_components_utils.py` ___ ### **PR Type** enhancement, tests ___ ### **Description** - Enhanced `BtoQ` and `BtoPS` classes by adding `adjoint`, `dual`, and `inverse` methods to ensure appropriate object types are returned. - Fixed a bug in the `__eq__` method of the `Circuit` class by correcting the return value. - Improved type checking in the `reorder_abc` function in `gaussian_integrals.py`. - Added comprehensive tests for `BtoPS`, `BtoQ`, and `TraceOut` classes to ensure functionality and correctness. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>b_to_ps.py</strong><dd><code>Implement adjoint, dual, and inverse methods for BtoPS</code> </dd></summary> <hr> mrmustard/lab_dev/circuit_components_utils/b_to_ps.py <li>Added <code>adjoint</code>, <code>dual</code>, and <code>inverse</code> methods to the <code>BtoPS</code> class.<br> <li> These methods ensure the return of appropriate object types.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-c530e576cf8965a0634d76cdd9dc2775fd218ee94278d8ea1f0bc7f9a65f28c2">+35/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>b_to_q.py</strong><dd><code>Implement adjoint, dual, and inverse methods for BtoQ</code> </dd></summary> <hr> mrmustard/lab_dev/circuit_components_utils/b_to_q.py <li>Added <code>adjoint</code>, <code>dual</code>, and <code>inverse</code> methods to the <code>BtoQ</code> class.<br> <li> These methods ensure the return of appropriate object types.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-ca88d1b44cdc56cd9f74c0a100800ae36547c5d76a3db2af91c9c8bd33565d6c">+33/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>gaussian_integrals.py</strong><dd><code>Enhance type checking in reorder_abc function</code> </dd></summary> <hr> mrmustard/physics/gaussian_integrals.py - Improved type checking in the `reorder_abc` function. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-a7b779ea109bae98fb3be0cb7ed5f6dba566d967f72666d24fbd01015f7962dc">+2/-2</a> </td> </tr> </table></td></tr><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>circuits.py</strong><dd><code>Fix return value bug in Circuit equality method</code> </dd></summary> <hr> mrmustard/lab_dev/circuits.py - Fixed a bug in the `__eq__` method by correcting the return value. </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-b2a78bf05544ee28bdbcc736c88ec4d7851cef12e34c9caab4ac98323a9028d7">+1/-1</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>test_b_to_ps.py</strong><dd><code>Add tests for BtoPS class methods</code> </dd></summary> <hr> tests/test_lab_dev/test_circuit_components_utils/test_b_to_ps.py <li>Added new tests for the <code>BtoPS</code> class.<br> <li> Tests cover initialization, adjoint, dual, inverse, and <br>representation.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-dc4893f24c7b72b4ebb606e0a8c5b6fab8a19dbc9eab592b2c4018c123174088">+137/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>test_b_to_q.py</strong><dd><code>Add tests for BtoQ class methods</code> </dd></summary> <hr> tests/test_lab_dev/test_circuit_components_utils/test_b_to_q.py <li>Added new tests for the <code>BtoQ</code> class.<br> <li> Tests cover adjoint, dual, inverse, and transformation correctness.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-ef330780848db87efb5e27f655eef3e67989039096d6e9fd00f9d225227c8817">+156/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>test_trace_out.py</strong><dd><code>Add tests for TraceOut class</code> </dd></summary> <hr> tests/test_lab_dev/test_circuit_components_utils/test_trace_out.py <li>Added new tests for the <code>TraceOut</code> class.<br> <li> Tests cover initialization and state tracing.<br> </details> </td> <td><a href="https://github.com/XanaduAI/MrMustard/pull/497/files#diff-af3a8a9f3790a0d3877b6deb46f7553d60c0c96e3da9b73cf29311d22a6d7b27">+71/-0</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information
- Loading branch information