pyqpanda.Visualization

QPanda Python

Copyright (C) Origin Quantum 2017-2020

Licensed Under Apache Licence 2.0

Submodules

Package Contents

Functions

draw_qprog(prog[, output, scale, fold, filename, ...])

Draw a quantum circuit to different formats (set by output parameter):

show_prog_info_count(prog)

draw_probability(list)

Draw a quantum state probaility dict

draw_probability_dict(prob_dict)

Draw a quantum state probaility dict

plot_state_city(state[, title, figsize, color, ...])

plot quantum state city

plot_density_matrix(M[, xlabels, ylabels, title, ...])

plot quantum state density matrix

state_to_density_matrix(quantum_state)

convert quantum state to density matrix

plot_bloch_circuit(circuit[, trace, saveas, fps, ...])

Draw a quantum circuit bloch view , only support one qubit

plot_bloch_vector(bloch[, title, axis_obj, fig_size])

Draw a quantum state bloch view

plot_bloch_multivector(state[, title, fig_size])

Draw a quantum state bloch view

pyqpanda.Visualization.draw_qprog(prog, output=None, scale=0.7, fold=30, filename=None, with_logo=False, line_length=100, NodeIter_first=None, NodeIter_second=None, console_encode_type='utf8')[源代码]

Draw a quantum circuit to different formats (set by output parameter):

text: ASCII art TextDrawing that can be printed in the console. text: ASCII art TextDrawing that can be printed in the console.

pic: images with color rendered purely in Python.

latex: latex source code of circuit

Args:

prog : the quantum circuit to draw scale (float): scale of image to draw (shrink if < 1). Only used by the pic outputs. flod (int): x_max_size of image to draw. dOnly used by the pic outputs. Default is 30. filename (str): file path to save image to NodeIter_first: circuit printing start position. NodeIter_second: circuit printing end position. console_encode_type(str): Target console encoding type.

Mismatching of encoding types may result in character confusion, 'utf8' and 'gbk' are supported. Only used by the pic outputs.

line_length (int): Sets the length of the lines generated by text output type.

Returns:

no return

pyqpanda.Visualization.show_prog_info_count(prog)[源代码]
pyqpanda.Visualization.draw_probability(list)[源代码]

Draw a quantum state probaility dict

Args:

list : the quantum state probaility dict

Returns:

no return

pyqpanda.Visualization.draw_probability_dict(prob_dict)[源代码]

Draw a quantum state probaility dict

Args:

list : the quantum state probaility dict

Returns:

no return

pyqpanda.Visualization.plot_state_city(state, title='', figsize=None, color=None, ax_real=None, ax_imag=None)[源代码]

plot quantum state city

Args:

quantum state: complex list title : string for figure color : color for figure

Returns:

matplot figure

Raises:

RuntimeError: if input is not a valid quantum state.

pyqpanda.Visualization.plot_density_matrix(M, xlabels=None, ylabels=None, title=None, limits=None, phase_limits=None, fig=None, axis_vals=None, threshold=None)[源代码]

plot quantum state density matrix

Args:

quantum state: complex list title : string for figure color : color for figure

Returns:

matplot figure

Raises:

RuntimeError: if input is not a valid quantum state.

pyqpanda.Visualization.state_to_density_matrix(quantum_state)[源代码]

convert quantum state to density matrix

Args:

quantum state: complex list

Returns:

density matrix

Raises:

RuntimeError: if input is not a valid quantum state.

pyqpanda.Visualization.plot_bloch_circuit(circuit, trace=True, saveas=None, fps=20, secs_per_gate=1)[源代码]

Draw a quantum circuit bloch view , only support one qubit

Args:

circuit : the quantum circuit trace : whether shows the trace fps : flash fps

Returns:

bloch figure shows quantum circuit

pyqpanda.Visualization.plot_bloch_vector(bloch, title='bloch', axis_obj=None, fig_size=None)[源代码]

Draw a quantum state bloch view

Args:

state : the quantum state title : the figure title fig_size : the figure size

Returns:

bloch figure shows quantum state

pyqpanda.Visualization.plot_bloch_multivector(state, title='', fig_size=None)[源代码]

Draw a quantum state bloch view

Args:

state : the quantum state title : the figure title fig_size : the figure size

Returns:

bloch figure shows quantum state