"""Abstract base class for all noise models."""from__future__importannotationsimportabcfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:fromgraphix.channelsimportKrausChannelfromgraphix.simulatorimportPatternSimulator
[docs]classNoiseModel(abc.ABC):"""Abstract base class for all noise models."""data:PatternSimulator# shared by all objects of the child class.
[docs]defassign_simulator(self,simulator:PatternSimulator)->None:"""Assign a simulator to the noise model."""self.simulator=simulator
[docs]@abc.abstractmethoddefprepare_qubit(self)->KrausChannel:"""Return qubit to be added with preparation errors."""...
[docs]@abc.abstractmethoddefentangle(self)->KrausChannel:"""Apply noise to qubits that happens in the CZ gate process."""...
[docs]@abc.abstractmethoddefmeasure(self)->KrausChannel:"""Apply noise to qubits that happens in the measurement process."""...
[docs]@abc.abstractmethoddefbyproduct_x(self)->KrausChannel:"""Apply noise to qubits that happens in the X gate process."""...
[docs]@abc.abstractmethoddefbyproduct_z(self)->KrausChannel:"""Apply noise to qubits that happens in the Z gate process."""...
[docs]@abc.abstractmethoddefclifford(self)->KrausChannel:"""Apply noise to qubits that happens in the Clifford gate process."""# NOTE might be different depending on the gate....
[docs]@abc.abstractmethoddeftick_clock(self)->None:"""Notion of time in real devices - this is where we apply effect of T1 and T2. We assume commands that lie between 'T' commands run simultaneously on the device. """...