Source code for qiskit_qec.geometry.model.qubit_data
# This code is part of Qiskit.## (C) Copyright IBM 2017, 2020## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Module for Qubit Data"""fromtypingimportUnion,List,TuplefromnumpyimportndarrayfromqiskitimportQiskitError
[docs]classQubitData:"""Class for containing qubit information"""def__init__(self)->None:"""Init Qubit Data"""# Vertex Dataself.operator={}# Vertex_id to operator list for given vertexself.qubit={}# vertex_id to qubit_idself.index={}# vertex_id to PauliList index# Edge Data# Wireframe Data# Face Dataself.face_colors={}# Face id to color str# Otherself.qubit_to_index={}# qubit_id to PauliList indexself.index_to_qubit={}# PauliList index to qubit_idself.data_arrays={}
[docs]defadd_data_array(self,data_array:Union[List,Tuple,ndarray],name:str)->None:"""Adds a data array to the QubitData class instance Args: data_array (Union[List, Tuple, ndarray]): _description_ name: string name of array """self.data_arrays[name]=data_array
[docs]defdel_data_array(self,name:str):"""Deletes a given data_array from the QubitData class instance Args: name (str): Name of data array to delete """try:delself.data_arrays[name]exceptKeyErroraskeyerror:raiseQiskitError(f"Data array {name} does not exist")fromkeyerror