def execute(experiments, backend,<EOL>basis_gates=None, coupling_map=None,  <EOL>backend_properties=None, initial_layout=None,<EOL>seed_transpiler=None, optimization_level=None, pass_manager=None,<EOL>qobj_id=None, qobj_header=None, shots=<NUM_LIT>,  <EOL>memory=False, max_credits=<NUM_LIT:10>, seed_simulator=None,<EOL>default_qubit_los=None, default_meas_los=None,  <EOL>schedule_los=None, meas_level=<NUM_LIT:2>, meas_return='<STR_LIT>',<EOL>memory_slots=None, memory_slot_size=<NUM_LIT:100>, rep_time=None, parameter_binds=None,<EOL>seed=None, seed_mapper=None,  <EOL>config=None, circuits=None,<EOL>**run_config):

if circuits is not None:<EOL><INDENT>experiments = circuits<EOL>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL><DEDENT>experiments = transpile(experiments,<EOL>basis_gates=basis_gates,<EOL>coupling_map=coupling_map,<EOL>backend_properties=backend_properties,<EOL>initial_layout=initial_layout,<EOL>seed_transpiler=seed_transpiler,<EOL>optimization_level=optimization_level,<EOL>backend=backend,<EOL>pass_manager=pass_manager,<EOL>seed_mapper=seed_mapper,  <EOL>)<EOL>qobj = assemble(experiments,<EOL>qobj_id=qobj_id,<EOL>qobj_header=qobj_header,<EOL>shots=shots,<EOL>memory=memory,<EOL>max_credits=max_credits,<EOL>seed_simulator=seed_simulator,<EOL>default_qubit_los=default_qubit_los,<EOL>default_meas_los=default_meas_los,<EOL>schedule_los=schedule_los,<EOL>meas_level=meas_level,<EOL>meas_return=meas_return,<EOL>memory_slots=memory_slots,<EOL>memory_slot_size=memory_slot_size,<EOL>rep_time=rep_time,<EOL>parameter_binds=parameter_binds,<EOL>backend=backend,<EOL>config=config,  <EOL>seed=seed,  <EOL>run_config=run_config<EOL>)<EOL>return backend.run(qobj, **run_config)<EOL>

