Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacfomg committed Sep 26, 2023
1 parent 833a612 commit 7045021
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/qibo/gates/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from qibo.backends import GlobalBackend
from qibo.config import raise_error

REQUIRED_FIELDS = ["name", "init_kwargs", "_target_qubits", "_control_qubits"]
REQUIRED_FIELDS_INIT_KWARGS = ["theta", "phi", "lam"]


class Gate:
"""The base class for gate implementation.
Expand Down Expand Up @@ -54,16 +57,14 @@ def __init__(self):
def to_json(self):
encoded = self.__dict__

required_fields = ["name", "init_kwargs", "_target_qubits", "_control_qubits"]
encoded_simple = {
key: value for key, value in encoded.items() if key in required_fields
key: value for key, value in encoded.items() if key in REQUIRED_FIELDS
}

required_fields_init_kwargs = ["theta", "phi", "lam"]
encoded_simple["init_kwargs"] = {
key: value
for key, value in encoded_simple["init_kwargs"].items()
if key in required_fields_init_kwargs
if key in REQUIRED_FIELDS_INIT_KWARGS
}

for value in encoded_simple:
Expand Down

0 comments on commit 7045021

Please sign in to comment.