Skip to content

Commit

Permalink
Merge branches 'main' and 'cutoff-per-qumode' of https://github.com/C…
Browse files Browse the repository at this point in the history
…2QA/bosonic-qiskit into cutoff-per-qumode
  • Loading branch information
tjstavenger-pnnl committed Oct 12, 2023
2 parents 570930a + 288a536 commit 6e4990c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/pydoctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: apidocs
on:
- push

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install requirements for documentation generation
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install docutils pydoctor
- name: Generate API documentation with pydoctor
run: |
# Run pydoctor build
pydoctor \
--project-name=bosonic-qiskit \
--project-url=https://github.com/$GITHUB_REPOSITORY \
--html-viewsource-base=https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_SHA \
--make-html \
--html-output=./apidocs \
--project-base-dir="$(pwd)" \
--docformat=google \
--intersphinx=https://docs.python.org/3/objects.inv \
./c2qa
- name: Push API documentation to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./apidocs
commit_message: "Generate API documentation"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,6 @@ tutorials/**/*.mp4
tests/**/*.gif
tutorials/**/*.gif
tests/**/*.apng
tutorials/**/*.apng
tutorials/**/*.apng

apidocs/
3 changes: 2 additions & 1 deletion c2qa/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ def cv_initialize(self, params, qumodes):
Args:
params (list or int): If an int, all specified qumodes will be initialized to the Fock state with n=params.
If a list, all specified qumodes will be initialized to a superposition of Fock states,
with params[n] the complex amplitude of Fock state |n>. The length of params must be less
with ``params[n]`` the complex amplitude of Fock state ``|n>``. The length of params must be less
than or equal to the cutoff.
qumodes (list): list of qubits representing a single qumode, or list of multiple qumodes
Raises:
Expand Down
2 changes: 2 additions & 0 deletions c2qa/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,10 @@ def c_multiboson_sampling(self, max, cutoff):

def gate_from_matrix(self, matrix):
"""Converts matrix into gate. Called using ParameterizedUnitaryGate.
Args:
matrix (list): the (unitary) matrix that you wish to convert into a gate
Returns:
csc_matrix: operator matrix
"""
Expand Down
10 changes: 4 additions & 6 deletions c2qa/parameterized_unitary_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ def __init__(
Args:
op_func (function): function to build operator matrix
params (List): List of parameters to pass to op_func to build
operator matrix (supports instances of Qiskit Parameter to be
bound later)
num_qubits (int): Number of qubits in the operator -- this would
likely equate to (num_qubits_per_qumode * num_qumodes + num_ancilla).
cutoffs (List): cutoff values for each param (taken from each QumodeRegister)
params (List): List of parameters to pass to op_func to build operator matrix (supports instances of Qiskit Parameter to be bound later)
num_qubits (int): Number of qubits in the operator -- this would likely equate to (num_qubits_per_qumode * num_qumodes + num_ancilla).
label (string, optional): Gate name. Defaults to None.
duration (int, optional): Duration of gate used for noise modeling. Defaults to 100.
unit (string, optional): Unit of duration (only supports those allowed by Qiskit).
Expand Down Expand Up @@ -103,9 +99,11 @@ def calculate_matrix(
):
"""Calculate the operator matrix by executing the selected function.
Increment the parameters based upon the current and total steps.
Args:
current_step (int, optional): Current step within total_steps. Defaults to 1.
total_steps (int, optional): Total steps to increment parameters. Defaults to 1.
Returns:
ndarray: operator matrix
"""
Expand Down
8 changes: 4 additions & 4 deletions c2qa/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,17 @@ def fockmap(matrix, fock_input, fock_output, amplitude=[]):
Two use cases
1) int + list datatype combination (length of amp list must match length of either fock_input or fock_output, whichever is longer):
>fockmap(matrix, 1, [0, 1])
->> |0><1| + |1><1|
->> ``|0><1| + |1><1|``
>fockmap(matrix, [3, 2], 0, [0.5j, 1])
->> 0.5j|0><3| + |0><2|
->> ``0.5j|0><3| + |0><2|``
2) list datatype
>fockmap(matrix, [3, 2], [2, 1], [0.1j, 0.8])
->> 0.1j|2><3| + 0.8|1><2|
->> ``0.1j|2><3| + 0.8|1><2|``
>fockmap(matrix, [1, 1], [2, 4])
->> |2><1| + |4><1|
->> ``|2><1| + |4><1|``
Args:
Expand Down

0 comments on commit 6e4990c

Please sign in to comment.