src/quantuminspire/qiskit/backend_qx.py
def __convert_result_data(self, result: Dict[str, Any], measurements: Dict[str, Any]) -> Tuple[Obj, List[str]]:
        """ The quantum inspire backend returns the single shot values as raw data. This function
            converts this list of single shot values to hexadecimal memory data according the Qiskit spec.
            From this memory data the counts histogram is constructed by counting the single shot values.

        Note:
            When shots = 1, the backend returns an empty list as raw_data. This is a special case. In this case the
            resulting memory data consists of 1 value and the count histogram consists of 1 instance of this value.
            To determine this value a random float is generated in the range [0, 1). With this random number the
            value from this probabilities histogram is taken where the added probabilities is greater this random
            number.
            Example: probability histogram is {[0x0, 0.2], [0x3, 0.4], [0x5, 0.1], [0x6, 0.3]}.
            When random is in the range [0, 0.2) the first value of the probability histogram is taken (0x0).
            When random is in the range [0.2, 0.6) the second value of the probability histogram is taken (0x3).
            When random is in the range [0.6, 0.7) the third value of the probability histogram is taken (0x5).
            When random is in the range [0.7, 1) the last value of the probability histogram is taken (0x6).

        Args:
            result: The result output from the quantum inspire backend with full-
                    state projection histogram output.
            measurements: The dictionary contains a measured qubits/classical bits map (list) and the
                          number of classical bits (int).

        Returns:
            The result consists of two formats for the result. The first result is the histogram with count data,
            the second result is a list with converted hexadecimal memory values for each shot.
        """
        memory_data = []
        histogram_data: Dict[str, int] = defaultdict(lambda: 0)
        number_of_qubits: int = result['number_of_qubits']
        raw_data = self.__api.get_raw_data_from_result(result['id'])
        if raw_data:
            for raw_qubit_register in raw_data:
                classical_state_hex = QuantumInspireBackend.__qubit_to_classical_hex(str(raw_qubit_register),
                                                                                     measurements, number_of_qubits)
                memory_data.append(classical_state_hex)
            histogram_data = {elem: count for elem, count in Counter(memory_data).items()}
        else:
            state_probabilities = result['histogram']
            random_probability = np.random.rand()
            sum_probability = 0.0
            for qubit_register, probability in state_probabilities.items():
                sum_probability += probability
                if random_probability < sum_probability:
                    classical_state_hex = QuantumInspireBackend.__qubit_to_classical_hex(qubit_register, measurements,
                                                                                         number_of_qubits)
                    memory_data.append(classical_state_hex)
                    histogram_data[classical_state_hex] = 1
                    break

        sorted_histogram_data: List[Tuple[str, int]] = sorted(histogram_data.items(), key=lambda kv: int(kv[0], 16))
        histogram_obj = OrderedDict(sorted_histogram_data)
        return Obj.from_dict(histogram_obj), memory_data
 The quantum inspire backend returns the single shot values as raw data. This function
            converts this list of single shot values to hexadecimal memory data according the Qiskit spec.
            From this memory data the counts histogram is constructed by counting the single shot values.

        Note:
            When shots = 1, the backend returns an empty list as raw_data. This is a special case. In this case the
            resulting memory data consists of 1 value and the count histogram consists of 1 instance of this value.
            To determine this value a random float is generated in the range [0, 1). With this random number the
            value from this probabilities histogram is taken where the added probabilities is greater this random
            number.
            Example: probability histogram is {[0x0, 0.2], [0x3, 0.4], [0x5, 0.1], [0x6, 0.3]}.
            When random is in the range [0, 0.2) the first value of the probability histogram is taken (0x0).
            When random is in the range [0.2, 0.6) the second value of the probability histogram is taken (0x3).
            When random is in the range [0.6, 0.7) the third value of the probability histogram is taken (0x5).
            When random is in the range [0.7, 1) the last value of the probability histogram is taken (0x6).

        Args:
            result: The result output from the quantum inspire backend with full-
                    state projection histogram output.
            measurements: The dictionary contains a measured qubits/classical bits map (list) and the
                          number of classical bits (int).

        Returns:
            The result consists of two formats for the result. The first result is the histogram with count data,
            the second result is a list with converted hexadecimal memory values for each shot.
        
The quantum inspire backend returns the single shot values as raw data. This function
converts this list of single shot values to hexadecimal memory data according the Qiskit spec.
From this memory data the counts histogram is constructed by counting the single shot values.

