Skip to content

Commit

Permalink
Merge pull request #25 from unitaryfund/fix-import-no-shot-case
Browse files Browse the repository at this point in the history
Fix import in shots=None case
  • Loading branch information
WrathfulSpatula authored Oct 23, 2024
2 parents cc7a844 + 6a49e7d commit c5ce594
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pennylane_qrack/qrack_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import numpy as np

from pennylane import QubitDevice, DeviceError
from pennylane import QubitDevice, DeviceError, QuantumFunctionError
from pennylane.ops import (
QubitStateVector,
BasisState,
Expand Down Expand Up @@ -175,30 +175,30 @@ def get_c_interface():

def __init__(self, wires=0, shots=None, **kwargs):
options = dict(kwargs)
if 'isStabilizerHybrid' in options:
self.isStabilizerHybrid = options['isStabilizerHybrid']
if 'isTensorNetwork' in options:
self.isTensorNetwork = options['isTensorNetwork']
if 'isSchmidtDecompose' in options:
self.isSchmidtDecompose = options['isSchmidtDecompose']
if 'isBinaryDecisionTree' in options:
self.isBinaryDecisionTree = options['isBinaryDecisionTree']
if 'isOpenCL' in options:
self.isOpenCL = options['isOpenCL']
if 'isHostPointer' in options:
self.isHostPointer = options['isHostPointer']
if 'noise' in options:
self.noise = options['noise']
if "isStabilizerHybrid" in options:
self.isStabilizerHybrid = options["isStabilizerHybrid"]
if "isTensorNetwork" in options:
self.isTensorNetwork = options["isTensorNetwork"]
if "isSchmidtDecompose" in options:
self.isSchmidtDecompose = options["isSchmidtDecompose"]
if "isBinaryDecisionTree" in options:
self.isBinaryDecisionTree = options["isBinaryDecisionTree"]
if "isOpenCL" in options:
self.isOpenCL = options["isOpenCL"]
if "isHostPointer" in options:
self.isHostPointer = options["isHostPointer"]
if "noise" in options:
self.noise = options["noise"]
super().__init__(wires=wires, shots=shots)
self._state = QrackSimulator(
self.num_wires,
isStabilizerHybrid = self.isStabilizerHybrid,
isStabilizerHybrid=self.isStabilizerHybrid,
isTensorNetwork=self.isTensorNetwork,
isSchmidtDecompose=self.isSchmidtDecompose,
isBinaryDecisionTree=self.isBinaryDecisionTree,
isOpenCL=self.isOpenCL,
isHostPointer=self.isHostPointer,
noise = self.noise
noise=self.noise,
)

def _reverse_state(self):
Expand Down Expand Up @@ -649,7 +649,7 @@ def expval(self, observable, **kwargs):

def generate_samples(self):
if self.shots is None:
raise qml.QuantumFunctionError(
raise QuantumFunctionError(
"The number of shots has to be explicitly set on the device "
"when using sample-based measurements."
)
Expand Down

0 comments on commit c5ce594

Please sign in to comment.