Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New minor version, with it's flow of buxfixes #62

Merged
merged 72 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
41d12b8
doc: reformulated the Pauli string name conflict note
Henri-ColibrITD Jun 4, 2024
b7f092e
doc: remove custome gates from doc
MoHermes Jun 4, 2024
fe23cbe
doc: PS remark sphinx render fixed
Henri-ColibrITD Jun 5, 2024
3c56640
doc: update custom.js to generate a list of native gates
MoHermes Jun 5, 2024
b8f0947
doc: ensure the list is inserted correctly after the <h2> title
MoHermes Jun 5, 2024
346c31a
doc: change list layout to horizontal display
MoHermes Jun 6, 2024
e844a11
doc: update custom.js with the required gates, insert some texts
MoHermes Jun 6, 2024
5412d8c
doc: update css rules
MoHermes Jun 6, 2024
2e45138
doc: refined the ng link list generation and the sticky imports
Henri-ColibrITD Jun 7, 2024
2511f0e
doc: update both custom.js and custom.css, enhance the work done on n…
MoHermes Jun 7, 2024
b3e6890
doc: gates list more homogeneous
Henri-ColibrITD Jun 7, 2024
fb7b85c
Merge branch 'feat-doc-update' of https://github.com/ColibrITD-SAS/mp…
Henri-ColibrITD Jun 7, 2024
e0ccfaf
Merge pull request #55 from ColibrITD-SAS/feat-doc-update
Henri-ColibrITD Jun 7, 2024
e44ed82
Merge branch 'main' into dev
Henri-ColibrITD Jun 7, 2024
f055a19
fix: braket tag is now dynamically set
Henri-ColibrITD Jun 7, 2024
8962a90
fix: delayed imports re-added and improved
Henri-ColibrITD Jun 10, 2024
9988582
chores: start reviewing TODOs
Henri-ColibrITD Jun 10, 2024
d34ea8c
chores: todos updates
Henri-ColibrITD Jun 10, 2024
73f2f54
chores: preparing the exiting feature
Henri-ColibrITD Jun 11, 2024
e9b2920
fix: highlight in doc for dark mode improved
Henri-ColibrITD Jun 11, 2024
1595ea9
fix: added back the 3M-TODOs so that the doctest passes
Henri-ColibrITD Jun 11, 2024
c8e3c77
fix: delayed imports advanced
Henri-ColibrITD Jun 11, 2024
870b5fe
fix: more progress on delayed imports
Henri-ColibrITD Jun 12, 2024
63f103b
doc: white shadow for dark theme switcher
JulienCalistoTD Jun 12, 2024
dd27aa8
feat: targets as an option for NoiseModel
JulienCalistoTD Jun 12, 2024
9029edf
doc: notebooks tweaks
Henri-ColibrITD Jun 12, 2024
70c4939
Merge remote-tracking branch 'origin/dev' into dev
Henri-ColibrITD Jun 12, 2024
2219de6
doc: error better documented
Henri-ColibrITD Jun 12, 2024
6d63cf6
feat: execute several circuits with a single call to "run"
JulienCalistoTD Jun 12, 2024
1888b3c
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
JulienCalistoTD Jun 12, 2024
653a7d0
fix: add None for result test
JulienCalistoTD Jun 12, 2024
35e50fc
fix: remove set for device, for sorted result
JulienCalistoTD Jun 12, 2024
0aee78d
doc: installing pandoc added in contributing.md
Henri-ColibrITD Jun 13, 2024
397e02d
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
Henri-ColibrITD Jun 13, 2024
ebb306e
chore: formatting details
Henri-ColibrITD Jun 17, 2024
eb35cda
doc: import symbols form sympy on examples
JulienCalistoTD Jun 18, 2024
9aeed4e
doc: ABC improvement
Henri-ColibrITD Jun 20, 2024
654787d
doc: gate list is sticky
Henri-ColibrITD Jun 20, 2024
c7de199
fix: allow higher versions of jsonschema
hJaffaliColibritd Jun 21, 2024
72497c9
doc: update doc for controlled gate, abc instantiation
MoHermes Jun 24, 2024
a2c46be
doc: update doc for gate, abc instantiation
MoHermes Jun 24, 2024
cae4e7a
doc: update doc for native gates, abc instantiation
MoHermes Jun 24, 2024
fd57193
doc: update doc for parametrized gate, abc instantiation
MoHermes Jun 24, 2024
2d9cc12
fix: noise gate filter fixed
Henri-ColibrITD Jun 24, 2024
4ff15b2
test: circ init with noise
Henri-ColibrITD Jun 24, 2024
93461c7
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
Henri-ColibrITD Jun 24, 2024
59bdb0e
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
JulienCalistoTD Jun 25, 2024
bbeef70
feat: add test for examples and notebooks
JulienCalistoTD Jun 25, 2024
e2eb27b
feat: add --long option for tests on push to main
JulienCalistoTD Jun 25, 2024
92a34f8
feat: add option --longlocal for pytest
JulienCalistoTD Jun 25, 2024
6a0928e
fix: test for google
JulienCalistoTD Jun 25, 2024
77998df
doc: reformat Google test
JulienCalistoTD Jun 25, 2024
798f796
fix: noise targets segfault
JulienCalistoTD Jun 25, 2024
b9e8232
chore: in JobStatus, messages only need to be stored in docstrings
Henri-ColibrITD Jun 25, 2024
add8a86
doc: MessageEnum warning
Henri-ColibrITD Jun 25, 2024
855da1e
doc: language completed
Henri-ColibrITD Jun 25, 2024
bf4f990
chore: circ pprint, remove prural marker if applicable
JulienCalistoTD Jun 25, 2024
60936d6
doc: MessageEnum's example cannot be tested since inspect does not wo…
Henri-ColibrITD Jun 25, 2024
610417b
doc: typo
Henri-ColibrITD Jun 25, 2024
2de4d59
chore: typos, small optimizations and alike
Henri-ColibrITD Jun 25, 2024
4fc9b83
chore: esthetic fixes
Henri-ColibrITD Jun 25, 2024
9a2d7ac
Merge pull request #60 from ColibrITD-SAS/feat-test-exemples
Henri-ColibrITD Jun 25, 2024
c26688b
Merge branch 'dev' of https://github.com/ColibrITD-SAS/mpqp into dev
JulienCalistoTD Jun 26, 2024
986c885
doc-fix: example of prettyprint
JulienCalistoTD Jun 26, 2024
3f9af1a
doc: changed the abstract note to be automatically added on page load…
Henri-ColibrITD Jun 26, 2024
e846e86
chore: forgotten console log
Henri-ColibrITD Jun 26, 2024
0167a89
Merge pull request #58 from ColibrITD-SAS/feat-doc-abc
Henri-ColibrITD Jun 26, 2024
ab6da5c
chore: forgot about a css detail
Henri-ColibrITD Jun 26, 2024
6eafaae
doc: classproperty
Henri-ColibrITD Jun 26, 2024
8099100
doc: SimpleClassReprABC
Henri-ColibrITD Jun 26, 2024
664b60d
fix: raise ValueError if nb_target < dimension when target apply to a…
JulienCalistoTD Jun 26, 2024
971d97c
fix: noise default targets rolled back because incomplete
Henri-ColibrITD Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,57 @@ on:
push:
branches:
- dev
- main
workflow_dispatch:
inputs:
python_v:
description: 'python version'
description: "python version"
required: true
default: '3.9'
default: "3.9"
type: choice
options:
- '3.9'
- '3.10'
- '3.11'
- "3.9"
- "3.10"
- "3.11"
commit_ref:
description: Specific ref (branch, tag or SHA)
default: ''
default: ""
type: string
required: false