When shots = 1, the backend returns an empty list as raw_data. This is a special case. In this case the
resulting memory data consists of 1 value and the count histogram consists of 1 instance of this value.
To determine this value a random float is generated in the range [0, 1). With this random number the
value from this probabilities histogram is taken where the added probabilities is greater this random
number.
The quantum inspire backend returns the single shot values as raw data . This function converts this list of single shot values to hexadecimal memory data according the Qiskit spec . From this memory data the counts histogram is constructed by counting the single shot values . When shots = 1 the backend returns an empty list as raw_data . This is a special case . In this case the resulting memory data consists of 1 value and the count histogram consists of 1 instance of this value . To determine this value a random float is generated in the range [ 0 1 ) . With this random number the value from this probabilities histogram is taken where the added probabilities is greater this random number .
def __convert_result_data(self, result: Dict[str, Any], measurements: Dict[str, Any]) -> Tuple[Obj, List[str]]:
        memory_data = []
        histogram_data: Dict[str, int] = defaultdict(lambda: 0)
        number_of_qubits: int = result['number_of_qubits']
        raw_data = self.__api.get_raw_data_from_result(result['id'])
        if raw_data:
            for raw_qubit_register in raw_data:
                classical_state_hex = QuantumInspireBackend.__qubit_to_classical_hex(str(raw_qubit_register),
                                                                                     measurements, number_of_qubits)
                memory_data.append(classical_state_hex)
            histogram_data = {elem: count for elem, count in Counter(memory_data).items()}
        else:
            state_probabilities = result['histogram']
            random_probability = np.random.rand()
            sum_probability = 0.0
            for qubit_register, probability in state_probabilities.items():
                sum_probability += probability
                if random_probability < sum_probability:
                    classical_state_hex = QuantumInspireBackend.__qubit_to_classical_hex(qubit_register, measurements,
                                                                                         number_of_qubits)
                    memory_data.append(classical_state_hex)
                    histogram_data[classical_state_hex] = 1
                    break
        sorted_histogram_data: List[Tuple[str, int]] = sorted(histogram_data.items(), key=lambda kv: int(kv[0], 16))
        histogram_obj = OrderedDict(sorted_histogram_data)
        return Obj.from_dict(histogram_obj), memory_data
def __convert_result_data ( self , result : Dict [ str , Any ] , measurements : Dict [ str , Any ] ) -> Tuple [ Obj , List [ str ] ] : memory_data = [ ] histogram_data : Dict [ str , int ] = defaultdict ( lambda : 0 ) number_of_qubits : int = result [ 'number_of_qubits' ] raw_data = self . __api . get_raw_data_from_result ( result [ 'id' ] ) if raw_data : for raw_qubit_register in raw_data : classical_state_hex = QuantumInspireBackend . __qubit_to_classical_hex ( str ( raw_qubit_register ) , measurements , number_of_qubits ) memory_data . append ( classical_state_hex ) histogram_data = { elem : count for elem , count in Counter ( memory_data ) . items ( ) } else : state_probabilities = result [ 'histogram' ] random_probability = np . random . rand ( ) sum_probability = 0.0 for qubit_register , probability in state_probabilities . items ( ) : sum_probability += probability if random_probability < sum_probability : classical_state_hex = QuantumInspireBackend . __qubit_to_classical_hex ( qubit_register , measurements , number_of_qubits ) memory_data . append ( classical_state_hex ) histogram_data [ classical_state_hex ] = 1 break sorted_histogram_data : List [ Tuple [ str , int ] ] = sorted ( histogram_data . items ( ) , key = lambda kv : int ( kv [ 0 ] , 16 ) ) histogram_obj = OrderedDict ( sorted_histogram_data ) return Obj . from_dict ( histogram_obj ) , memory_data
The quantum inspire backend returns the single shot values as raw data.
The quantum inspire backend returns the single shot values as raw data .
""" The quantum inspire backend returns the single shot values as raw data. This function
            converts this list of single shot values to hexadecimal memory data according the Qiskit spec.
            From this memory data the counts histogram is constructed by counting the single shot values.

        Note:
            When shots = 1, the backend returns an empty list as raw_data. This is a special case. In this case the
            resulting memory data consists of 1 value and the count histogram consists of 1 instance of this value.
            To determine this value a random float is generated in the range [0, 1). With this random number the
            value from this probabilities histogram is taken where the added probabilities is greater this random
            number.
            Example: probability histogram is {[0x0, 0.2], [0x3, 0.4], [0x5, 0.1], [0x6, 0.3]}.
            When random is in the range [0, 0.2) the first value of the probability histogram is taken (0x0).
            When random is in the range [0.2, 0.6) the second value of the probability histogram is taken (0x3).
            When random is in the range [0.6, 0.7) the third value of the probability histogram is taken (0x5).
            When random is in the range [0.7, 1) the last value of the probability histogram is taken (0x6).

        Args:
            result: The result output from the quantum inspire backend with full-
                    state projection histogram output.
            measurements: The dictionary contains a measured qubits/classical bits map (list) and the
                          number of classical bits (int).

        Returns:
            The result consists of two formats for the result. The first result is the histogram with count data,
            the second result is a list with converted hexadecimal memory values for each shot.
        """
The result consists of two formats for the result. The first result is the histogram with count data,
the second result is a list with converted hexadecimal memory values for each shot.
The result consists of two formats for the result . The first result is the histogram with count data the second result is a list with converted hexadecimal memory values for each shot .
self
result
Dict[str, Any]
The result output from the quantum inspire backend with full
state projection histogram output.
The result output from the quantum inspire backend with full state projection histogram output .
measurements
Dict[str, Any]
The dictionary contains a measured qubits/classical bits map (list) and the
number of classical bits (int).
The dictionary contains a measured qubits / classical bits map ( list ) and the number of classical bits ( int ) .