Sphinx docs line wrapping and sample code lines

This commit is contained in:
Diego M. Rodriguez 2017-09-18 13:47:34 +02:00
parent 568bcaf80a
commit 2f58bf92d1
4 changed files with 36 additions and 9 deletions

View File

@ -5,7 +5,10 @@ Programming interface
---------------------
The *qiskit* directory is the main Python module and contains the
programming interface objects :py:mod:`QuantumProgram <qiskit._quantumprogram>`, :py:mod:`QuantumRegister <qiskit._quantumregister>`, :py:mod:`ClassicalRegister <qiskit._classicalregister>`, and :py:mod:`QuantumCircuit <qiskit._quantumcircuit>`.
programming interface objects :py:mod:`QuantumProgram <qiskit._quantumprogram>`,
:py:mod:`QuantumRegister <qiskit._quantumregister>`,
:py:mod:`ClassicalRegister <qiskit._classicalregister>`,
and :py:mod:`QuantumCircuit <qiskit._quantumcircuit>`.
At the highest level, users construct a *QuantumProgram* to create,
modify, compile, and execute a collection of quantum circuits. Each
@ -25,15 +28,28 @@ Internal modules
The directory also contains internal modules that are still under development:
- a *qasm* module for parsing **OpenQASM** circuits
- an *unroll* module to interpret and “unroll” **OpenQASM** to a target gate basis (expanding gate subroutines and loops as needed)
- an *unroll* module to interpret and “unroll” **OpenQASM** to a target gate basis
(expanding gate subroutines and loops as needed)
- a *dagcircuit* module for working with circuits as graphs
- a *mapper* module for mapping all-to-all circuits to run on devices with fixed couplings
- a *simulators* module contains quantum circuit simulators
- a *tools* directory contains methods for applications, analysis, and visualization
Quantum circuits flow through the components as follows. The programming interface is used to generate **OpenQASM** circuits, as text or *QuantumCircuit* objects. **OpenQASM** source, as a file or string, is passed into a *Qasm* object, whose parse method produces an abstract syntax tree (**AST**). The **AST** is passed to an *Unroller* that is attached to an *UnrollerBackend*. There is a *PrinterBackend* for outputting text, a *JsonBackend* for producing input to simulator and experiment backends, a *DAGBackend* for constructing *DAGCircuit* objects, and a *CircuitBackend* for producing *QuantumCircuit* objects. The *DAGCircuit* object represents an “unrolled” **OpenQASM** circuit as a directed acyclic graph (DAG). The *DAGCircuit* provides methods for representing, transforming, and computing properties of a circuit and outputting the results again as **OpenQASM**. The whole flow is used by the *mapper* module to rewrite a circuit to execute on a device with fixed couplings given by a *CouplingGraph*. The structure of these components is subject to change.
Quantum circuits flow through the components as follows. The programming interface is used to
generate **OpenQASM** circuits, as text or *QuantumCircuit* objects. **OpenQASM** source, as a
file or string, is passed into a *Qasm* object, whose parse method produces an abstract syntax
tree (**AST**). The **AST** is passed to an *Unroller* that is attached to an *UnrollerBackend*.
There is a *PrinterBackend* for outputting text, a *JsonBackend* for producing input to
simulator and experiment backends, a *DAGBackend* for constructing *DAGCircuit* objects, and
a *CircuitBackend* for producing *QuantumCircuit* objects. The *DAGCircuit* object represents
an “unrolled” **OpenQASM** circuit as a directed acyclic graph (DAG). The *DAGCircuit* provides
methods for representing, transforming, and computing properties of a circuit and outputting the
results again as **OpenQASM**. The whole flow is used by the *mapper* module to rewrite a
circuit to execute on a device with fixed couplings given by a *CouplingGraph*. The structure of
these components is subject to change.
The circuit representations and how they are currently transformed into each other are summarized in this figure:
The circuit representations and how they are currently transformed into each other are summarized
in this figure:

View File

@ -1,7 +1,8 @@
Example Real Chip Backend
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
.. code-block:: python
:linenos:
from qiskit import QuantumProgram
@ -9,7 +10,8 @@ Example Real Chip Backend
Q_program = QuantumProgram()
# Set your API Token
# You can get it from https://quantumexperience.ng.bluemix.net/qx/account, looking for "Personal Access Token" section.
# You can get it from https://quantumexperience.ng.bluemix.net/qx/account,
# looking for "Personal Access Token" section.
QX_TOKEN = "API_TOKEN"
QX_URL = "https://quantumexperience.ng.bluemix.net/api"

View File

@ -8,14 +8,18 @@ Installation
1. Get the tools
----------------
To use QISKit you'll need to have installed at least `Python 3.5 or later <https://www.python.org/downloads/>`__ and `Jupyter Notebooks <https://jupyter.readthedocs.io/en/latest/install.html>`__ (recommended for interacting with the tutorials).
To use QISKit you'll need to have installed at least
`Python 3.5 or later <https://www.python.org/downloads/>`__ and
`Jupyter Notebooks <https://jupyter.readthedocs.io/en/latest/install.html>`__
(recommended for interacting with the tutorials).
For this reason we recommend installing `Anaconda 3 <https://www.continuum.io/downloads>`__
python distribution, which already comes with all these dependencies pre-installed.
if you are a Mac OS X user, you will find Xcode useful: https://developer.apple.com/xcode/
if you are willing to contribute to QISKit or just wanted to extend it, you should install Git too: https://git-scm.com/download/.
if you are willing to contribute to QISKit or just wanted to extend it, you
should install Git too: https://git-scm.com/download/.
2. PIP Install
@ -30,7 +34,8 @@ The fastest way to install QISKit is by using the PIP tool (Python package manag
3. Repository Install
---------------------
Other common option is to clone the QISKit SDK repository on your local machine, and change into the cloned directory:
Other common option is to clone the QISKit SDK repository on your local machine,
and change into the cloned directory:
- If you have Git installed, run the following commands:

View File

@ -12,16 +12,20 @@ To compose and run a circuit on a simulator, which is distributed with
this project, one can do,
.. code-block:: python
:linenos:
from qiskit import QuantumProgram
qp = QuantumProgram()
qr = qp.create_quantum_register('qr', 2)
cr = qp.create_classical_register('cr', 2)
qc = qp.create_circuit('Bell', [qr], [cr])
qc.h(qr[0])
qc.cx(qr[0], qr[1])
qc.measure(qr[0], cr[0])
qc.measure(qr[1], cr[1])
result = qp.execute('Bell')
print(result.get_counts('Bell'))