long:
description: "Run long tests"
required: false
default: false
type: boolean

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_ref || github.ref }}
- name: Set up Python ${{ github.event.inputs.python_v || '3.9' }}
- name: Set up python ${{ github.event.inputs.python_v || '3.9' }}
uses: actions/setup-python@v5
with:
python-version: ${{ github.event.inputs.python_v || '3.9' }}
cache: "pip"
- name: Install Dependencies
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run test
run: python -m pytest
- name: Install long dedendencies
if: ${{ github.event.inputs.long == 'true' || github.ref_name == 'main' }}
run: |
pip install .
sudo apt-get update
sudo apt install -y poppler-utils
sudo apt-get install -y texlive-latex-base texlive-pictures texlive-latex-extra
- name: Run tests
run: |
if [ "${{ github.event.inputs.long }}" == "true" ] || [ "${{ github.ref_name }}" == "main" ]; then
python -m pytest --long-local
else
python -m pytest
fi
24 changes: 16 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describing the problem you would like to solve.

### Setup your environment locally

_Some commands will assume you have the GitHub CLI installed, if you haven't,
\_Some commands will assume you have the GitHub CLI installed, if you haven't,
consider [installing it](https://github.com/cli/cli#installation), but you can
always use the Web UI if you prefer that instead.

Expand All @@ -41,6 +41,13 @@ etc... included), use pip:
pip install -r requirements-dev.txt
```

In the documentation, some notebooks are rendered to HTML, this process is done
using [Pandoc](https://pandoc.org/). Unfortunately, this software cannot be
installed from the pip repository, so you need to install it separately. You can
check [their documentation](https://pandoc.org/installing.html) to see how to
install it on your OS (you can find it on most package manager: `apt`,
`yum`, `pacman`, `choco`, `winget`, `brew` and more... )

The last (optinal) step is to setup a GitHub personal access tokens to enable
the sphinx automatic changelog generation. This step is only important if you
want to preview this changelog generation on your personal computer. Not being
Expand Down Expand Up @@ -88,11 +95,12 @@ repository, and find the one you need to modify to achieve your goal.

Here are some useful scripts for when you are developing:

| Command | Description |
| --------------------------------- | ------------------------ |
| `sphinx-build -b html docs build` | Builds the documentation |
| `python -m pytest` | Runs the test suite |
| `python -m pytest --long` | Runs the long tests too |
| Command | Description |
| --------------------------------- | ------------------------- |
| `sphinx-build -b html docs build` | Builds the documentation |
| `python -m pytest` | Runs the test suite |
| `python -m pytest --long` | Runs the long tests too |
| `python -m pytest --long-local` | Runs the local long tests |

When making commits, make sure to follow the
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/)
Expand All @@ -117,8 +125,8 @@ following (even though each of these sections is optional):
2. `Returns`
3. `Raises`
4. `Example(s)`
5. `Notes`
6. `Warnings`
5. `Note`
6. `Warning`

### When you're done

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ RUN pip3 install --upgrade pip && \

FROM python:3.9

RUN apt-get update && \
apt-get install -y pandoc && \
apt-get clean && \
RUN apt update && \
apt install -y pandoc && \
apt clean && \
rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app/mpqp
Expand Down
15 changes: 6 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import os

from pytest import Metafunc, Parser
from pytest import Parser


def pytest_addoption(parser: Parser):
parser.addoption("--long", action="store_false", help="If set, long tests will run")


def pytest_generate_tests(metafunc: Metafunc):
print("ho")
if metafunc.config.option.long:
os.environ["LONG_TESTS"] = "True"
parser.addoption(
"--long-local",
action="store_false",
help="If set, only local long tests will run",
)
50 changes: 50 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ div.document {
} */

/* *** fix for rtd dark *** */
html[data-theme="dark"] .theme-switcher {
box-shadow: 0px 1px 14px 2px rgb(255 255 255 / 20%);
}

html[data-theme="dark"] div.nboutput.container div.output_area.stderr {
background: rgb(103, 23, 23);
Expand Down Expand Up @@ -159,3 +162,50 @@ html[data-theme="dark"] .rst-content .admonition,
html[data-theme="dark"] .rst-content .note {
background-color: #80cb53;
}*/

.highlight-python.import {
position: sticky;
top: 10px;
z-index: 9999;
box-shadow: 0px 0px 10px 0px black;
}

html[data-theme="dark"] .highlight-python.import {
box-shadow: 0px 0px 10px 0px #595959;
}

html[data-theme="dark"] .rst-content .highlighted {
background: #7e6500;
box-shadow: 0 0 0 2px #7e6500;
}

#native-gates-list > * {
position: relative;
}

#native-gates-list {
display: flex;
flex-wrap: wrap;
margin-block-end: 1em;
position: sticky;
top: 57px;
z-index: 10000;
background-color: #141414;
}

#native-gates-list > * {
padding: 0 1em 0 1em;
border: 0.5px solid;
border-block-start: 0;
border-block-end: 0;
border-color: black;
margin-block-end: 0.5em;
}

html[data-theme="dark"] #native-gates-list > * {
border-color: white;
}

section > * {
scroll-padding-block-start: 60px;
}
44 changes: 39 additions & 5 deletions docs/_static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,41 @@ window.onload = () => {
}
}
});
};

// const themeButton = document.querySelector('themeSwitcher')
// themeButton.addEventListener('click', () => {
//
// });
// in the native gates section, add the list of native gates
ngListLocation = document.getElementById("native-gates-list");
if (ngListLocation) {
ngSection = ngListLocation.parentElement;
ngClasses = ngSection.querySelectorAll("dl.py.class");
ngLinks = "";

ngClasses.forEach(function (c) {
if (c.textContent.includes("ABC")) return;
ngLinks += `<a href="#${c.querySelector("dt.sig.sig-object.py").id}">
${c.querySelector("span.descname").innerText}
</a>`;
});
ngListLocation.innerHTML = ngLinks;
}

// we add a note for abstract classes to remind that they cannot be
// implemented directly
document.querySelectorAll(".class").forEach((class_elt) => {
if (isABC(class_elt)) {
parents = class_elt.querySelector("dd > p:first-child");
template = document.createElement("template");
template.innerHTML = `
<div class="admonition note">
<p class="admonition-title"><span>Note</span></p>
<p>
Abstract classes (ABCs) are not meant to be instantiated as is. See
classes that inherite from this one to check how to instantiate it.
</p>
</div>`;
parents.insertAdjacentElement("afterend", template.content.children[0]);
}
});
};

function getEndOfClassHeader(elt) {
admonition = elt.querySelectorAll(".admonition");
Expand All @@ -93,6 +122,11 @@ function getEndOfClassHeader(elt) {
return elt;
}

function isABC(elt) {
parents = elt.querySelector("dd > p:first-child");
return parents && parents.innerHTML.includes("ABC");
}

function isEnum(elt, explored = []) {
id = elt.querySelector("dt").id;
if (explored.includes(id)) return false;
Expand Down
1 change: 1 addition & 0 deletions docs/barrier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Barriers
========

.. code-block:: python
:class: import

from mpqp import Barrier

Expand Down
1 change: 1 addition & 0 deletions docs/circuit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ The Quantum Circuit
===================

.. code-block:: python
:class: import

from mpqp import QCircuit

Expand Down
1 change: 1 addition & 0 deletions docs/execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Execution
=========

.. code-block:: python
:class: import

from mpqp.execution import *

Expand Down
1 change: 1 addition & 0 deletions docs/gates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Gates
=====

.. code-block:: python
:class: import

from mpqp.gates import *

Expand Down
1 change: 1 addition & 0 deletions docs/measures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Measurements
============

.. code-block:: python
:class: import

from mpqp.measures import *

Expand Down
1 change: 1 addition & 0 deletions docs/noise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ details about the manipulation, usage, and simulation of noise models are
presented.

.. code-block:: python
:class: import

from mpqp.noise import *

Expand Down
1 change: 1 addition & 0 deletions docs/qasm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ QASM converter
==================

.. code-block:: python
:class: import

from mpqp.qasm import *

Expand Down
4 changes: 4 additions & 0 deletions docs/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Useful Maths Operations
-----------------------

.. code-block:: python
:class: import

from mpqp.tools.maths import *

Expand All @@ -22,6 +23,7 @@ Generics
--------

.. code-block:: python
:class: import

from mpqp.tools.generics import *

Expand All @@ -31,6 +33,7 @@ Errors
------

.. code-block:: python
:class: import

from mpqp.tools.errors import *

Expand All @@ -40,6 +43,7 @@ Choice Tree
-----------

.. code-block:: python
:class: import

from mpqp.tools.choice_tree import *

Expand Down
3 changes: 2 additions & 1 deletion docs/vqa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Variational Quantum Algorithms
==============================

.. code-block:: python
:class: import

from mpqp.execution.vqa import *

Expand All @@ -16,7 +17,7 @@ value attributed. It can be created as such:

.. code-block:: python

from mpqp.execution.vqa import symbols
from sympy import symbols

theta, k = symbols("Θ k")

Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/1_Basics_of_circuit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@
"metadata": {},
"outputs": [],
"source": [
"from mpqp.gates import symbols\n",
"from sympy import symbols\n",
"\n",
"theta, k = symbols(\"θ k\")"
]
Expand Down Expand Up @@ -790,7 +790,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
"version": "3.9.5"
}
},
"nbformat": 4,
Expand Down
Loading
Loading