Skip to content

Commit

Permalink
Merge pull request #1512 from qiboteam/docs
Browse files Browse the repository at this point in the history
Update outdated docstrings
  • Loading branch information
MatteoRobbiati authored Nov 13, 2024
2 parents b4da3bf + 3110f99 commit 9474eaa
Show file tree
Hide file tree
Showing 44 changed files with 1,002 additions and 904 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Here another example with more gates and shots simulation:
import numpy as np
from qibo import Circuit, gates

c = Circuit(2)
c.add(gates.X(0))
circuit = Circuit(2)
circuit.add(gates.X(0))

# Add a measurement register on both qubits
c.add(gates.M(0, 1))
circuit.add(gates.M(0, 1))

# Execute the circuit with the default initial state |00>.
result = c(nshots=100)
result = circuit(nshots=100)
```

In both cases, the simulation will run in a single device CPU or GPU in double precision `complex128`.
Expand Down
53 changes: 26 additions & 27 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,20 @@ Circuit addition

.. testsetup::

import qibo
from qibo import models
from qibo import gates
from qibo import Circuit, gates
from qibo.models import QFT

.. testcode::

c1 = models.QFT(4)
circuit_1 = QFT(4)

c2 = models.Circuit(4)
c2.add(gates.RZ(0, 0.1234))
c2.add(gates.RZ(1, 0.1234))
c2.add(gates.RZ(2, 0.1234))
c2.add(gates.RZ(3, 0.1234))
circuit_2 = Circuit(4)
circuit_2.add(gates.RZ(0, 0.1234))
circuit_2.add(gates.RZ(1, 0.1234))
circuit_2.add(gates.RZ(2, 0.1234))
circuit_2.add(gates.RZ(3, 0.1234))

c = c1 + c2
circuit = circuit_1 + circuit_2

will create a circuit that performs the Quantum Fourier Transform on four qubits
followed by Rotation-Z gates.
Expand Down Expand Up @@ -93,28 +92,28 @@ For example the following:

.. testcode::

from qibo import models, gates
from qibo import Circuit, gates

c = models.Circuit(2)
c.add([gates.H(0), gates.H(1)])
c.add(gates.CZ(0, 1))
c.add([gates.X(0), gates.Y(1)])
fused_c = c.fuse()
circuit = Circuit(2)
circuit.add([gates.H(0), gates.H(1)])
circuit.add(gates.CZ(0, 1))
circuit.add([gates.X(0), gates.Y(1)])
fused_circuit = circuit.fuse()

will create a new circuit with a single :class:`qibo.gates.special.FusedGate`
acting on ``(0, 1)``, while the following:

.. testcode::

from qibo import models, gates
from qibo import Circuit, gates

c = models.Circuit(3)
c.add([gates.H(0), gates.H(1), gates.H(2)])
c.add(gates.CZ(0, 1))
c.add([gates.X(0), gates.Y(1), gates.Z(2)])
c.add(gates.CNOT(1, 2))
c.add([gates.H(0), gates.H(1), gates.H(2)])
fused_c = c.fuse()
circuit = Circuit(3)
circuit.add([gates.H(0), gates.H(1), gates.H(2)])
circuit.add(gates.CZ(0, 1))
circuit.add([gates.X(0), gates.Y(1), gates.Z(2)])
circuit.add(gates.CNOT(1, 2))
circuit.add([gates.H(0), gates.H(1), gates.H(2)])
fused_circuit = circuit.fuse()

will give a circuit with two fused gates, the first of which will act on
``(0, 1)`` corresponding to
Expand Down Expand Up @@ -1422,10 +1421,10 @@ The final result of the circuit execution can also be saved to disk and loaded b

.. testcode::

c = Circuit(2)
c.add(gates.M(0,1))
circuit = Circuit(2)
circuit.add(gates.M(0,1))
# this will be a CircuitResult object
result = c()
result = circuit()
# save it to final_result.npy
result.dump('final_result.npy')
# can be loaded back
Expand Down
Loading

0 comments on commit 9474eaa

Please sign in to comment.