-
Notifications
You must be signed in to change notification settings - Fork 80
Refactor Gate class (2) #328
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
Merged
BoxiLi
merged 117 commits into
qutip:gate_refactor
from
Mayank447:refactor-gate-class-2
Mar 11, 2026
Merged
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
a0922c6
Added Singleton design patter for non-parametric, non-controlled gates
Mayank447 48092e0
Make validate_control, validate_params as staticmethod, corrected some
Mayank447 be354e7
Moved certain abstract properties as class attribute in Gate class
Mayank447 cee446d
Deprecated gates.py
Mayank447 0d45d1d
Added __slots__ for optimization
Mayank447 da8da90
Added namespace to Gates
Mayank447 6ee5ca4
Resolved errors in qpe, vqa based on namespace
Mayank447 21f571a
Made Gate class not instantiable by default
Mayank447 4e52dd6
Add an additional test for qiskit backend
Mayank447 ab79f34
Added gate equivalence checking
Mayank447 1d64f8f
Renamed custom_gate, controlled_gate factory functions
Mayank447 e074634
separated controlled and parametric gate into their own files
Mayank447 bffbae9
run black
Mayank447 4f24efb
Removed get_qobj() static method from std controlled gates
Mayank447 a4594cf
Corrected a bug in controlled_gate for beyond two qubit controlled gates
Mayank447 1b0437b
Added some other standard gates
Mayank447 c645026
Added inverse for single qubit gates
Mayank447 7279957
Added tests for gate inverse of single qubit gate
Mayank447 46b7f12
Added gate inverse and tests for non-controlled two qubit gates
Mayank447 535cb8b
Added checks for unitary_gate method
Mayank447 06d8ca4
Use qutip_qip.operations.std import for std gates import
Mayank447 2fdde02
Added inverse method for controlled gates
Mayank447 8f20aeb
Minor change to argument ordering for ControlledGate
Mayank447 fd4214c
Added inverse gate test for TOFFOLI, FREDKIN
Mayank447 e9aa797
Corrected __setattr__ for Gate metaclass
Mayank447 f5aa421
Rename is_controlled_gate method to is_controlled
Mayank447 b31f5f4
Rename is_parametric_gate method to is_parametric
Mayank447 81c12d5
Fix dagger symbol in latex_str for gates
Mayank447 d28cd8d
Added further checks in add_gate
Mayank447 853a2c4
Renamed gates.py to old_gates.py
Mayank447 51978c5
Removed deprecated variables from expand_operator
Mayank447 470f58c
Removed deprecation for Gate, Measurement from circuit/ module
Mayank447 c7821d0
Remove precompute_unitary argument from CircuitSimulator
Mayank447 6d82f78
Rename inverse() method for Gate to inverse_gate()
Mayank447 e070a78
Add typehints to operations/utils.py
Mayank447 ff26e56
Minor changes
Mayank447 3bb9f7f
Corrected some latex_str for std gates
Mayank447 c5903a2
Added ctrl_value to ControlledGate class
Mayank447 cc54686
Remove mutable default values from function arguments
Mayank447 64bb346
Added slots=True to dataclasses
Mayank447 d1d15db
Add a ControlledParam Gate temporarily
Mayank447 348032e
Remove standard gates from operations
Mayank447 82a79ce
Made some of the std gates as ControllledParamGate
Mayank447 db68bc1
Made ControlledGate non-initialisable
Mayank447 b19272a
Added Dynamic Descriptors, Delegation to ControlledGate
Mayank447 5130d25
Deleted ControlledParamGate
Mayank447 77bc5eb
Resolved failing inverse gate tests
Mayank447 a0019dd
Corrected Metaclass for Gates
Mayank447 10a351c
Move hadamard_transform to utils
Mayank447 096573d
Replaced inverse_gate with inverse in Gate class
Mayank447 bebc64b
Add static method get_qobj, cache
Mayank447 9b6f022
Renamed std to gates
Mayank447 b54d6c2
Added __eq__, __hash__ to GateMetaclasses
Mayank447 c4fb138
Added caching single qubit parametrized gates
Mayank447 91e025b
Added caching for two qubit parametrized gates
Mayank447 6433f67
Added proper typehints for all standard gates
Mayank447 dc702df
Removed arg_value from ParametricGate
Mayank447 e84da96
Made the remaining tests pass based on removal of arg_value
Mayank447 ca8734c
Added a utils.py for helper functions
Mayank447 0d7af5d
Corrected several isInstance in the codebase
Mayank447 5026db4
Add setter method for arg_value
Mayank447 97540f3
Added expanded option in inverse method fort Parametric Gates
Mayank447 46b4f9b
Corrected typhinting for tuple[]
Mayank447 7b4cb9a
Add __hash__ method for Parametric Gates
Mayank447 a6f5d18
Added __eq__, __hash__ for Controlled Gates
Mayank447 11a889c
Remove __hash__ from Controlled, Parametric Gate as they are mutable
Mayank447 41e65d5
Made _compute_qobj() abstract in Parametric Gate
Mayank447 7f050a1
Renamed unitary_gate method to get_unitary_gate
Mayank447 ca44070
replace gate.name comparisions with actual gate comparision
Mayank447 4d63b1f
Added checks for input for add_gate method
Mayank447 242d5fb
Corrected inconsistency bt Gate and Type[Gate]
Mayank447 b14ed06
Added new standard gates to the colour theme
Mayank447 efa30db
Added new gates to qiskit converter
Mayank447 b7449ba
Added new standard gates to the docs
Mayank447 c40284d
Separated namespace from gates as a broader concept
Mayank447 e87100d
Added a NameSpaceRegistry functionality
Mayank447 7ee0f63
Use NameSpaceRegistry in Gate Meta class
Mayank447 b8889c0
Change the NameSpace dataclass
Mayank447 c37ac57
Replace .format with f-strings
Mayank447 5f2e5c8
Correct typing and added circuit.utils method to utils.py
Mayank447 03a483d
Corrected some minor typehinting as per Python 3.10 standards
Mayank447 67c2595
Added _namespace to all the standard gates and gate factory functions
Mayank447 d6814c1
NameSpace functionality working
Mayank447 b74497b
Move pytest.ini to root dir, make namespace a set
Mayank447 b1cbdaa
Minor fixes to tests, ControlledGate.inverse method
Mayank447 a3a1674
Fix the namespace mechanism
Mayank447 b90f53b
Corrected inverse method for controlled, parametrized gates
Mayank447 d7ab53a
Added a controlled gate registry mechanism
Mayank447 ad7782d
Add additional checks on Gate subclasses
Mayank447 880bc22
Corrected __hash__, __eq__ for Gate meta class
Mayank447 4dcd70e
Minor fix to inverse in ControlledGate
Mayank447 1a8f3d3
Minor remaining fixes
Mayank447 1cf0cf5
Fix bug in gate_product, move its logic to operations
Mayank447 d63d2db
Added test gates for which gates must raise an Error
Mayank447 f718e9c
Added more checks to __init_subclass__ in Gate class
Mayank447 fb80ef6
Added more tests for gates
Mayank447 15f8250
Add argument dtype to get_qobj() method
Mayank447 fd848b8
Added the functionality to remove elements from a namespace
Mayank447 100234d
Add checks on is_controlled, is_parametric method
Mayank447 403d656
Minor code ordering change in add_gate method
Mayank447 c5ca576
Add test for add_gate method in test_circuit.py
Mayank447 93dcaa0
Rename controlled to get_controlled_gate
Mayank447 45ebe81
Fix __hash__
Mayank447 6b10f95
Removed redundant CNOT in the codebase
Mayank447 43ec959
Correct several isinstances
Mayank447 3f4cd43
Minor fixes as per recommendation
Mayank447 25bd01a
Added more comments, docstring for gateclass
Mayank447 8b78eac
Minor Fixes to gate class design
Mayank447 c495ea2
Added gate.name in pulse compiler with gate_class
Mayank447 03c9f69
Added CSdag, CTdag gates
Mayank447 db49f47
Removed expanded from inverse() in Parametric Gates
Mayank447 6f0b7cf
Add inverse for standard controlled parametric gates
Mayank447 aae676a
Remove expanded from Parametric Gates
Mayank447 dd2b5ea
run black
Mayank447 4378e1f
Added a default inverse method for non-parametrized gates
Mayank447 0b1cd2f
Separated Identity and IDLE gate
Mayank447 5c7ac64
Add docstrings for namespace
Mayank447 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,19 @@ | ||
| [pytest] | ||
| markers = | ||
| slow: Mark a test as taking a long time to run, and so can be skipped with `pytest -m "not slow"`. | ||
| repeat(n): Repeat the given test 'n' times. | ||
| requires_cython: Mark that the given test requires Cython to be installed. Such tests will be skipped if Cython is not available. | ||
|
|
||
| filterwarnings = | ||
| error | ||
| ; ImportWarning: PyxImporter.find_spec() not found | ||
| ignore:PyxImporter:ImportWarning | ||
| ; DeprecationWarning: Please use `upcast` from the `scipy.sparse` namespace | ||
| ignore::DeprecationWarning:qutip.fastsparse*: | ||
| ignore::UserWarning: | ||
| ignore:matplotlib not found:UserWarning | ||
| ignore:the imp module is deprecated in favour of importlib:DeprecationWarning | ||
| ignore:Dedicated options class are no longer needed, options should be passed as dict to solvers.:FutureWarning | ||
| ignore::DeprecationWarning:qiskit.utils.algorithm_globals: | ||
| # Deprecation warning for python = 3.9 with matplotlib 3.9.4 | ||
| ignore:'mode' parameter is deprecated | ||
| # Deprecation warning for scipy disp interface, will be removed in scipy 1.18 | ||
| ignore:.*`disp` and `iprint` options.*L-BFGS-B.*deprecated.*:DeprecationWarning | ||
|
|
||
|
|
||
|
|
||
| pythonpath = src | ||
| testpaths = tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.