Skip to content

Commit 12b88fe

Browse files
committed
adding validation to options.
1 parent 85f0cd4 commit 12b88fe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/bloqade/pyqrack/base.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ class PyQrackOptions(typing.TypedDict):
2626
isOpenCL: bool
2727

2828

29+
def _validate_pyqrack_options(options: PyQrackOptions) -> None:
30+
if options["isBinaryDecisionTree"] and options["isStabilizerHybrid"]:
31+
raise ValueError(
32+
"Cannot use both isBinaryDecisionTree and isStabilizerHybrid at the same time."
33+
)
34+
elif options["isTensorNetwork"] and options["isBinaryDecisionTree"]:
35+
raise ValueError(
36+
"Cannot use both isTensorNetwork and isBinaryDecisionTree at the same time."
37+
)
38+
elif options["isTensorNetwork"] and options["isStabilizerHybrid"]:
39+
raise ValueError(
40+
"Cannot use both isTensorNetwork and isStabilizerHybrid at the same time."
41+
)
42+
43+
2944
def _default_pyqrack_args() -> PyQrackOptions:
3045
return PyQrackOptions(
3146
qubitCount=-1,
@@ -45,6 +60,9 @@ class MemoryABC(abc.ABC):
4560
pyqrack_options: PyQrackOptions = field(default_factory=_default_pyqrack_args)
4661
sim_reg: "QrackSimulator" = field(init=False)
4762

63+
def __post_init__(self):
64+
_validate_pyqrack_options(self.pyqrack_options)
65+
4866
@abc.abstractmethod
4967
def allocate(self, n_qubits: int) -> tuple[int, ...]:
5068
"""Allocate `n_qubits` qubits and return their ids."""

0 commit comments

Comments
 (0)