Execute a list of circuits or pulse schedules on a backend.

    The execution is asynchronous, and a handle to a job instance is returned.

    Args:
        experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]):
            Circuit(s) or pulse schedule(s) to execute

        backend (BaseBackend):
            Backend to execute circuits on.
            Transpiler options are automatically grabbed from
            backend.configuration() and backend.properties().
            If any other option is explicitly set (e.g. coupling_map), it
            will override the backend's.

        basis_gates (list[str]):
            List of basis gate names to unroll to.
            e.g:
                ['u1', 'u2', 'u3', 'cx']
            If None, do not unroll.

        coupling_map (CouplingMap or list):
            Coupling map (perhaps custom) to target in mapping.
            Multiple formats are supported:
            a. CouplingMap instance

            b. list
                Must be given as an adjacency matrix, where each entry
                specifies all two-qubit interactions supported by backend
                e.g:
                    [[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]

        backend_properties (BackendProperties):
            Properties returned by a backend, including information on gate
            errors, readout errors, qubit coherence times, etc. For a backend
            that provides this information, it can be obtained with:
            ``backend.properties()``

        initial_layout (Layout or dict or list):
            Initial position of virtual qubits on physical qubits.
            If this layout makes the circuit compatible with the coupling_map
            constraints, it will be used.
            The final layout is not guaranteed to be the same, as the transpiler
            may permute qubits through swaps or other means.

            Multiple formats are supported:
            a. Layout instance

            b. dict
                virtual to physical:
                    {qr[0]: 0,
                     qr[1]: 3,
                     qr[2]: 5}

                physical to virtual:
                    {0: qr[0],
                     3: qr[1],
                     5: qr[2]}

            c. list
                virtual to physical:
                    [0, 3, 5]  # virtual qubits are ordered (in addition to named)

                physical to virtual:
                    [qr[0], None, None, qr[1], None, qr[2]]

        seed_transpiler (int):
            Sets random seed for the stochastic parts of the transpiler

        optimization_level (int):
            How much optimization to perform on the circuits.
            Higher levels generate more optimized circuits,
            at the expense of longer transpilation time.
                0: no optimization
                1: light optimization
                2: heavy optimization

        pass_manager (PassManager):
            The pass manager to use during transpilation. If this arg is present,
            auto-selection of pass manager based on the transpile options will be
            turned off and this pass manager will be used directly.

        qobj_id (str):
            String identifier to annotate the Qobj

        qobj_header (QobjHeader or dict):
            User input that will be inserted in Qobj header, and will also be
            copied to the corresponding Result header. Headers do not affect the run.

        shots (int):
            Number of repetitions of each circuit, for sampling. Default: 2014

        memory (bool):
            If True, per-shot measurement bitstrings are returned as well
            (provided the backend supports it). For OpenPulse jobs, only
            measurement level 2 supports this option. Default: False

        max_credits (int):
            Maximum credits to spend on job. Default: 10

        seed_simulator (int):
            Random seed to control sampling, for when backend is a simulator

        default_qubit_los (list):
            List of default qubit lo frequencies

        default_meas_los (list):
            List of default meas lo frequencies

        schedule_los (None or list[Union[Dict[PulseChannel, float], LoConfig]] or
                      Union[Dict[PulseChannel, float], LoConfig]):
            Experiment LO configurations

        meas_level (int):
            Set the appropriate level of the measurement output for pulse experiments.

        meas_return (str):
            Level of measurement data for the backend to return
            For `meas_level` 0 and 1:
                "single" returns information from every shot.
                "avg" returns average measurement output (averaged over number of shots).

        memory_slots (int):
            Number of classical memory slots used in this job.

        memory_slot_size (int):
            Size of each memory slot if the output is Level 0.

        rep_time (int): repetition time of the experiment in μs.
            The delay between experiments will be rep_time.
            Must be from the list provided by the device.

        parameter_binds (list[dict{Parameter: Value}]):
            List of Parameter bindings over which the set of experiments will be
            executed. Each list element (bind) should be of the form
            {Parameter1: value1, Parameter2: value2, ...}. All binds will be
            executed across all experiments, e.g. if parameter_binds is a
            length-n list, and there are m experiments, a total of m x n
            experiments will be run (one for each experiment/bind pair).

        seed (int):
            DEPRECATED in 0.8: use ``seed_simulator`` kwarg instead

        seed_mapper (int):
            DEPRECATED in 0.8: use ``seed_transpiler`` kwarg instead

        config (dict):
            DEPRECATED in 0.8: use run_config instead

        circuits (QuantumCircuit or list[QuantumCircuit]):
            DEPRECATED in 0.8: use ``experiments`` kwarg instead.

        run_config (dict):
            Extra arguments used to configure the run (e.g. for Aer configurable backends)
            Refer to the backend documentation for details on these arguments
            Note: for now, these keyword arguments will both be copied to the
            Qobj config, and passed to backend.run()

    Returns:
        BaseJob: returns job instance derived from BaseJob

    Raises:
        QiskitError: if the execution cannot be interpreted as either circuits or schedules


if len(str1) != len(str2):<EOL><INDENT>raise VisualizationError('<STR_LIT>')<EOL><DEDENT>return sum(s1 != s2 for s1, s2 in zip(str1, str2))<EOL>

Calculate the Hamming distance between two bit strings

    Args:
        str1 (str): First string.
        str2 (str): Second string.
    Returns:
        int: Distance between strings.
    Raises:
        VisualizationError: Strings not same length


def plot_histogram(data, figsize=(<NUM_LIT:7>, <NUM_LIT:5>), color=None, number_to_keep=None,<EOL>sort='<STR_LIT>', target_string=None,<EOL>legend=None, bar_labels=True, title=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>if sort not in VALID_SORTS:<EOL><INDENT>raise VisualizationError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif sort in DIST_MEAS.keys() and target_string is None:<EOL><INDENT>err_msg = '<STR_LIT>'<EOL>raise VisualizationError(err_msg)<EOL><DEDENT>if isinstance(data, dict):<EOL><INDENT>data = [data]<EOL><DEDENT>if legend and len(legend) != len(data):<EOL><INDENT>raise VisualizationError("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(len(legend), len(data)))<EOL><DEDENT>fig, ax = plt.subplots(figsize=figsize)<EOL>labels = list(sorted(<EOL>functools.reduce(lambda x, y: x.union(y.keys()), data, set())))<EOL>if number_to_keep is not None:<EOL><INDENT>labels.append('<STR_LIT>')<EOL><DEDENT>if sort in DIST_MEAS.keys():<EOL><INDENT>dist = []<EOL>for item in labels:<EOL><INDENT>dist.append(DIST_MEAS[sort](item, target_string))<EOL><DEDENT>labels = [list(x) for x in zip(*sorted(zip(dist, labels),<EOL>key=lambda pair: pair[<NUM_LIT:0>]))][<NUM_LIT:1>]<EOL><DEDENT>labels_dict = OrderedDict()<EOL>if color is None:<EOL><INDENT>color = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>elif isinstance(color, str):<EOL><INDENT>color = [color]<EOL><DEDENT>all_pvalues = []<EOL>length = len(data)<EOL>for item, execution in enumerate(data):<EOL><INDENT>if number_to_keep is not None:<EOL><INDENT>data_temp = dict(Counter(execution).most_common(number_to_keep))<EOL>data_temp["<STR_LIT>"] = sum(execution.values()) - sum(data_temp.values())<EOL>execution = data_temp<EOL><DEDENT>values = []<EOL>for key in labels:<EOL><INDENT>if key not in execution:<EOL><INDENT>if number_to_keep is None:<EOL><INDENT>labels_dict[key] = <NUM_LIT:1><EOL>values.append(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>values.append(-<NUM_LIT:1>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>labels_dict[key] = <NUM_LIT:1><EOL>values.append(execution[key])<EOL><DEDENT><DEDENT>values = np.array(values, dtype=float)<EOL>where_idx = np.where(values >= <NUM_LIT:0>)[<NUM_LIT:0>]<EOL>pvalues = values[where_idx] / sum(values[where_idx])<EOL>for value in pvalues:<EOL><INDENT>all_pvalues.append(value)<EOL><DEDENT>numelem = len(values[where_idx])<EOL>ind = np.arange(numelem)  <EOL>width = <NUM_LIT:1>/(len(data)+<NUM_LIT:1>)  <EOL>rects = []<EOL>for idx, val in enumerate(pvalues):<EOL><INDENT>label = None<EOL>if not idx and legend:<EOL><INDENT>label = legend[item]<EOL><DEDENT>if val >= <NUM_LIT:0>:<EOL><INDENT>rects.append(ax.bar(idx+item*width, val, width, label=label,<EOL>color=color[item % len(color)],<EOL>zorder=<NUM_LIT:2>))<EOL><DEDENT><DEDENT>bar_center = (width / <NUM_LIT:2>) * (length - <NUM_LIT:1>)<EOL>ax.set_xticks(ind + bar_center)<EOL>ax.set_xticklabels(labels_dict.keys(), fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL>if bar_labels:<EOL><INDENT>for rect in rects:<EOL><INDENT>for rec in rect:<EOL><INDENT>height = rec.get_height()<EOL>if height >= <NUM_LIT>:<EOL><INDENT>ax.text(rec.get_x() + rec.get_width() / <NUM_LIT>, <NUM_LIT> * height,<EOL>'<STR_LIT>' % float(height),<EOL>ha='<STR_LIT>', va='<STR_LIT>', zorder=<NUM_LIT:3>)<EOL><DEDENT>else:<EOL><INDENT>ax.text(rec.get_x() + rec.get_width() / <NUM_LIT>, <NUM_LIT> * height,<EOL>'<STR_LIT:0>',<EOL>ha='<STR_LIT>', va='<STR_LIT>', zorder=<NUM_LIT:3>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>ax.set_ylabel('<STR_LIT>', fontsize=<NUM_LIT>)<EOL>ax.set_ylim([<NUM_LIT:0.>, min([<NUM_LIT>, max([<NUM_LIT> * val for val in all_pvalues])])])<EOL>if sort == '<STR_LIT>':<EOL><INDENT>ax.invert_xaxis()<EOL><DEDENT>ax.yaxis.set_major_locator(MaxNLocator(<NUM_LIT:5>))<EOL>for tick in ax.yaxis.get_major_ticks():<EOL><INDENT>tick.label.set_fontsize(<NUM_LIT>)<EOL><DEDENT>ax.set_facecolor('<STR_LIT>')<EOL>plt.grid(which='<STR_LIT>', axis='<STR_LIT:y>', zorder=<NUM_LIT:0>, linestyle='<STR_LIT>')<EOL>if title:<EOL><INDENT>plt.title(title)<EOL><DEDENT>if legend:<EOL><INDENT>ax.legend(loc='<STR_LIT>', bbox_to_anchor=(<NUM_LIT>, <NUM_LIT:1.0>), ncol=<NUM_LIT:1>,<EOL>borderaxespad=<NUM_LIT:0>, frameon=True, fontsize=<NUM_LIT:12>)<EOL><DEDENT>if fig:<EOL><INDENT>plt.close(fig)<EOL><DEDENT>return fig<EOL>

Plot a histogram of data.

    Args:
        data (list or dict): This is either a list of dictionaries or a single
            dict containing the values to represent (ex {'001': 130})
        figsize (tuple): Figure size in inches.
        color (list or str): String or list of strings for histogram bar colors.
        number_to_keep (int): The number of terms to plot and rest
            is made into a single bar called 'rest'.
        sort (string): Could be 'asc', 'desc', or 'hamming'.
        target_string (str): Target string if 'sort' is a distance measure.
        legend(list): A list of strings to use for labels of the data.
            The number of entries must match the length of data (if data is a
            list or 1 if it's a dict)
        bar_labels (bool): Label each bar in histogram with probability value.
        title (str): A string to use for the plot title

    Returns:
        matplotlib.Figure: A figure for the rendered histogram.

    Raises:
        ImportError: Matplotlib not available.
        VisualizationError: When legend is provided and the length doesn't
            match the input data.


<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>options = {}<EOL><DEDENT>else:<EOL><INDENT>options = {'<STR_LIT:width>': figsize[<NUM_LIT:0>], '<STR_LIT>': figsize[<NUM_LIT:1>]}<EOL><DEDENT>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>real = []<EOL>imag = []<EOL>for xvalue in rho:<EOL><INDENT>row_real = []<EOL>col_imag = []<EOL>for value_real in xvalue.real:<EOL><INDENT>row_real.append(float(value_real))<EOL><DEDENT>real.append(row_real)<EOL>for value_imag in xvalue.imag:<EOL><INDENT>col_imag.append(float(value_imag))<EOL><DEDENT>imag.append(col_imag)<EOL><DEDENT>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': [{'<STR_LIT:data>': real}, {'<STR_LIT:data>': imag}],<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a hinton representation.

        Graphical representation of the input array using a 2D city style
        graph (hinton).

        Args:
            rho (array): Density matrix
            figsize (tuple): Figure size in pixels.


def iplot_state(quantum_state, method='<STR_LIT>', figsize=None):

warnings.warn("<STR_LIT>",<EOL>DeprecationWarning)<EOL>rho = _validate_input_state(quantum_state)<EOL>if method == "<STR_LIT>":<EOL><INDENT>iplot_state_city(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>iplot_state_paulivec(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>iplot_state_qsphere(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>iplot_bloch_multivector(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>iplot_state_hinton(rho, figsize=figsize)<EOL><DEDENT>else:<EOL><INDENT>raise VisualizationError('<STR_LIT>')<EOL><DEDENT>

Plot the quantum state.

    Args:
        quantum_state (ndarray): statevector or density matrix
                                 representation of a quantum state.
        method (str): Plotting method to use.
        figsize (tuple): Figure size in pixels.

    Raises:
        VisualizationError: if the input is not a statevector or density
        matrix, or if the state is not an multi-qubit quantum state.


<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>options = {}<EOL><DEDENT>else:<EOL><INDENT>options = {'<STR_LIT:width>': figsize[<NUM_LIT:0>], '<STR_LIT>': figsize[<NUM_LIT:1>]}<EOL><DEDENT>num = int(np.log2(len(rho)))<EOL>bloch_data = []<EOL>for i in range(num):<EOL><INDENT>pauli_singles = [Pauli.pauli_single(num, i, '<STR_LIT:X>'), Pauli.pauli_single(num, i, '<STR_LIT:Y>'),<EOL>Pauli.pauli_single(num, i, '<STR_LIT>')]<EOL>bloch_state = list(map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),<EOL>pauli_singles))<EOL>bloch_data.append(bloch_state)<EOL><DEDENT>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT:data>': bloch_data,<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a bloch sphere representation.

        Graphical representation of the input array, using as much bloch
        spheres as qubit are required.

        Args:
            rho (array): State vector or density matrix
            figsize (tuple): Figure size in pixels.


<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>options = {}<EOL><DEDENT>else:<EOL><INDENT>options = {'<STR_LIT:width>': figsize[<NUM_LIT:0>], '<STR_LIT>': figsize[<NUM_LIT:1>]}<EOL><DEDENT>qspheres_data = []<EOL>num = int(np.log2(len(rho)))<EOL>weig, stateall = linalg.eigh(rho)<EOL>for _ in range(<NUM_LIT:2>**num):<EOL><INDENT>probmix = weig.max()<EOL>prob_location = weig.argmax()<EOL>if probmix > <NUM_LIT>:<EOL><INDENT>state = stateall[:, prob_location]<EOL>loc = np.absolute(state).argmax()<EOL>for j in range(<NUM_LIT:2>**num):<EOL><INDENT>test = np.absolute(np.absolute(state[j]) -<EOL>np.absolute(state[loc]))<EOL>if test < <NUM_LIT>:<EOL><INDENT>loc = j<EOL>break<EOL><DEDENT><DEDENT>angles = (np.angle(state[loc]) + <NUM_LIT:2> * np.pi) % (<NUM_LIT:2> * np.pi)<EOL>angleset = np.exp(-<NUM_LIT>*angles)<EOL>state = angleset*state<EOL>state.flatten()<EOL>spherepoints = []<EOL>for i in range(<NUM_LIT:2>**num):<EOL><INDENT>element = bin(i)[<NUM_LIT:2>:].zfill(num)<EOL>weight = element.count("<STR_LIT:1>")<EOL>number_of_divisions = n_choose_k(num, weight)<EOL>weight_order = bit_string_index(element)<EOL>angle = weight_order * <NUM_LIT:2> * np.pi / number_of_divisions<EOL>zvalue = -<NUM_LIT:2> * weight / num + <NUM_LIT:1><EOL>xvalue = np.sqrt(<NUM_LIT:1> - zvalue**<NUM_LIT:2>) * np.cos(angle)<EOL>yvalue = np.sqrt(<NUM_LIT:1> - zvalue**<NUM_LIT:2>) * np.sin(angle)<EOL>prob = np.real(np.dot(state[i], state[i].conj()))<EOL>angles = (np.angle(state[i]) + <NUM_LIT:2> * np.pi) % (<NUM_LIT:2> * np.pi)<EOL>qpoint = {<EOL>'<STR_LIT:x>': xvalue,<EOL>'<STR_LIT:y>': yvalue,<EOL>'<STR_LIT:z>': zvalue,<EOL>'<STR_LIT>': prob,<EOL>'<STR_LIT>': angles<EOL>}<EOL>spherepoints.append(qpoint)<EOL><DEDENT>sphere = {<EOL>'<STR_LIT>': spherepoints,<EOL>'<STR_LIT>': probmix<EOL>}<EOL>qspheres_data.append(sphere)<EOL>weig[prob_location] = <NUM_LIT:0><EOL><DEDENT><DEDENT>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT:data>': qspheres_data,<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a Q sphere representation.

        Graphical representation of the input array, using a Q sphere for each
        eigenvalue.

        Args:
            rho (array): State vector or density matrix.
            figsize (tuple): Figure size in pixels.


if n == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>return reduce(lambda x, y: x * y[<NUM_LIT:0>] / y[<NUM_LIT:1>],<EOL>zip(range(n - k + <NUM_LIT:1>, n + <NUM_LIT:1>),<EOL>range(<NUM_LIT:1>, k + <NUM_LIT:1>)), <NUM_LIT:1>)<EOL>

Return the number of combinations for n choose k.

    Args:
        n (int): the total number of options .
        k (int): The number of elements.

    Returns:
        int: returns the binomial coefficient


n = len(text)<EOL>k = text.count("<STR_LIT:1>")<EOL>if text.count("<STR_LIT:0>") != n - k:<EOL><INDENT>raise VisualizationError("<STR_LIT>")<EOL><DEDENT>ones = [pos for pos, char in enumerate(text) if char == "<STR_LIT:1>"]<EOL>return lex_index(n, k, ones)<EOL>

Return the index of a string of 0s and 1s.


if len(lst) != k:<EOL><INDENT>raise VisualizationError("<STR_LIT>")<EOL><DEDENT>comb = list(map(lambda x: n - <NUM_LIT:1> - x, lst))<EOL>dualm = sum([n_choose_k(comb[k - <NUM_LIT:1> - i], i + <NUM_LIT:1>) for i in range(k)])<EOL>return int(dualm)<EOL>

Return  the lex index of a combination..

    Args:
        n (int): the total number of options .
        k (int): The number of elements.
        lst (list): list

    Returns:
        int: returns int index for lex order

    Raises:
        VisualizationError: if length of list is not equal to k


result = dict()<EOL>num = int(np.log2(len(rho)))<EOL>labels = list(map(lambda x: x.to_label(), pauli_group(num)))<EOL>values = list(map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),<EOL>pauli_group(num)))<EOL>for position, label in enumerate(labels):<EOL><INDENT>result[label] = values[position]<EOL><DEDENT>return result<EOL>


def iplot_state_paulivec(rho, figsize=None, slider=False, show_legend=False):

<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:7>, <NUM_LIT:5>)<EOL><DEDENT>options = {'<STR_LIT:width>': figsize[<NUM_LIT:0>], '<STR_LIT>': figsize[<NUM_LIT:1>],<EOL>'<STR_LIT>': int(slider), '<STR_LIT>': int(show_legend)}<EOL>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>data_to_plot = []<EOL>rho_data = process_data(rho)<EOL>data_to_plot.append(dict(<EOL>data=rho_data<EOL>))<EOL>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': data_to_plot,<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a paulivec representation.

        Graphical representation of the input array.

        Args:
            rho (array): State vector or density matrix.
            figsize (tuple): Figure size in pixels.
            slider (bool): activate slider
            show_legend (bool): show legend of graph content


result = dict()<EOL>if number_to_keep != <NUM_LIT:0>:<EOL><INDENT>data_temp = dict(Counter(data).most_common(number_to_keep))<EOL>data_temp['<STR_LIT>'] = sum(data.values()) - sum(data_temp.values())<EOL>data = data_temp<EOL><DEDENT>labels = data<EOL>values = np.array([data[key] for key in labels], dtype=float)<EOL>pvalues = values / sum(values)<EOL>for position, label in enumerate(labels):<EOL><INDENT>result[label] = round(pvalues[position], <NUM_LIT:5>)<EOL><DEDENT>return result<EOL>

Prepare received data for representation.

        Args:
            data (dict): values to represent (ex. {'001' : 130})
            number_to_keep (int): number of elements to show individually.

        Returns:
            dict: processed data to show.


def iplot_histogram(data, figsize=None, number_to_keep=None,<EOL>sort='<STR_LIT>', legend=None):

<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:7>, <NUM_LIT:5>)<EOL><DEDENT>options = {'<STR_LIT>': <NUM_LIT:0> if number_to_keep is None else number_to_keep,<EOL>'<STR_LIT>': sort,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>'<STR_LIT:width>': int(figsize[<NUM_LIT:0>]),<EOL>'<STR_LIT>': int(figsize[<NUM_LIT:1>])}<EOL>if legend:<EOL><INDENT>options['<STR_LIT>'] = <NUM_LIT:1><EOL><DEDENT>data_to_plot = []<EOL>if isinstance(data, dict):<EOL><INDENT>data = [data]<EOL><DEDENT>if legend and len(legend) != len(data):<EOL><INDENT>raise VisualizationError("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>(len(legend), len(data)))<EOL><DEDENT>for item, execution in enumerate(data):<EOL><INDENT>exec_data = process_data(execution, options['<STR_LIT>'])<EOL>out_dict = {'<STR_LIT:data>': exec_data}<EOL>if legend:<EOL><INDENT>out_dict['<STR_LIT:name>'] = legend[item]<EOL><DEDENT>data_to_plot.append(out_dict)<EOL><DEDENT>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': data_to_plot,<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a histogram representation.

        Graphical representation of the input array using a vertical bars
        style graph.

        Args:
            data (list or dict):  This is either a list of dicts or a single
                dict containing the values to represent (ex. {'001' : 130})
            figsize (tuple): Figure size in pixels.
            number_to_keep (int): The number of terms to plot and
                rest is made into a single bar called other values
            sort (string): Could be 'asc' or 'desc'
            legend (list): A list of strings to use for labels of the data.
                The number of entries must match the length of data.
        Raises:
            VisualizationError: When legend is provided and the length doesn't
                match the input data.


<EOL>html_template = Template("""<STR_LIT>""")<EOL>javascript_template = Template("""<STR_LIT>""")<EOL>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>options = {}<EOL><DEDENT>else:<EOL><INDENT>options = {'<STR_LIT:width>': figsize[<NUM_LIT:0>], '<STR_LIT>': figsize[<NUM_LIT:1>]}<EOL><DEDENT>real = []<EOL>imag = []<EOL>for xvalue in rho:<EOL><INDENT>row_real = []<EOL>col_imag = []<EOL>for value_real in xvalue.real:<EOL><INDENT>row_real.append(float(value_real))<EOL><DEDENT>real.append(row_real)<EOL>for value_imag in xvalue.imag:<EOL><INDENT>col_imag.append(float(value_imag))<EOL><DEDENT>imag.append(col_imag)<EOL><DEDENT>div_number = str(time.time())<EOL>div_number = re.sub('<STR_LIT>', '<STR_LIT>', div_number)<EOL>html = html_template.substitute({<EOL>'<STR_LIT>': div_number<EOL>})<EOL>javascript = javascript_template.substitute({<EOL>'<STR_LIT>': real,<EOL>'<STR_LIT>': imag,<EOL>'<STR_LIT>': len(real),<EOL>'<STR_LIT>': div_number,<EOL>'<STR_LIT>': options<EOL>})<EOL>display(HTML(html + javascript))<EOL>

Create a cities representation.

        Graphical representation of the input array using a city style graph.

        Args:
            rho (array): State vector or density matrix.
            figsize (tuple): The figure size in pixels.


image = None<EOL>if output == '<STR_LIT:text>':<EOL><INDENT>return _text_circuit_drawer(circuit, filename=filename,<EOL>line_length=line_length,<EOL>reverse_bits=reverse_bits,<EOL>plotbarriers=plot_barriers,<EOL>justify=justify)<EOL><DEDENT>elif output == '<STR_LIT>':<EOL><INDENT>image = _latex_circuit_drawer(circuit, scale=scale,<EOL>filename=filename, style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL><DEDENT>elif output == '<STR_LIT>':<EOL><INDENT>return _generate_latex_source(circuit,<EOL>filename=filename, scale=scale,<EOL>style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL><DEDENT>elif output == '<STR_LIT>':<EOL><INDENT>image = _matplotlib_circuit_drawer(circuit, scale=scale,<EOL>filename=filename, style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL><DEDENT>else:<EOL><INDENT>raise exceptions.VisualizationError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % output)<EOL><DEDENT>if image and interactive:<EOL><INDENT>image.show()<EOL><DEDENT>return image<EOL>

Draw a quantum circuit to different formats (set by output parameter):
    0. text: ASCII art TextDrawing that can be printed in the console.
    1. latex: high-quality images, but heavy external software dependencies
    2. matplotlib: purely in Python with no external dependencies

    Args:
        circuit (QuantumCircuit): the quantum circuit to draw
        scale (float): scale of image to draw (shrink if < 1)
        filename (str): file path to save image to
        style (dict or str): dictionary of style or file name of style file.
            This option is only used by the `mpl`, `latex`, and `latex_source`
            output types. If a str is passed in that is the path to a json
            file which contains that will be open, parsed, and then used just
            as the input dict.
        output (TextDrawing): Select the output method to use for drawing the circuit.
            Valid choices are `text`, `latex`, `latex_source`, `mpl`. Note if
            one is not specified it will use latex and if that fails fallback
            to mpl. However this behavior is deprecated and in a future release
            the default will change.
        interactive (bool): when set true show the circuit in a new window
            (for `mpl` this depends on the matplotlib backend being used
            supporting this). Note when used with either the `text` or the
            `latex_source` output type this has no effect and will be silently
            ignored.
        line_length (int): Sets the length of the lines generated by `text`
            output type. This useful when the drawing does not fit in the
            console. If None (default), it will try to guess the console width
            using shutil.get_terminal_size(). However, if you're running in
            jupyter the default line length is set to 80 characters. If you
            don't want pagination at all, set `line_length=-1`.
        reverse_bits (bool): When set to True reverse the bit order inside
            registers for the output visualization.
        plot_barriers (bool): Enable/disable drawing barriers in the output
            circuit. Defaults to True.
        justify (string): Options are `left`, `right` or `none`, if anything
            else is supplied it defaults to left justified. It refers to where
            gates should be placed in the output circuit if there is an option.
            `none` results in each gate being placed in its own column. Currently
            only supported by text drawer.

    Returns:
        PIL.Image: (output `latex`) an in-memory representation of the image
            of the circuit diagram.
        matplotlib.figure: (output `mpl`) a matplotlib figure object for the
            circuit diagram.
        String: (output `latex_source`). The LaTeX source code.
        TextDrawing: (output `text`). A drawing that can be printed as ascii art
    Raises:
        VisualizationError: when an invalid output method is selected
        ImportError: when the output methods requieres non-installed libraries.

    .. _style-dict-doc:

    The style dict kwarg contains numerous options that define the style of the
    output circuit visualization. While the style dict is used by the `mpl`,
    `latex`, and `latex_source` outputs some options in that are only used
    by the `mpl` output. These options are defined below, if it is only used by
    the `mpl` output it is marked as such:

        textcolor (str): The color code to use for text. Defaults to
            `'#000000'` (`mpl` only)
        subtextcolor (str): The color code to use for subtext. Defaults to
            `'#000000'` (`mpl` only)
        linecolor (str): The color code to use for lines. Defaults to
            `'#000000'` (`mpl` only)
        creglinecolor (str): The color code to use for classical register lines
            `'#778899'`(`mpl` only)
        gatetextcolor (str): The color code to use for gate text `'#000000'`
            (`mpl` only)
        gatefacecolor (str): The color code to use for gates. Defaults to
            `'#ffffff'` (`mpl` only)
        barrierfacecolor (str): The color code to use for barriers. Defaults to
            `'#bdbdbd'` (`mpl` only)
        backgroundcolor (str): The color code to use for the background.
            Defaults to `'#ffffff'` (`mpl` only)
        fontsize (int): The font size to use for text. Defaults to 13 (`mpl`
            only)
        subfontsize (int): The font size to use for subtext. Defaults to 8
            (`mpl` only)
        displaytext (dict): A dictionary of the text to use for each element
            type in the output visualization. The default values are:
            {
                'id': 'id',
                'u0': 'U_0',
                'u1': 'U_1',
                'u2': 'U_2',
                'u3': 'U_3',
                'x': 'X',
                'y': 'Y',
                'z': 'Z',
                'h': 'H',
                's': 'S',
                'sdg': 'S^\\dagger',
                't': 'T',
                'tdg': 'T^\\dagger',
                'rx': 'R_x',
                'ry': 'R_y',
                'rz': 'R_z',
                'reset': '\\left|0\\right\\rangle'
            }
            You must specify all the necessary values if using this. There is
            no provision for passing an incomplete dict in. (`mpl` only)
        displaycolor (dict): The color codes to use for each circuit element.
            By default all values default to the value of `gatefacecolor` and
            the keys are the same as `displaytext`. Also, just like
            `displaytext` there is no provision for an incomplete dict passed
            in. (`mpl` only)
        latexdrawerstyle (bool): When set to True enable latex mode which will
            draw gates like the `latex` output modes. (`mpl` only)
        usepiformat (bool): When set to True use radians for output (`mpl`
            only)
        fold (int): The number of circuit elements to fold the circuit at.
            Defaults to 20 (`mpl` only)
        cregbundle (bool): If set True bundle classical registers (`mpl` only)
        showindex (bool): If set True draw an index. (`mpl` only)
        compress (bool): If set True draw a compressed circuit (`mpl` only)
        figwidth (int): The maximum width (in inches) for the output figure.
            (`mpl` only)
        dpi (int): The DPI to use for the output image. Defaults to 150 (`mpl`
            only)
        margin (list): `mpl` only
        creglinestyle (str): The style of line to use for classical registers.
            Choices are `'solid'`, `'doublet'`, or any valid matplotlib
            `linestyle` kwarg value. Defaults to `doublet`(`mpl` only)


return {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": <NUM_LIT:20>,<EOL>"<STR_LIT>": <NUM_LIT>,<EOL>"<STR_LIT>": <NUM_LIT:8>,<EOL>"<STR_LIT>": -<NUM_LIT:1>,<EOL>"<STR_LIT>": <NUM_LIT>,<EOL>"<STR_LIT>": {<EOL>"<STR_LIT:id>": "<STR_LIT:id>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:x>": "<STR_LIT:X>",<EOL>"<STR_LIT:y>": "<STR_LIT:Y>",<EOL>"<STR_LIT:z>": "<STR_LIT>",<EOL>"<STR_LIT:h>": "<STR_LIT:H>",<EOL>"<STR_LIT:s>": "<STR_LIT:S>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:t>": "<STR_LIT:T>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>},<EOL>"<STR_LIT>": {<EOL>"<STR_LIT:id>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:x>": "<STR_LIT>",<EOL>"<STR_LIT:y>": "<STR_LIT>",<EOL>"<STR_LIT:z>": "<STR_LIT>",<EOL>"<STR_LIT:h>": "<STR_LIT>",<EOL>"<STR_LIT:s>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:t>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:target>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>},<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": False,<EOL>"<STR_LIT>": True,<EOL>"<STR_LIT>": [<NUM_LIT>, <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT>],<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": False<EOL>}<EOL>

Return default style for matplotlib_circuit_drawer (IBM QX style).


def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False,<EOL>plotbarriers=True, justify=None, vertically_compressed=True):

qregs, cregs, ops = utils._get_layered_instructions(circuit,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL>text_drawing = _text.TextDrawing(qregs, cregs, ops)<EOL>text_drawing.plotbarriers = plotbarriers<EOL>text_drawing.line_length = line_length<EOL>text_drawing.vertically_compressed = vertically_compressed<EOL>if filename:<EOL><INDENT>text_drawing.dump(filename)<EOL><DEDENT>return text_drawing<EOL>

Draws a circuit using ascii art.
Args:
    circuit (QuantumCircuit): Input circuit
    filename (str): optional filename to write the result
    line_length (int): Optional. Breaks the circuit drawing to this length. This
               useful when the drawing does not fit in the console. If
               None (default), it will try to guess the console width using
               shutil.get_terminal_size(). If you don't want pagination
               at all, set line_length=-1.
    reverse_bits (bool): Rearrange the bits in reverse order.
    plotbarriers (bool): Draws the barriers when they are there.
    justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                    the circuit should be justified.
    vertically_compressed (bool): Default is `True`. It merges the lines so the
                                  drawing will take less vertical room.
Returns:
    TextDrawing: An instances that, when printed, draws the circuit in ascii art.


tmpfilename = '<STR_LIT>'<EOL>with tempfile.TemporaryDirectory() as tmpdirname:<EOL><INDENT>tmppath = os.path.join(tmpdirname, tmpfilename + '<STR_LIT>')<EOL>_generate_latex_source(circuit, filename=tmppath,<EOL>scale=scale, style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits, justify=justify)<EOL>image = None<EOL>try:<EOL><INDENT>subprocess.run(["<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>".format(tmpdirname),<EOL>"<STR_LIT:{}>".format(tmpfilename + '<STR_LIT>')],<EOL>stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,<EOL>check=True)<EOL><DEDENT>except OSError as ex:<EOL><INDENT>if ex.errno == errno.ENOENT:<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>raise<EOL><DEDENT>except subprocess.CalledProcessError as ex:<EOL><INDENT>with open('<STR_LIT>', '<STR_LIT:wb>') as error_file:<EOL><INDENT>error_file.write(ex.stdout)<EOL><DEDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>raise<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>base = os.path.join(tmpdirname, tmpfilename)<EOL>subprocess.run(["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>base + '<STR_LIT>', base])<EOL>image = Image.open(base + '<STR_LIT>')<EOL>image = utils._trim(image)<EOL>os.remove(base + '<STR_LIT>')<EOL>if filename:<EOL><INDENT>image.save(filename, '<STR_LIT>')<EOL><DEDENT><DEDENT>except OSError as ex:<EOL><INDENT>if ex.errno == errno.ENOENT:<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>return image<EOL><DEDENT>

Draw a quantum circuit based on latex (Qcircuit package)

    Requires version >=2.6.0 of the qcircuit LaTeX package.

    Args:
        circuit (QuantumCircuit): a quantum circuit
        scale (float): scaling factor
        filename (str): file path to save image to
        style (dict or str): dictionary of style or file name of style file
        reverse_bits (bool): When set to True reverse the bit order inside
            registers for the output visualization.
        plot_barriers (bool): Enable/disable drawing barriers in the output
            circuit. Defaults to True.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                        the circuit should be justified.

    Returns:
        PIL.Image: an in-memory representation of the circuit diagram

    Raises:
        OSError: usually indicates that ```pdflatex``` or ```pdftocairo``` is
                 missing.
        CalledProcessError: usually points errors during diagram creation.


def _generate_latex_source(circuit, filename=None,<EOL>scale=<NUM_LIT>, style=None, reverse_bits=False,<EOL>plot_barriers=True, justify=None):

qregs, cregs, ops = utils._get_layered_instructions(circuit,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL>qcimg = _latex.QCircuitImage(qregs, cregs, ops, scale, style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits)<EOL>latex = qcimg.latex()<EOL>if filename:<EOL><INDENT>with open(filename, '<STR_LIT:w>') as latex_file:<EOL><INDENT>latex_file.write(latex)<EOL><DEDENT><DEDENT>return latex<EOL>

Convert QuantumCircuit to LaTeX string.

    Args:
        circuit (QuantumCircuit): input circuit
        scale (float): image scaling
        filename (str): optional filename to write latex
        style (dict or str): dictionary of style or file name of style file
        reverse_bits (bool): When set to True reverse the bit order inside
            registers for the output visualization.
        plot_barriers (bool): Enable/disable drawing barriers in the output
            circuit. Defaults to True.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                        the circuit should be justified.

    Returns:
        str: Latex string appropriate for writing to file.


qregs, cregs, ops = utils._get_layered_instructions(circuit,<EOL>reverse_bits=reverse_bits,<EOL>justify=justify)<EOL>qcd = _matplotlib.MatplotlibDrawer(qregs, cregs, ops, scale=scale, style=style,<EOL>plot_barriers=plot_barriers,<EOL>reverse_bits=reverse_bits)<EOL>return qcd.draw(filename)<EOL>

Draw a quantum circuit based on matplotlib.
    If `%matplotlib inline` is invoked in a Jupyter notebook, it visualizes a circuit inline.
    We recommend `%config InlineBackend.figure_format = 'svg'` for the inline visualization.

    Args:
        circuit (QuantumCircuit): a quantum circuit
        scale (float): scaling factor
        filename (str): file path to save image to
        style (dict or str): dictionary of style or file name of style file
        reverse_bits (bool): When set to True reverse the bit order inside
            registers for the output visualization.
        plot_barriers (bool): Enable/disable drawing barriers in the output
            circuit. Defaults to True.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
            the circuit should be justified.

    Returns:
        matplotlib.figure: a matplotlib figure object for the circuit diagram


def plot_state_hinton(rho, title='<STR_LIT>', figsize=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:8>, <NUM_LIT:5>)<EOL><DEDENT>num = int(np.log2(len(rho)))<EOL>fig, (ax1, ax2) = plt.subplots(<NUM_LIT:1>, <NUM_LIT:2>, figsize=figsize)<EOL>max_weight = <NUM_LIT:2> ** np.ceil(np.log(np.abs(rho).max()) / np.log(<NUM_LIT:2>))<EOL>datareal = np.real(rho)<EOL>dataimag = np.imag(rho)<EOL>column_names = [bin(i)[<NUM_LIT:2>:].zfill(num) for i in range(<NUM_LIT:2>**num)]<EOL>row_names = [bin(i)[<NUM_LIT:2>:].zfill(num) for i in range(<NUM_LIT:2>**num)]<EOL>lx = len(datareal[<NUM_LIT:0>])            <EOL>ly = len(datareal[:, <NUM_LIT:0>])<EOL>ax1.patch.set_facecolor('<STR_LIT>')<EOL>ax1.set_aspect('<STR_LIT>', '<STR_LIT>')<EOL>ax1.xaxis.set_major_locator(plt.NullLocator())<EOL>ax1.yaxis.set_major_locator(plt.NullLocator())<EOL>for (x, y), w in np.ndenumerate(datareal):<EOL><INDENT>color = '<STR_LIT>' if w > <NUM_LIT:0> else '<STR_LIT>'<EOL>size = np.sqrt(np.abs(w) / max_weight)<EOL>rect = plt.Rectangle([x - size / <NUM_LIT:2>, y - size / <NUM_LIT:2>], size, size,<EOL>facecolor=color, edgecolor=color)<EOL>ax1.add_patch(rect)<EOL><DEDENT>ax1.set_xticks(np.arange(<NUM_LIT:0>, lx+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax1.set_yticks(np.arange(<NUM_LIT:0>, ly+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax1.set_yticklabels(row_names, fontsize=<NUM_LIT>)<EOL>ax1.set_xticklabels(column_names, fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL>ax1.autoscale_view()<EOL>ax1.invert_yaxis()<EOL>ax1.set_title('<STR_LIT>', fontsize=<NUM_LIT>)<EOL>ax2.patch.set_facecolor('<STR_LIT>')<EOL>ax2.set_aspect('<STR_LIT>', '<STR_LIT>')<EOL>ax2.xaxis.set_major_locator(plt.NullLocator())<EOL>ax2.yaxis.set_major_locator(plt.NullLocator())<EOL>for (x, y), w in np.ndenumerate(dataimag):<EOL><INDENT>color = '<STR_LIT>' if w > <NUM_LIT:0> else '<STR_LIT>'<EOL>size = np.sqrt(np.abs(w) / max_weight)<EOL>rect = plt.Rectangle([x - size / <NUM_LIT:2>, y - size / <NUM_LIT:2>], size, size,<EOL>facecolor=color, edgecolor=color)<EOL>ax2.add_patch(rect)<EOL><DEDENT>if np.any(dataimag != <NUM_LIT:0>):<EOL><INDENT>ax2.set_xticks(np.arange(<NUM_LIT:0>, lx+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax2.set_yticks(np.arange(<NUM_LIT:0>, ly+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax2.set_yticklabels(row_names, fontsize=<NUM_LIT>)<EOL>ax2.set_xticklabels(column_names, fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL><DEDENT>ax2.autoscale_view()<EOL>ax2.invert_yaxis()<EOL>ax2.set_title('<STR_LIT>', fontsize=<NUM_LIT>)<EOL>if title:<EOL><INDENT>fig.suptitle(title, fontsize=<NUM_LIT:16>)<EOL><DEDENT>plt.tight_layout()<EOL>plt.close(fig)<EOL>return fig<EOL>

Plot a hinton diagram for the quanum state.

    Args:
        rho (ndarray): Numpy array for state vector or density matrix.
        title (str): a string that represents the plot title
        figsize (tuple): Figure size in inches.
    Returns:
         matplotlib.Figure: The matplotlib.Figure of the visualization

    Raises:
        ImportError: Requires matplotlib.


def plot_bloch_vector(bloch, title="<STR_LIT>", ax=None, figsize=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:5>, <NUM_LIT:5>)<EOL><DEDENT>B = Bloch(axes=ax)<EOL>B.add_vectors(bloch)<EOL>B.render(title=title)<EOL>if ax is None:<EOL><INDENT>fig = B.fig<EOL>fig.set_size_inches(figsize[<NUM_LIT:0>], figsize[<NUM_LIT:1>])<EOL>plt.close(fig)<EOL>return fig<EOL><DEDENT>return None<EOL>

Plot the Bloch sphere.

    Plot a sphere, axes, the Bloch vector, and its projections onto each axis.

    Args:
        bloch (list[double]): array of three elements where [<x>, <y>, <z>]
        title (str): a string that represents the plot title
        ax (matplotlib.Axes): An Axes to use for rendering the bloch sphere
        figsize (tuple): Figure size in inches. Has no effect is passing `ax`.

    Returns:
        Figure: A matplotlib figure instance if `ax = None`.

    Raises:
        ImportError: Requires matplotlib.


def plot_bloch_multivector(rho, title='<STR_LIT>', figsize=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>rho = _validate_input_state(rho)<EOL>num = int(np.log2(len(rho)))<EOL>width, height = plt.figaspect(<NUM_LIT:1>/num)<EOL>fig = plt.figure(figsize=(width, height))<EOL>for i in range(num):<EOL><INDENT>ax = fig.add_subplot(<NUM_LIT:1>, num, i + <NUM_LIT:1>, projection='<STR_LIT>')<EOL>pauli_singles = [<EOL>Pauli.pauli_single(num, i, '<STR_LIT:X>'),<EOL>Pauli.pauli_single(num, i, '<STR_LIT:Y>'),<EOL>Pauli.pauli_single(num, i, '<STR_LIT>')<EOL>]<EOL>bloch_state = list(<EOL>map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),<EOL>pauli_singles))<EOL>plot_bloch_vector(bloch_state, "<STR_LIT>" + str(i), ax=ax,<EOL>figsize=figsize)<EOL><DEDENT>fig.suptitle(title, fontsize=<NUM_LIT:16>)<EOL>plt.close(fig)<EOL>return fig<EOL>

Plot the Bloch sphere.

    Plot a sphere, axes, the Bloch vector, and its projections onto each axis.

    Args:
        rho (ndarray): Numpy array for state vector or density matrix.
        title (str): a string that represents the plot title
        figsize (tuple): Has no effect, here for compatibility only.

    Returns:
        Figure: A matplotlib figure instance if `ax = None`.

    Raises:
        ImportError: Requires matplotlib.


def plot_state_city(rho, title="<STR_LIT>", figsize=None, color=None,<EOL>alpha=<NUM_LIT:1>):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>rho = _validate_input_state(rho)<EOL>num = int(np.log2(len(rho)))<EOL>datareal = np.real(rho)<EOL>dataimag = np.imag(rho)<EOL>column_names = [bin(i)[<NUM_LIT:2>:].zfill(num) for i in range(<NUM_LIT:2>**num)]<EOL>row_names = [bin(i)[<NUM_LIT:2>:].zfill(num) for i in range(<NUM_LIT:2>**num)]<EOL>lx = len(datareal[<NUM_LIT:0>])            <EOL>ly = len(datareal[:, <NUM_LIT:0>])<EOL>xpos = np.arange(<NUM_LIT:0>, lx, <NUM_LIT:1>)    <EOL>ypos = np.arange(<NUM_LIT:0>, ly, <NUM_LIT:1>)<EOL>xpos, ypos = np.meshgrid(xpos+<NUM_LIT>, ypos+<NUM_LIT>)<EOL>xpos = xpos.flatten()<EOL>ypos = ypos.flatten()<EOL>zpos = np.zeros(lx*ly)<EOL>dx = <NUM_LIT:0.5> * np.ones_like(zpos)  <EOL>dy = dx.copy()<EOL>dzr = datareal.flatten()<EOL>dzi = dataimag.flatten()<EOL>if color is None:<EOL><INDENT>color = ["<STR_LIT>", "<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>if len(color) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if color[<NUM_LIT:0>] is None:<EOL><INDENT>color[<NUM_LIT:0>] = "<STR_LIT>"<EOL><DEDENT>if color[<NUM_LIT:1>] is None:<EOL><INDENT>color[<NUM_LIT:1>] = "<STR_LIT>"<EOL><DEDENT><DEDENT>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:15>, <NUM_LIT:5>)<EOL><DEDENT>fig = plt.figure(figsize=figsize)<EOL>ax1 = fig.add_subplot(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:1>, projection='<STR_LIT>')<EOL>x = [<NUM_LIT:0>, max(xpos)+<NUM_LIT:0.5>, max(xpos)+<NUM_LIT:0.5>, <NUM_LIT:0>]<EOL>y = [<NUM_LIT:0>, <NUM_LIT:0>, max(ypos)+<NUM_LIT:0.5>, max(ypos)+<NUM_LIT:0.5>]<EOL>z = [<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>verts = [list(zip(x, y, z))]<EOL>fc1 = generate_facecolors(xpos, ypos, zpos, dx, dy, dzr, color[<NUM_LIT:0>])<EOL>for idx, cur_zpos in enumerate(zpos):<EOL><INDENT>if dzr[idx] > <NUM_LIT:0>:<EOL><INDENT>zorder = <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>zorder = <NUM_LIT:0><EOL><DEDENT>b1 = ax1.bar3d(xpos[idx], ypos[idx], cur_zpos,<EOL>dx[idx], dy[idx], dzr[idx],<EOL>alpha=alpha, zorder=zorder)<EOL>b1.set_facecolors(fc1[<NUM_LIT:6>*idx:<NUM_LIT:6>*idx+<NUM_LIT:6>])<EOL><DEDENT>pc1 = Poly3DCollection(verts, alpha=<NUM_LIT>, facecolor='<STR_LIT:k>',<EOL>linewidths=<NUM_LIT:1>, zorder=<NUM_LIT:1>)<EOL>if min(dzr) < <NUM_LIT:0> < max(dzr):<EOL><INDENT>ax1.add_collection3d(pc1)<EOL><DEDENT>ax2 = fig.add_subplot(<NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:2>, projection='<STR_LIT>')<EOL>fc2 = generate_facecolors(xpos, ypos, zpos, dx, dy, dzi, color[<NUM_LIT:1>])<EOL>for idx, cur_zpos in enumerate(zpos):<EOL><INDENT>if dzi[idx] > <NUM_LIT:0>:<EOL><INDENT>zorder = <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>zorder = <NUM_LIT:0><EOL><DEDENT>b2 = ax2.bar3d(xpos[idx], ypos[idx], cur_zpos,<EOL>dx[idx], dy[idx], dzi[idx],<EOL>alpha=alpha, zorder=zorder)<EOL>b2.set_facecolors(fc2[<NUM_LIT:6>*idx:<NUM_LIT:6>*idx+<NUM_LIT:6>])<EOL><DEDENT>pc2 = Poly3DCollection(verts, alpha=<NUM_LIT>, facecolor='<STR_LIT:k>',<EOL>linewidths=<NUM_LIT:1>, zorder=<NUM_LIT:1>)<EOL>if min(dzi) < <NUM_LIT:0> < max(dzi):<EOL><INDENT>ax2.add_collection3d(pc2)<EOL><DEDENT>ax1.set_xticks(np.arange(<NUM_LIT:0.5>, lx+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax1.set_yticks(np.arange(<NUM_LIT:0.5>, ly+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>max_dzr = max(dzr)<EOL>min_dzr = min(dzr)<EOL>if max_dzr != min_dzr:<EOL><INDENT>ax1.axes.set_zlim3d(np.min(dzr), np.max(dzr)+<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>if min_dzr == <NUM_LIT:0>:<EOL><INDENT>ax1.axes.set_zlim3d(np.min(dzr), np.max(dzr)+<NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>ax1.axes.set_zlim3d(auto=True)<EOL><DEDENT><DEDENT>ax1.zaxis.set_major_locator(MaxNLocator(<NUM_LIT:5>))<EOL>ax1.w_xaxis.set_ticklabels(row_names, fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL>ax1.w_yaxis.set_ticklabels(column_names, fontsize=<NUM_LIT>, rotation=-<NUM_LIT>)<EOL>ax1.set_zlabel("<STR_LIT>", fontsize=<NUM_LIT>)<EOL>for tick in ax1.zaxis.get_major_ticks():<EOL><INDENT>tick.label.set_fontsize(<NUM_LIT>)<EOL><DEDENT>ax2.set_xticks(np.arange(<NUM_LIT:0.5>, lx+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>ax2.set_yticks(np.arange(<NUM_LIT:0.5>, ly+<NUM_LIT:0.5>, <NUM_LIT:1>))<EOL>min_dzi = np.min(dzi)<EOL>max_dzi = np.max(dzi)<EOL>if min_dzi != max_dzi:<EOL><INDENT>eps = <NUM_LIT:0><EOL>ax2.zaxis.set_major_locator(MaxNLocator(<NUM_LIT:5>))<EOL>ax2.axes.set_zlim3d(np.min(dzi), np.max(dzi)+eps)<EOL><DEDENT>else:<EOL><INDENT>if min_dzi == <NUM_LIT:0>:<EOL><INDENT>ax2.set_zticks([<NUM_LIT:0>])<EOL>eps = <NUM_LIT><EOL>ax2.axes.set_zlim3d(np.min(dzi), np.max(dzi)+eps)<EOL><DEDENT>else:<EOL><INDENT>ax2.axes.set_zlim3d(auto=True)<EOL><DEDENT><DEDENT>ax2.w_xaxis.set_ticklabels(row_names, fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL>ax2.w_yaxis.set_ticklabels(column_names, fontsize=<NUM_LIT>, rotation=-<NUM_LIT>)<EOL>ax2.set_zlabel("<STR_LIT>", fontsize=<NUM_LIT>)<EOL>for tick in ax2.zaxis.get_major_ticks():<EOL><INDENT>tick.label.set_fontsize(<NUM_LIT>)<EOL><DEDENT>plt.suptitle(title, fontsize=<NUM_LIT:16>)<EOL>plt.tight_layout()<EOL>plt.close(fig)<EOL>return fig<EOL>

Plot the cityscape of quantum state.

    Plot two 3d bar graphs (two dimensional) of the real and imaginary
    part of the density matrix rho.

    Args:
        rho (ndarray): Numpy array for state vector or density matrix.
        title (str): a string that represents the plot title
        figsize (tuple): Figure size in inches.
        color (list): A list of len=2 giving colors for real and
        imaginary components of matrix elements.
        alpha (float): Transparency value for bars
    Returns:
         matplotlib.Figure: The matplotlib.Figure of the visualization

    Raises:
        ImportError: Requires matplotlib.
        ValueError: When 'color' is not a list of len=2.


def plot_state_paulivec(rho, title="<STR_LIT>", figsize=None, color=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:7>, <NUM_LIT:5>)<EOL><DEDENT>num = int(np.log2(len(rho)))<EOL>labels = list(map(lambda x: x.to_label(), pauli_group(num)))<EOL>values = list(map(lambda x: np.real(np.trace(np.dot(x.to_matrix(), rho))),<EOL>pauli_group(num)))<EOL>numelem = len(values)<EOL>if color is None:<EOL><INDENT>color = "<STR_LIT>"<EOL><DEDENT>ind = np.arange(numelem)  <EOL>width = <NUM_LIT:0.5>  <EOL>fig, ax = plt.subplots(figsize=figsize)<EOL>ax.grid(zorder=<NUM_LIT:0>, linewidth=<NUM_LIT:1>, linestyle='<STR_LIT>')<EOL>ax.bar(ind, values, width, color=color, zorder=<NUM_LIT:2>)<EOL>ax.axhline(linewidth=<NUM_LIT:1>, color='<STR_LIT:k>')<EOL>ax.set_ylabel('<STR_LIT>', fontsize=<NUM_LIT>)<EOL>ax.set_xticks(ind)<EOL>ax.set_yticks([-<NUM_LIT:1>, -<NUM_LIT:0.5>, <NUM_LIT:0>, <NUM_LIT:0.5>, <NUM_LIT:1>])<EOL>ax.set_xticklabels(labels, fontsize=<NUM_LIT>, rotation=<NUM_LIT>)<EOL>ax.set_xlabel('<STR_LIT>', fontsize=<NUM_LIT>)<EOL>ax.set_ylim([-<NUM_LIT:1>, <NUM_LIT:1>])<EOL>ax.set_facecolor('<STR_LIT>')<EOL>for tick in ax.xaxis.get_major_ticks()+ax.yaxis.get_major_ticks():<EOL><INDENT>tick.label.set_fontsize(<NUM_LIT>)<EOL><DEDENT>ax.set_title(title, fontsize=<NUM_LIT:16>)<EOL>plt.close(fig)<EOL>return fig<EOL>

Plot the paulivec representation of a quantum state.

    Plot a bargraph of the mixed state rho over the pauli matrices

    Args:
        rho (ndarray): Numpy array for state vector or density matrix
        title (str): a string that represents the plot title
        figsize (tuple): Figure size in inches.
        color (list or str): Color of the expectation value bars.
    Returns:
         matplotlib.Figure: The matplotlib.Figure of the visualization
    Raises:
        ImportError: Requires matplotlib.


if n == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>return reduce(lambda x, y: x * y[<NUM_LIT:0>] / y[<NUM_LIT:1>],<EOL>zip(range(n - k + <NUM_LIT:1>, n + <NUM_LIT:1>),<EOL>range(<NUM_LIT:1>, k + <NUM_LIT:1>)), <NUM_LIT:1>)<EOL>

Return the number of combinations for n choose k.

    Args:
        n (int): the total number of options .
        k (int): The number of elements.

    Returns:
        int: returns the binomial coefficient


if len(lst) != k:<EOL><INDENT>raise VisualizationError("<STR_LIT>")<EOL><DEDENT>comb = list(map(lambda x: n - <NUM_LIT:1> - x, lst))<EOL>dualm = sum([n_choose_k(comb[k - <NUM_LIT:1> - i], i + <NUM_LIT:1>) for i in range(k)])<EOL>return int(dualm)<EOL>

Return  the lex index of a combination..

    Args:
        n (int): the total number of options .
        k (int): The number of elements.
        lst (list): list

    Returns:
        int: returns int index for lex order

    Raises:
        VisualizationError: if length of list is not equal to k


n = len(s)<EOL>k = s.count("<STR_LIT:1>")<EOL>if s.count("<STR_LIT:0>") != n - k:<EOL><INDENT>raise VisualizationError("<STR_LIT>")<EOL><DEDENT>ones = [pos for pos, char in enumerate(s) if char == "<STR_LIT:1>"]<EOL>return lex_index(n, k, ones)<EOL>

Return the index of a string of 0s and 1s.


angles = np.angle(complex_number)<EOL>angle_round = int(((angles + <NUM_LIT:2> * np.pi) % (<NUM_LIT:2> * np.pi))/np.pi*<NUM_LIT:6>)<EOL>color_map = {<EOL><NUM_LIT:0>: (<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>),  <EOL><NUM_LIT:1>: (<NUM_LIT:0.5>, <NUM_LIT:0>, <NUM_LIT:1>),  <EOL><NUM_LIT:2>: (<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>),  <EOL><NUM_LIT:3>: (<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0.5>),  <EOL><NUM_LIT:4>: (<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>),  <EOL><NUM_LIT:5>: (<NUM_LIT:1>, <NUM_LIT:0.5>, <NUM_LIT:0>),  <EOL><NUM_LIT:6>: (<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>),  <EOL><NUM_LIT:7>: (<NUM_LIT:0.5>, <NUM_LIT:1>, <NUM_LIT:0>),  <EOL><NUM_LIT:8>: (<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>),  <EOL><NUM_LIT:9>: (<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0.5>),  <EOL><NUM_LIT:10>: (<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:1>),  <EOL><NUM_LIT:11>: (<NUM_LIT:0>, <NUM_LIT:0.5>, <NUM_LIT:1>)  <EOL>}<EOL>return color_map[angle_round]<EOL>

Map a phase of a complexnumber to a color in (r,g,b).

    complex_number is phase is first mapped to angle in the range
    [0, 2pi] and then to a color wheel with blue at zero phase.


if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>rho = _validate_input_state(rho)<EOL>if figsize is None:<EOL><INDENT>figsize = (<NUM_LIT:7>, <NUM_LIT:7>)<EOL><DEDENT>num = int(np.log2(len(rho)))<EOL>we, stateall = linalg.eigh(rho)<EOL>for _ in range(<NUM_LIT:2>**num):<EOL><INDENT>probmix = we.max()<EOL>prob_location = we.argmax()<EOL>if probmix > <NUM_LIT>:<EOL><INDENT>state = stateall[:, prob_location]<EOL>loc = np.absolute(state).argmax()<EOL>for j in range(<NUM_LIT:2>**num):<EOL><INDENT>test = np.absolute(np.absolute(state[j]) -<EOL>np.absolute(state[loc]))<EOL>if test < <NUM_LIT>:<EOL><INDENT>loc = j<EOL>break<EOL><DEDENT><DEDENT>angles = (np.angle(state[loc]) + <NUM_LIT:2> * np.pi) % (<NUM_LIT:2> * np.pi)<EOL>angleset = np.exp(-<NUM_LIT>*angles)<EOL>state = angleset*state<EOL>state.flatten()<EOL>fig = plt.figure(figsize=figsize)<EOL>ax = fig.add_subplot(<NUM_LIT>, projection='<STR_LIT>')<EOL>ax.axes.set_xlim3d(-<NUM_LIT:1.0>, <NUM_LIT:1.0>)<EOL>ax.axes.set_ylim3d(-<NUM_LIT:1.0>, <NUM_LIT:1.0>)<EOL>ax.axes.set_zlim3d(-<NUM_LIT:1.0>, <NUM_LIT:1.0>)<EOL>ax.set_aspect("<STR_LIT>")<EOL>ax.axes.grid(False)<EOL>u = np.linspace(<NUM_LIT:0>, <NUM_LIT:2> * np.pi, <NUM_LIT>)<EOL>v = np.linspace(<NUM_LIT:0>, np.pi, <NUM_LIT>)<EOL>x = np.outer(np.cos(u), np.sin(v))<EOL>y = np.outer(np.sin(u), np.sin(v))<EOL>z = np.outer(np.ones(np.size(u)), np.cos(v))<EOL>ax.plot_surface(x, y, z, rstride=<NUM_LIT:1>, cstride=<NUM_LIT:1>, color='<STR_LIT:k>',<EOL>alpha=<NUM_LIT>, linewidth=<NUM_LIT:0>)<EOL>ax.w_xaxis.set_pane_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.w_yaxis.set_pane_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.w_zaxis.set_pane_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.w_xaxis.line.set_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.w_yaxis.line.set_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.w_zaxis.line.set_color((<NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:1.0>, <NUM_LIT:0.0>))<EOL>ax.set_xticks([])<EOL>ax.set_yticks([])<EOL>ax.set_zticks([])<EOL>d = num<EOL>for i in range(<NUM_LIT:2>**num):<EOL><INDENT>element = bin(i)[<NUM_LIT:2>:].zfill(num)<EOL>weight = element.count("<STR_LIT:1>")<EOL>zvalue = -<NUM_LIT:2> * weight / d + <NUM_LIT:1><EOL>number_of_divisions = n_choose_k(d, weight)<EOL>weight_order = bit_string_index(element)<EOL>angle = weight_order * <NUM_LIT:2> * np.pi / number_of_divisions<EOL>xvalue = np.sqrt(<NUM_LIT:1> - zvalue**<NUM_LIT:2>) * np.cos(angle)<EOL>yvalue = np.sqrt(<NUM_LIT:1> - zvalue**<NUM_LIT:2>) * np.sin(angle)<EOL>ax.plot([xvalue], [yvalue], [zvalue],<EOL>markerfacecolor=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>),<EOL>markeredgecolor=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>),<EOL>marker='<STR_LIT:o>', markersize=<NUM_LIT:10>, alpha=<NUM_LIT:1>)<EOL>prob = np.real(np.dot(state[i], state[i].conj()))<EOL>colorstate = phase_to_color_wheel(state[i])<EOL>a = Arrow3D([<NUM_LIT:0>, xvalue], [<NUM_LIT:0>, yvalue], [<NUM_LIT:0>, zvalue],<EOL>mutation_scale=<NUM_LIT:20>, alpha=prob, arrowstyle="<STR_LIT:->",<EOL>color=colorstate, lw=<NUM_LIT:10>)<EOL>ax.add_artist(a)<EOL><DEDENT>for weight in range(d + <NUM_LIT:1>):<EOL><INDENT>theta = np.linspace(-<NUM_LIT:2> * np.pi, <NUM_LIT:2> * np.pi, <NUM_LIT:100>)<EOL>z = -<NUM_LIT:2> * weight / d + <NUM_LIT:1><EOL>r = np.sqrt(<NUM_LIT:1> - z**<NUM_LIT:2>)<EOL>x = r * np.cos(theta)<EOL>y = r * np.sin(theta)<EOL>ax.plot(x, y, z, color=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL><DEDENT>ax.plot([<NUM_LIT:0>], [<NUM_LIT:0>], [<NUM_LIT:0>], markerfacecolor=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>),<EOL>markeredgecolor=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>), marker='<STR_LIT:o>', markersize=<NUM_LIT:10>,<EOL>alpha=<NUM_LIT:1>)<EOL>we[prob_location] = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>plt.tight_layout()<EOL>plt.close(fig)<EOL>return fig<EOL>

Plot the qsphere representation of a quantum state.

    Args:
        rho (ndarray): State vector or density matrix representation.
        of quantum state.
        figsize (tuple): Figure size in inches.

    Returns:
        Figure: A matplotlib figure instance.

    Raises:
        ImportError: Requires matplotlib.


def plot_state(quantum_state, method='<STR_LIT>', figsize=None):

if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>warnings.warn("<STR_LIT>",<EOL>DeprecationWarning)<EOL>rho = _validate_input_state(quantum_state)<EOL>fig = None<EOL>if method == '<STR_LIT>':<EOL><INDENT>fig = plot_state_city(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>fig = plot_state_paulivec(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>fig = plot_state_qsphere(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>plot_bloch_multivector(rho, figsize=figsize)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>fig = plot_state_hinton(rho, figsize=figsize)<EOL><DEDENT>return fig<EOL>

Plot the quantum state.

    Args:
        quantum_state (ndarray): statevector or density matrix
                                 representation of a quantum state.
        method (str): Plotting method to use.
        figsize (tuple): Figure size in inches,

    Returns:
         matplotlib.Figure: The matplotlib.Figure of the visualization
    Raises:
        ImportError: Requires matplotlib.
        VisualizationError: if the input is not a statevector or density
        matrix, or if the state is not an multi-qubit quantum state.


def generate_facecolors(x, y, z, dx, dy, dz, color):

cuboid = np.array([<EOL>(<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>),<EOL>(<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>),<EOL>(<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>),<EOL>(<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>),<EOL>(<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>(<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>),<EOL>(<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:0>),<EOL>(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>),<EOL>(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>),<EOL>])<EOL>polys = np.empty(x.shape + cuboid.shape)<EOL>for i, p, dp in [(<NUM_LIT:0>, x, dx), (<NUM_LIT:1>, y, dy), (<NUM_LIT:2>, z, dz)]:<EOL><INDENT>p = p[..., np.newaxis, np.newaxis]<EOL>dp = dp[..., np.newaxis, np.newaxis]<EOL>polys[..., i] = p + dp * cuboid[..., i]<EOL><DEDENT>polys = polys.reshape((-<NUM_LIT:1>,) + polys.shape[<NUM_LIT:2>:])<EOL>facecolors = []<EOL>if len(color) == len(x):<EOL><INDENT>for c in color:<EOL><INDENT>facecolors.extend([c] * <NUM_LIT:6>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>facecolors = list(mcolors.to_rgba_array(color))<EOL>if len(facecolors) < len(x):<EOL><INDENT>facecolors *= (<NUM_LIT:6> * len(x))<EOL><DEDENT><DEDENT>normals = _generate_normals(polys)<EOL>return _shade_colors(facecolors, normals)<EOL>

Generates shaded facecolors for shaded bars.
    This is here to work around a Matplotlib bug
    where alpha does not work in Bar3D.
    Args:
        x (array_like): The x- coordinates of the anchor point of the bars.
        y (array_like): The y- coordinates of the anchor point of the bars.
        z (array_like): The z- coordinates of the anchor point of the bars.
        dx (array_like): Width of bars.
        dy (array_like): Depth of bars.
        dz (array_like): Height of bars.
        color (array_like): sequence of valid color specifications, optional
    Returns:
        list: Shaded colors for bars.


if isinstance(polygons, np.ndarray):<EOL><INDENT>n = polygons.shape[-<NUM_LIT:2>]<EOL>i1, i2, i3 = <NUM_LIT:0>, n//<NUM_LIT:3>, <NUM_LIT:2>*n//<NUM_LIT:3><EOL>v1 = polygons[..., i1, :] - polygons[..., i2, :]<EOL>v2 = polygons[..., i2, :] - polygons[..., i3, :]<EOL><DEDENT>else:<EOL><INDENT>v1 = np.empty((len(polygons), <NUM_LIT:3>))<EOL>v2 = np.empty((len(polygons), <NUM_LIT:3>))<EOL>for poly_i, ps in enumerate(polygons):<EOL><INDENT>n = len(ps)<EOL>i1, i2, i3 = <NUM_LIT:0>, n//<NUM_LIT:3>, <NUM_LIT:2>*n//<NUM_LIT:3><EOL>v1[poly_i, :] = ps[i1, :] - ps[i2, :]<EOL>v2[poly_i, :] = ps[i2, :] - ps[i3, :]<EOL><DEDENT><DEDENT>return np.cross(v1, v2)<EOL>

Takes a list of polygons and return an array of their normals.
Normals point towards the viewer for a face with its vertices in
counterclockwise order, following the right hand rule.
Uses three points equally spaced around the polygon.
This normal of course might not make sense for polygons with more than
three points not lying in a plane, but it's a plausible and fast
approximation.
Args:
    polygons (list): list of (M_i, 3) array_like, or (..., M, 3) array_like
        A sequence of polygons to compute normals for, which can have
        varying numbers of vertices. If the polygons all have the same
        number of vertices and array is passed, then the operation will
        be vectorized.
Returns:
    normals: (..., 3) array_like
        A normal vector estimated for the polygon.


def _shade_colors(color, normals, lightsource=None):

if lightsource is None:<EOL><INDENT>lightsource = LightSource(azdeg=<NUM_LIT>, altdeg=<NUM_LIT>)<EOL><DEDENT>shade = np.array([np.dot(n / proj3d.mod(n), lightsource.direction)<EOL>if proj3d.mod(n) else np.nan<EOL>for n in normals])<EOL>mask = ~np.isnan(shade)<EOL>if mask.any():<EOL><INDENT>norm = Normalize(min(shade[mask]), max(shade[mask]))<EOL>shade[~mask] = min(shade[mask])<EOL>color = mcolors.to_rgba_array(color)<EOL>alpha = color[:, <NUM_LIT:3>]<EOL>colors = (<NUM_LIT:0.5> + norm(shade)[:, np.newaxis] * <NUM_LIT:0.5>) * color<EOL>colors[:, <NUM_LIT:3>] = alpha<EOL><DEDENT>else:<EOL><INDENT>colors = np.asanyarray(color).copy()<EOL><DEDENT>return colors<EOL>

Shade *color* using normal vectors given by *normals*.
*color* can also be an array of the same length as *normals*.


if not HAS_MATPLOTLIB:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>if backend.configuration().simulator:<EOL><INDENT>raise QiskitError('<STR_LIT>')<EOL><DEDENT>mpl_data = {}<EOL>mpl_data['<STR_LIT>'] = [[<NUM_LIT:0>, <NUM_LIT:0>], [<NUM_LIT:0>, <NUM_LIT:1>], [<NUM_LIT:0>, <NUM_LIT:2>], [<NUM_LIT:0>, <NUM_LIT:3>], [<NUM_LIT:0>, <NUM_LIT:4>],<EOL>[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:1>, <NUM_LIT:1>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:1>, <NUM_LIT:3>], [<NUM_LIT:1>, <NUM_LIT:4>],<EOL>[<NUM_LIT:2>, <NUM_LIT:0>], [<NUM_LIT:2>, <NUM_LIT:1>], [<NUM_LIT:2>, <NUM_LIT:2>], [<NUM_LIT:2>, <NUM_LIT:3>], [<NUM_LIT:2>, <NUM_LIT:4>],<EOL>[<NUM_LIT:3>, <NUM_LIT:0>], [<NUM_LIT:3>, <NUM_LIT:1>], [<NUM_LIT:3>, <NUM_LIT:2>], [<NUM_LIT:3>, <NUM_LIT:3>], [<NUM_LIT:3>, <NUM_LIT:4>]]<EOL>mpl_data['<STR_LIT>'] = mpl_data['<STR_LIT>']<EOL>mpl_data['<STR_LIT>'] = [[<NUM_LIT:0>, <NUM_LIT:0>], [<NUM_LIT:0>, <NUM_LIT:1>], [<NUM_LIT:0>, <NUM_LIT:2>], [<NUM_LIT:0>, <NUM_LIT:3>], [<NUM_LIT:0>, <NUM_LIT:4>],<EOL>[<NUM_LIT:0>, <NUM_LIT:5>], [<NUM_LIT:0>, <NUM_LIT:6>], [<NUM_LIT:1>, <NUM_LIT:7>], [<NUM_LIT:1>, <NUM_LIT:6>], [<NUM_LIT:1>, <NUM_LIT:5>],<EOL>[<NUM_LIT:1>, <NUM_LIT:4>], [<NUM_LIT:1>, <NUM_LIT:3>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:1>, <NUM_LIT:1>]]<EOL>mpl_data['<STR_LIT>'] = [[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:0>, <NUM_LIT:0>], [<NUM_LIT:0>, <NUM_LIT:1>], [<NUM_LIT:0>, <NUM_LIT:2>], [<NUM_LIT:0>, <NUM_LIT:3>],<EOL>[<NUM_LIT:0>, <NUM_LIT:4>], [<NUM_LIT:0>, <NUM_LIT:5>], [<NUM_LIT:0>, <NUM_LIT:6>], [<NUM_LIT:0>, <NUM_LIT:7>], [<NUM_LIT:1>, <NUM_LIT:7>],<EOL>[<NUM_LIT:1>, <NUM_LIT:6>], [<NUM_LIT:1>, <NUM_LIT:5>], [<NUM_LIT:1>, <NUM_LIT:4>], [<NUM_LIT:1>, <NUM_LIT:3>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:1>, <NUM_LIT:1>]]<EOL>mpl_data['<STR_LIT>'] = [[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:0>, <NUM_LIT:1>], [<NUM_LIT:1>, <NUM_LIT:1>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:2>, <NUM_LIT:1>]]<EOL>mpl_data['<STR_LIT>'] = mpl_data['<STR_LIT>']<EOL>config = backend.configuration()<EOL>name = config.backend_name<EOL>cmap = config.coupling_map<EOL>dep_names = {'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'}<EOL>if name in dep_names.keys():<EOL><INDENT>name = dep_names[name]<EOL><DEDENT>if name in mpl_data.keys():<EOL><INDENT>grid_data = mpl_data[name]<EOL><DEDENT>else:<EOL><INDENT>fig, ax = plt.subplots(figsize=(<NUM_LIT:5>, <NUM_LIT:5>))  <EOL>ax.axis('<STR_LIT>')<EOL>return fig<EOL><DEDENT>x_max = max([d[<NUM_LIT:1>] for d in grid_data])<EOL>y_max = max([d[<NUM_LIT:0>] for d in grid_data])<EOL>max_dim = max(x_max, y_max)<EOL>if figsize is None:<EOL><INDENT>if x_max/max_dim > <NUM_LIT> and y_max/max_dim > <NUM_LIT>:<EOL><INDENT>figsize = (<NUM_LIT:5>, <NUM_LIT:5>)<EOL><DEDENT>else:<EOL><INDENT>figsize = (<NUM_LIT:9>, <NUM_LIT:3>)<EOL><DEDENT><DEDENT>fig, ax = plt.subplots(figsize=figsize)  <EOL>ax.axis('<STR_LIT>')<EOL>fig.tight_layout()<EOL>if qubit_color is None:<EOL><INDENT>qubit_color = ['<STR_LIT>']*config.n_qubits<EOL><DEDENT>if line_color is None:<EOL><INDENT>line_color = ['<STR_LIT>']*len(cmap)<EOL><DEDENT>for ind, edge in enumerate(cmap):<EOL><INDENT>is_symmetric = False<EOL>if edge[::-<NUM_LIT:1>] in cmap:<EOL><INDENT>is_symmetric = True<EOL><DEDENT>y_start = grid_data[edge[<NUM_LIT:0>]][<NUM_LIT:0>]<EOL>x_start = grid_data[edge[<NUM_LIT:0>]][<NUM_LIT:1>]<EOL>y_end = grid_data[edge[<NUM_LIT:1>]][<NUM_LIT:0>]<EOL>x_end = grid_data[edge[<NUM_LIT:1>]][<NUM_LIT:1>]<EOL>if is_symmetric:<EOL><INDENT>if y_start == y_end:<EOL><INDENT>x_end = (x_end - x_start)/<NUM_LIT:2>+x_start<EOL><DEDENT>elif x_start == x_end:<EOL><INDENT>y_end = (y_end - y_start)/<NUM_LIT:2>+y_start<EOL><DEDENT>else:<EOL><INDENT>x_end = (x_end - x_start)/<NUM_LIT:2>+x_start<EOL>y_end = (y_end - y_start)/<NUM_LIT:2>+y_start<EOL><DEDENT><DEDENT>ax.add_artist(plt.Line2D([x_start, x_end], [-y_start, -y_end],<EOL>color=line_color[ind], linewidth=line_width,<EOL>zorder=<NUM_LIT:0>))<EOL>if plot_directed:<EOL><INDENT>dx = x_end-x_start  <EOL>dy = y_end-y_start  <EOL>if is_symmetric:<EOL><INDENT>x_arrow = x_start+dx*<NUM_LIT><EOL>y_arrow = -y_start-dy*<NUM_LIT><EOL>dx_arrow = dx*<NUM_LIT><EOL>dy_arrow = -dy*<NUM_LIT><EOL>head_width = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>x_arrow = x_start+dx*<NUM_LIT:0.5><EOL>y_arrow = -y_start-dy*<NUM_LIT:0.5><EOL>dx_arrow = dx*<NUM_LIT><EOL>dy_arrow = -dy*<NUM_LIT><EOL>head_width = <NUM_LIT><EOL><DEDENT>ax.add_patch(mpatches.FancyArrow(x_arrow,<EOL>y_arrow,<EOL>dx_arrow,<EOL>dy_arrow,<EOL>head_width=head_width,<EOL>length_includes_head=True,<EOL>edgecolor=None,<EOL>linewidth=<NUM_LIT:0>,<EOL>facecolor=line_color[ind],<EOL>zorder=<NUM_LIT:1>))<EOL><DEDENT><DEDENT>for var, idx in enumerate(grid_data):<EOL><INDENT>_idx = [idx[<NUM_LIT:1>], -idx[<NUM_LIT:0>]]<EOL>width = _GraphDist(qubit_size, ax, True)<EOL>height = _GraphDist(qubit_size, ax, False)<EOL>ax.add_artist(mpatches.Ellipse(<EOL>_idx, width, height, color=qubit_color[var], zorder=<NUM_LIT:1>))<EOL>if label_qubits:<EOL><INDENT>ax.text(*_idx, s=str(var),<EOL>horizontalalignment='<STR_LIT>',<EOL>verticalalignment='<STR_LIT>',<EOL>color=font_color, size=font_size, weight='<STR_LIT>')<EOL><DEDENT><DEDENT>ax.set_xlim([-<NUM_LIT:1>, x_max+<NUM_LIT:1>])<EOL>ax.set_ylim([-(y_max+<NUM_LIT:1>), <NUM_LIT:1>])<EOL>plt.close(fig)<EOL>return fig<EOL>

Plots the gate map of a device.

    Args:
        backend (BaseBackend): A backend instance,
        figsize (tuple): Output figure size (wxh) in inches.
        plot_directed (bool): Plot directed coupling map.
        label_qubits (bool): Label the qubits.
        qubit_size (float): Size of qubit marker.
        line_width (float): Width of lines.
        font_size (int): Font size of qubit labels.
        qubit_color (list): A list of colors for the qubits
        line_color (list): A list of colors for each line from coupling_map.
        font_color (str): The font color for the qubit labels.

    Returns:
        Figure: A Matplotlib figure instance.

    Raises:
        QiskitError: if tried to pass a simulator.
        ImportError: if matplotlib not installed.


x0, y0 = self.ax.transAxes.transform(  <EOL>(<NUM_LIT:0>, <NUM_LIT:0>))<EOL>x1, y1 = self.ax.transAxes.transform(  <EOL>(<NUM_LIT:1>, <NUM_LIT:1>))<EOL>value = x1 - x0 if self.x else y1 - y0<EOL>return value<EOL>


bounds = self.ax.get_xlim() if self.x else self.ax.get_ylim()<EOL>return bounds[<NUM_LIT:0>] - bounds[<NUM_LIT:1>]<EOL>


return (self.size / self.dist_real) * self.dist_abs<EOL>


ret = self.top_format % self.top_connect.center(<EOL>self.width, self.top_pad)<EOL>if self.right_fill:<EOL><INDENT>ret = ret.ljust(self.right_fill, self.top_pad)<EOL><DEDENT>if self.left_fill:<EOL><INDENT>ret = ret.rjust(self.left_fill, self.top_pad)<EOL><DEDENT>ret = ret.center(self.layer_width, self.top_bck)<EOL>return ret<EOL>


ret = self.mid_format % self.mid_content.center(<EOL>self.width, self._mid_padding)<EOL>if self.right_fill:<EOL><INDENT>ret = ret.ljust(self.right_fill, self._mid_padding)<EOL><DEDENT>if self.left_fill:<EOL><INDENT>ret = ret.rjust(self.left_fill, self._mid_padding)<EOL><DEDENT>ret = ret.center(self.layer_width, self.mid_bck)<EOL>return ret<EOL>

Constructs the middle line of the element


ret = self.bot_format % self.bot_connect.center(<EOL>self.width, self.bot_pad)<EOL>if self.right_fill:<EOL><INDENT>ret = ret.ljust(self.right_fill, self.bot_pad)<EOL><DEDENT>if self.left_fill:<EOL><INDENT>ret = ret.rjust(self.left_fill, self.bot_pad)<EOL><DEDENT>ret = ret.center(self.layer_width, self.bot_bck)<EOL>return ret<EOL>

Constructs the bottom line of the element


return max(len(self.top), len(self.mid), len(self.bot))<EOL>

Returns the length of the element, including the box around.


if self._width:<EOL><INDENT>return self._width<EOL><DEDENT>return len(self.mid_content)<EOL>

Returns the width of the label, including padding


def connect(self, wire_char, where, label=None):

if '<STR_LIT>' in where and self.top_connector:<EOL><INDENT>self.top_connect = self.top_connector[wire_char]<EOL><DEDENT>if '<STR_LIT>' in where and self.bot_connector:<EOL><INDENT>self.bot_connect = self.bot_connector[wire_char]<EOL><DEDENT>if label:<EOL><INDENT>self.top_format = self.top_format[:-<NUM_LIT:1>] + (label if label else "<STR_LIT>")<EOL><DEDENT>

Connects boxes and elements using wire_char and setting proper connectors.
Args:
    wire_char (char): For example '║' or '│'.
    where (list["top", "bot"]): Where the connector should be set.
    label (string): Some connectors have a label (see cu1, for example).


def center_label(self, input_length, order):

location_in_the_box = '<STR_LIT:*>'.center(input_length * <NUM_LIT:2> - <NUM_LIT:1>).index('<STR_LIT:*>') + <NUM_LIT:1><EOL>top_limit = order * <NUM_LIT:2> + <NUM_LIT:2><EOL>bot_limit = top_limit + <NUM_LIT:2><EOL>if top_limit <= location_in_the_box < bot_limit:<EOL><INDENT>if location_in_the_box == top_limit:<EOL><INDENT>self.top_connect = self.label<EOL><DEDENT>elif location_in_the_box == top_limit + <NUM_LIT:1>:<EOL><INDENT>self.mid_content = self.label<EOL><DEDENT>else:<EOL><INDENT>self.bot_connect = self.label<EOL><DEDENT><DEDENT>

In multi-bit elements, the label is centered vertically.
Args:
    input_length (int): Rhe amount of wires affected.
    order (int): Which middle element is this one?


if self._width:<EOL><INDENT>return self._width<EOL><DEDENT>return len(self.label)<EOL>


for nones in [i for i, x in enumerate(layer) if x is None]:<EOL><INDENT>layer[nones] = EmptyWire('<STR_LIT>') if nones >= first_clbit else EmptyWire('<STR_LIT>')<EOL><DEDENT>return layer<EOL>

Given a layer, replace the Nones in it with EmptyWire elements.
Args:
    layer (list): The layer that contains Nones.
    first_clbit (int): The first wire that is classic.

Returns:
    list: The new layer, with no Nones.


breakwire_layer = []<EOL>for _ in range(layer_length):<EOL><INDENT>breakwire_layer.append(BreakWire(arrow_char))<EOL><DEDENT>return breakwire_layer<EOL>

Creates a layer with BreakWire elements.
Args:
    layer_length (int): The length of the layer to create
    arrow_char (char): The char used to create the BreakWire element.

Returns:
    list: The new layer.


@staticmethod<EOL><INDENT>def fillup_layer(names):  <DEDENT>

longest = max([len(name) for name in names])<EOL>inputs_wires = []<EOL>for name in names:<EOL><INDENT>inputs_wires.append(InputWire(name.rjust(longest)))<EOL><DEDENT>return inputs_wires<EOL>

Creates a layer with InputWire elements.
Args:
    names (list): List of names for the wires.

Returns:
    list: The new layer


return "<STR_LIT:\n>".join(self.lines())<EOL>

Creates a long string with the ascii art
Returns:
    str: The lines joined by '\n'


def dump(self, filename, encoding="<STR_LIT:utf8>"):

with open(filename, mode='<STR_LIT:w>', encoding=encoding) as text_file:<EOL><INDENT>text_file.write(self.single_string())<EOL><DEDENT>

Dumps the ascii art in the file.
Args:
    filename (str): File to dump the ascii art.
    encoding (str): Optional. Default "utf-8".


if line_length is None:<EOL><INDENT>line_length = self.line_length<EOL><DEDENT>if line_length is None:<EOL><INDENT>if ('<STR_LIT>' in sys.modules) and ('<STR_LIT>' not in sys.modules):<EOL><INDENT>line_length = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>line_length, _ = get_terminal_size()<EOL><DEDENT><DEDENT>noqubits = len(self.qregs)<EOL>layers = self.build_layers()<EOL>if not line_length:<EOL><INDENT>line_length = self.line_length<EOL><DEDENT>layer_groups = [[]]<EOL>rest_of_the_line = line_length<EOL>for layerno, layer in enumerate(layers):<EOL><INDENT>layers[layerno] = EmptyWire.fillup_layer(layer, noqubits)<EOL>TextDrawing.normalize_width(layer)<EOL>if line_length == -<NUM_LIT:1>:<EOL><INDENT>layer_groups[-<NUM_LIT:1>].append(layer)<EOL>continue<EOL><DEDENT>layer_length = layers[layerno][<NUM_LIT:0>].length<EOL>if layer_length < rest_of_the_line:<EOL><INDENT>layer_groups[-<NUM_LIT:1>].append(layer)<EOL>rest_of_the_line -= layer_length<EOL><DEDENT>else:<EOL><INDENT>layer_groups[-<NUM_LIT:1>].append(BreakWire.fillup_layer(len(layer), '<STR_LIT>'))<EOL>layer_groups.append([BreakWire.fillup_layer(len(layer), '<STR_LIT>')])<EOL>rest_of_the_line = line_length - layer_groups[-<NUM_LIT:1>][-<NUM_LIT:1>][<NUM_LIT:0>].length<EOL>layer_groups[-<NUM_LIT:1>].append(<EOL>InputWire.fillup_layer(self.wire_names(with_initial_value=False)))<EOL>rest_of_the_line -= layer_groups[-<NUM_LIT:1>][-<NUM_LIT:1>][<NUM_LIT:0>].length<EOL>layer_groups[-<NUM_LIT:1>].append(layer)<EOL>rest_of_the_line -= layer_groups[-<NUM_LIT:1>][-<NUM_LIT:1>][<NUM_LIT:0>].length<EOL><DEDENT><DEDENT>lines = []<EOL>for layer_group in layer_groups:<EOL><INDENT>wires = [i for i in zip(*layer_group)]<EOL>lines += TextDrawing.draw_wires(wires, self.vertically_compressed)<EOL><DEDENT>return lines<EOL>

Generates a list with lines. These lines form the text drawing.
Args:
    line_length (int): Optional. Breaks the circuit drawing to this length. This
                       useful when the drawing does not fit in the console. If
                       None (default), it will try to guess the console width using
                       shutil.get_terminal_size(). If you don't want pagination
                       at all, set line_length=-1.

Returns:
    list: A list of lines with the text drawing.


qubit_labels = self._get_qubit_labels()<EOL>clbit_labels = self._get_clbit_labels()<EOL>if with_initial_value:<EOL><INDENT>qubit_labels = ['<STR_LIT>' % qubit for qubit in qubit_labels]<EOL>clbit_labels = ['<STR_LIT>' % clbit for clbit in clbit_labels]<EOL><DEDENT>else:<EOL><INDENT>qubit_labels = ['<STR_LIT>' % qubit for qubit in qubit_labels]<EOL>clbit_labels = ['<STR_LIT>' % clbit for clbit in clbit_labels]<EOL><DEDENT>return qubit_labels + clbit_labels<EOL>

Returns a list of names for each wire.
Args:
    with_initial_value (bool): Optional (Default: True). If true, adds the initial value to
                               the name.

Returns:
    List: The list of wire names.


lines = []<EOL>bot_line = None<EOL>for wire in wires:<EOL><INDENT>top_line = '<STR_LIT>'<EOL>for instruction in wire:<EOL><INDENT>top_line += instruction.top<EOL><DEDENT>if bot_line is None:<EOL><INDENT>lines.append(top_line)<EOL><DEDENT>else:<EOL><INDENT>if vertically_compressed:<EOL><INDENT>lines.append(TextDrawing.merge_lines(lines.pop(), top_line))<EOL><DEDENT>else:<EOL><INDENT>lines.append(TextDrawing.merge_lines(lines[-<NUM_LIT:1>], top_line, icod="<STR_LIT>"))<EOL><DEDENT><DEDENT>mid_line = '<STR_LIT>'<EOL>for instruction in wire:<EOL><INDENT>mid_line += instruction.mid<EOL><DEDENT>lines.append(TextDrawing.merge_lines(lines[-<NUM_LIT:1>], mid_line, icod="<STR_LIT>"))<EOL>bot_line = '<STR_LIT>'<EOL>for instruction in wire:<EOL><INDENT>bot_line += instruction.bot<EOL><DEDENT>lines.append(TextDrawing.merge_lines(lines[-<NUM_LIT:1>], bot_line, icod="<STR_LIT>"))<EOL><DEDENT>return lines<EOL>

Given a list of wires, creates a list of lines with the text drawing.
Args:
    wires (list): A list of wires with instructions.
    vertically_compressed (bool): Default is `True`. It merges the lines
                             so the drawing will take less vertical room.
Returns:
    list: A list of lines with the text drawing.


return "<STR_LIT>" % ('<STR_LIT:=>', instruction.condition[<NUM_LIT:1>])<EOL>

Creates the label for a conditional instruction.


if not hasattr(instruction.op, '<STR_LIT>'):<EOL><INDENT>return None<EOL><DEDENT>if all([isinstance(param, ndarray) for param in instruction.op.params]):<EOL><INDENT>return None<EOL><DEDENT>ret = []<EOL>for param in instruction.op.params:<EOL><INDENT>if isinstance(param, (sympy.Number, float)):<EOL><INDENT>ret.append('<STR_LIT>' % param)<EOL><DEDENT>else:<EOL><INDENT>ret.append('<STR_LIT:%s>' % param)<EOL><DEDENT><DEDENT>return ret<EOL>

Get the params and format them to add them to a label. None if there
         are no params of if the params are numpy.ndarrays.


label = instruction.name.capitalize()<EOL>params = TextDrawing.params_for_label(instruction)<EOL>if params:<EOL><INDENT>label += "<STR_LIT>" % '<STR_LIT:U+002C>'.join(params)<EOL><DEDENT>return label<EOL>


@staticmethod<EOL><INDENT>def merge_lines(top, bot, icod="<STR_LIT>"):<DEDENT>

ret = "<STR_LIT>"<EOL>for topc, botc in zip(top, bot):<EOL><INDENT>if topc == botc:<EOL><INDENT>ret += topc<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc == "<STR_LIT:U+0020>":<EOL><INDENT>ret += botc<EOL><DEDENT>elif topc in '<STR_LIT>' and botc in "<STR_LIT>" and icod == "<STR_LIT>":<EOL><INDENT>ret += topc<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>" and icod == "<STR_LIT>":<EOL><INDENT>ret += '<STR_LIT>'<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>" and icod == "<STR_LIT>":<EOL><INDENT>ret += '<STR_LIT>'<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT>":<EOL><INDENT>ret += '<STR_LIT>'<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT>":<EOL><INDENT>ret += '<STR_LIT>'<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>" and icod == "<STR_LIT>":<EOL><INDENT>ret += topc<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>" and icod == "<STR_LIT>":<EOL><INDENT>ret += topc<EOL><DEDENT>elif topc in '<STR_LIT>' and botc == "<STR_LIT:U+0020>" and icod == "<STR_LIT>":<EOL><INDENT>ret += botc<EOL><DEDENT>elif topc in "<STR_LIT>" and botc in "<STR_LIT>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc in "<STR_LIT>" and botc in "<STR_LIT>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc in '<STR_LIT>' and botc in "<STR_LIT:U+0020>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc == '<STR_LIT>' and botc == "<STR_LIT>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc == '<STR_LIT>' and botc == "<STR_LIT>":<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif botc in "<STR_LIT>" and icod == '<STR_LIT>':<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>elif topc in "<STR_LIT>" and botc in "<STR_LIT>" and icod == '<STR_LIT>':<EOL><INDENT>ret += "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>ret += botc<EOL><DEDENT><DEDENT>return ret<EOL>

Merges two lines (top and bot) in the way that the overlapping make senses.
Args:
    top (str): the top line
    bot (str): the bottom line
    icod (top or bot): in case of doubt, which line should have priority? Default: "top".
Returns:
    str: The merge of both lines.


instructions = [instruction for instruction in filter(lambda x: x is not None, layer)]<EOL>longest = max([instruction.length for instruction in instructions])<EOL>for instruction in instructions:<EOL><INDENT>instruction.layer_width = longest<EOL><DEDENT>

When the elements of the layer have different widths, sets the width to the max elements.
Args:
    layer (list): A list of elements.


def _instruction_to_gate(self, instruction, layer):

current_cons = []<EOL>connection_label = None<EOL>def add_connected_gate(instruction, gates, layer, current_cons):<EOL><INDENT>for i, gate in enumerate(gates):<EOL><INDENT>layer.set_qubit(instruction.qargs[i], gate)<EOL>actual_index = self.qregs.index(instruction.qargs[i])<EOL>current_cons.append((actual_index, gate))<EOL><DEDENT><DEDENT>if instruction.name == '<STR_LIT>':<EOL><INDENT>gate = MeasureFrom()<EOL>layer.set_qubit(instruction.qargs[<NUM_LIT:0>], gate)<EOL>layer.set_clbit(instruction.cargs[<NUM_LIT:0>], MeasureTo())<EOL><DEDENT>elif instruction.name in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>']:<EOL><INDENT>if not self.plotbarriers:<EOL><INDENT>return layer, current_cons, connection_label<EOL><DEDENT>for qubit in instruction.qargs:<EOL><INDENT>layer.set_qubit(qubit, Barrier())<EOL><DEDENT><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>gates = [Ex() for _ in range(len(instruction.qargs))]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>gates = [Bullet(), Ex(), Ex()]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>layer.set_qubit(instruction.qargs[<NUM_LIT:0>], Reset())<EOL><DEDENT>elif instruction.condition is not None:<EOL><INDENT>cllabel = TextDrawing.label_for_conditional(instruction)<EOL>qulabel = TextDrawing.label_for_box(instruction)<EOL>layer.set_cl_multibox(instruction.condition[<NUM_LIT:0>], cllabel, top_connect='<STR_LIT>')<EOL>layer.set_qubit(instruction.qargs[<NUM_LIT:0>], BoxOnQuWire(qulabel, bot_connect='<STR_LIT>'))<EOL><DEDENT>elif instruction.name in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>gates = [Bullet() for _ in range(len(instruction.qargs) - <NUM_LIT:1>)]<EOL>gates.append(BoxOnQuWire('<STR_LIT:X>'))<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>gates = [Bullet(), BoxOnQuWire('<STR_LIT:Y>')]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>gates = [Bullet(), Bullet()]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>gates = [Bullet(), BoxOnQuWire('<STR_LIT:H>')]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>connection_label = TextDrawing.params_for_label(instruction)[<NUM_LIT:0>]<EOL>gates = [Bullet(), Bullet()]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>connection_label = "<STR_LIT>" % TextDrawing.params_for_label(instruction)[<NUM_LIT:0>]<EOL>gates = [Bullet(), Bullet()]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>params = TextDrawing.params_for_label(instruction)<EOL>gates = [Bullet(), BoxOnQuWire("<STR_LIT>" % '<STR_LIT:U+002C>'.join(params))]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif instruction.name == '<STR_LIT>':<EOL><INDENT>label = "<STR_LIT>" % TextDrawing.params_for_label(instruction)[<NUM_LIT:0>]<EOL>gates = [Bullet(), BoxOnQuWire(label)]<EOL>add_connected_gate(instruction, gates, layer, current_cons)<EOL><DEDENT>elif len(instruction.qargs) == <NUM_LIT:1> and not instruction.cargs:<EOL><INDENT>layer.set_qubit(instruction.qargs[<NUM_LIT:0>],<EOL>BoxOnQuWire(TextDrawing.label_for_box(instruction)))<EOL><DEDENT>elif len(instruction.qargs) >= <NUM_LIT:2> and not instruction.cargs:<EOL><INDENT>label = instruction.name<EOL>params = TextDrawing.params_for_label(instruction)<EOL>if params:<EOL><INDENT>label += "<STR_LIT>" % '<STR_LIT:U+002C>'.join(params)<EOL><DEDENT>layer.set_qu_multibox(instruction.qargs, label)<EOL><DEDENT>else:<EOL><INDENT>raise VisualizationError(<EOL>"<STR_LIT>", instruction)<EOL><DEDENT>current_cons.sort(key=lambda tup: tup[<NUM_LIT:0>])<EOL>current_cons = [g for q, g in current_cons]<EOL>return layer, current_cons, connection_label<EOL>

Convert an instruction into its corresponding Gate object, and establish
        any connections it introduces between qubits


wire_names = self.wire_names(with_initial_value=True)<EOL>if not wire_names:<EOL><INDENT>return []<EOL><DEDENT>layers = [InputWire.fillup_layer(wire_names)]<EOL>for instruction_layer in self.instructions:<EOL><INDENT>layer = Layer(self.qregs, self.cregs)<EOL>for instruction in instruction_layer:<EOL><INDENT>layer, current_connections, connection_label =self._instruction_to_gate(instruction, layer)<EOL>layer.connections.append((connection_label, current_connections))<EOL>layer.connect_with("<STR_LIT>")<EOL><DEDENT>layers.append(layer.full_layer)<EOL><DEDENT>return layers<EOL>

Constructs layers.
Returns:
    list: List of DrawElements.
Raises:
    VisualizationError: When the drawing is, for some reason, impossible to be drawn.


return self.qubit_layer + self.clbit_layer<EOL>

Returns the composition of qubits and classic wires.
Returns:
    String: self.qubit_layer + self.clbit_layer


self.qubit_layer[self.qregs.index(qubit)] = element<EOL>

Sets the qubit to the element
Args:
    qubit (qbit): Element of self.qregs.
    element (DrawElement): Element to set in the qubit


self.clbit_layer[self.cregs.index(clbit)] = element<EOL>

Sets the clbit to the element
Args:
    clbit (cbit): Element of self.cregs.
    element (DrawElement): Element to set in the clbit


def set_cl_multibox(self, creg, label, top_connect='<STR_LIT>'):

clbit = [bit for bit in self.cregs if bit[<NUM_LIT:0>] == creg]<EOL>self._set_multibox("<STR_LIT>", clbit, label, top_connect=top_connect)<EOL>

Sets the multi clbit box.
Args:
    creg (string): The affected classical register.
    label (string): The label for the multi clbit box.
    top_connect (char): The char to connect the box on the top.


self._set_multibox("<STR_LIT>", bits, label)<EOL>

Sets the multi qubit box.
Args:
    bits (list[int]): A list of affected bits.
    label (string): The label for the multi qubit box.


if len([qbit for qbit in self.qubit_layer if qbit is not None]) == <NUM_LIT:1>:<EOL><INDENT>return<EOL><DEDENT>for label, affected_bits in self.connections:<EOL><INDENT>if not affected_bits:<EOL><INDENT>continue<EOL><DEDENT>affected_bits[<NUM_LIT:0>].connect(wire_char, ['<STR_LIT>'])<EOL>for affected_bit in affected_bits[<NUM_LIT:1>:-<NUM_LIT:1>]:<EOL><INDENT>affected_bit.connect(wire_char, ['<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>affected_bits[-<NUM_LIT:1>].connect(wire_char, ['<STR_LIT>'], label)<EOL>if label:<EOL><INDENT>for affected_bit in affected_bits:<EOL><INDENT>affected_bit.right_fill = len(label) + len(affected_bit.mid)<EOL><DEDENT><DEDENT><DEDENT>

Connects the elements in the layer using wire_char.
Args:
    wire_char (char): For example '║' or '│'.


def pulse_drawer(samples, duration, dt=None, interp_method='<STR_LIT:None>',<EOL>filename=None, interactive=False,<EOL>dpi=<NUM_LIT>, nop=<NUM_LIT:1000>, size=(<NUM_LIT:6>, <NUM_LIT:5>)):

try:<EOL><INDENT>from matplotlib import pyplot as plt<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ImportError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if dt:<EOL><INDENT>_dt = dt<EOL><DEDENT>else:<EOL><INDENT>_dt = <NUM_LIT:1><EOL><DEDENT>re_y = np.real(samples)<EOL>im_y = np.imag(samples)<EOL>image = plt.figure(figsize=size)<EOL>ax0 = image.add_subplot(<NUM_LIT>)<EOL>if interp_method == '<STR_LIT>':<EOL><INDENT>time = np.arange(<NUM_LIT:0>, duration + <NUM_LIT:1>) * _dt + <NUM_LIT:0.5> * _dt<EOL>cs_ry = CubicSpline(time[:-<NUM_LIT:1>], re_y)<EOL>cs_iy = CubicSpline(time[:-<NUM_LIT:1>], im_y)<EOL>_time = np.linspace(<NUM_LIT:0>, duration * _dt, nop)<EOL>_re_y = cs_ry(_time)<EOL>_im_y = cs_iy(_time)<EOL><DEDENT>elif interp_method == '<STR_LIT:None>':<EOL><INDENT>time = np.arange(<NUM_LIT:0>, duration + <NUM_LIT:1>) * _dt<EOL>_time = np.r_[time[<NUM_LIT:0>], np.repeat(time[<NUM_LIT:1>:-<NUM_LIT:1>], <NUM_LIT:2>), time[-<NUM_LIT:1>]]<EOL>_re_y = np.repeat(re_y, <NUM_LIT:2>)<EOL>_im_y = np.repeat(im_y, <NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>raise QiskitError('<STR_LIT>' % interp_method)<EOL><DEDENT>ax0.fill_between(x=_time, y1=_re_y, y2=np.zeros_like(_time),<EOL>facecolor='<STR_LIT>', alpha=<NUM_LIT>,<EOL>edgecolor='<STR_LIT>', linewidth=<NUM_LIT>,<EOL>label='<STR_LIT>')<EOL>ax0.fill_between(x=_time, y1=_im_y, y2=np.zeros_like(_time),<EOL>facecolor='<STR_LIT>', alpha=<NUM_LIT>,<EOL>edgecolor='<STR_LIT>', linewidth=<NUM_LIT>,<EOL>label='<STR_LIT>')<EOL>ax0.set_xlim(<NUM_LIT:0>, duration * _dt)<EOL>ax0.grid(b=True, linestyle='<STR_LIT:->')<EOL>ax0.legend(bbox_to_anchor=(<NUM_LIT:0.5>, <NUM_LIT>), loc='<STR_LIT>',<EOL>ncol=<NUM_LIT:2>, frameon=False, fontsize=<NUM_LIT>)<EOL>if filename:<EOL><INDENT>image.savefig(filename, dpi=dpi, bbox_inches='<STR_LIT>')<EOL><DEDENT>plt.close(image)<EOL>if image and interactive:<EOL><INDENT>plt.show(image)<EOL><DEDENT>return image<EOL>

Plot the interpolated envelope of pulse

    Args:
        samples (ndarray): Data points of complex pulse envelope.
        duration (int): Pulse length (number of points).
        dt (float): Time interval of samples.
        interp_method (str): Method of interpolation
            (set `None` for turn off the interpolation).
        filename (str): Name required to save pulse image.
        interactive (bool): When set true show the circuit in a new window
            (this depends on the matplotlib backend being used supporting this).
        dpi (int): Resolution of saved image.
        nop (int): Data points for interpolation.
        size (tuple): Size of figure.
    Returns:
        matplotlib.figure: A matplotlib figure object for the pulse envelope.
    Raises:
        ImportError: when the output methods requieres non-installed libraries.
        QiskitError: when invalid interpolation method is specified.


for item in axis.get_ticklines() + axis.get_ticklabels():<EOL><INDENT>item.set_visible(False)<EOL><DEDENT>

Set visible property of ticklines and ticklabels of an axis to False