Skip to content

Commit 241dc75

Browse files
Merge branch 'dev' into feat-cirq-provider
2 parents 0adf81f + aa3890e commit 241dc75

18 files changed

+401
-123
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ __pycache__/
1111
.pytest_cache/
1212
.dockerenv
1313
.env
14-
.idea/
14+
.idea/
15+
.vs/

CONTRIBUTING.md

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Contribution Guidelines
2+
3+
When contributing to `MPQP`, whether on GitHub or in other community spaces:
4+
5+
- Be respectful, civil, and open-minded.
6+
- If you want to make code changes based on your personal opinion(s), make sure
7+
you open an issue first describing the changes you want to make, and open a
8+
pull request only when your suggestions get approved by maintainers.
9+
10+
## How to Contribute
11+
12+
### Prerequisites
13+
14+
In order to not waste your time implementing a change that has already been
15+
declined, or is generally not needed, start by [opening an
16+
issue](https://github.com/ColibrITD-SAS/mpqp/issues/new/choose) describing the
17+
problem you would like to solve.
18+
19+
### Setup your environment locally
20+
21+
_Some commands will assume you have the Github CLI installed, if you haven't,
22+
consider [installing it](https://github.com/cli/cli#installation), but you can
23+
always use the Web UI if you prefer that instead._
24+
25+
In order to contribute to this project, you will need to fork the repository:
26+
27+
```bash
28+
gh repo fork ColibrITD-SAS/mpqp
29+
```
30+
31+
then, clone it to your local machine:
32+
33+
```bash
34+
gh repo clone <your-github-name>/mpqp
35+
```
36+
37+
To install all the dependencies needed to contribute (documentation, tests,
38+
etc... included), use pip:
39+
40+
```bash
41+
pip install -r requirements-dev.txt
42+
```
43+
44+
### Our tech stack
45+
46+
Here are the pieces of software useful to know to work on our library:
47+
48+
- All the code of the Library is in [Python](https://www.python.org).
49+
- We run our tests using [pytest](https://docs.pytest.org).
50+
- We generate our documentation using [Sphinx](https://www.sphinx-doc.org).
51+
- We format the code using [black](https://black.readthedocs.io), but this is not
52+
configured yet.
53+
- We check our types using [Pyright](https://microsoft.github.io/pyright), but
54+
this is not configured yet.
55+
- The documentation is automatically deployed on new versions with
56+
[GitHub Actions](https://docs.github.com/en/actions). (As well as a few other
57+
bits and bobs)
58+
59+
### Implement your changes
60+
61+
This project is organized as such:
62+
63+
- `mpqp/` contains the source code of the library;
64+
- `docs/` contains the source code of the documentation, but working on the
65+
documentation will require you to also get comfortable with the source code,
66+
since the biggest part of the documentation is as docstrings in the library
67+
source code (using the `autodoc` Sphinx extension);
68+
- all the source files requiring testing are mirrored from `mpqp\` to `tests\`.
69+
We do not consider all code need to be tested, but the "tricky" (error prone)
70+
code should be covered a minimum amount (we are actively trying to improve the
71+
state of testing in our library currently).
72+
73+
Strong of this knowledge, you should be able to go through the files of this
74+
repository, and find the one you need to modify to achieve your goal.
75+
76+
Here are some useful scripts for when you are developing:
77+
78+
| Command | Description |
79+
| --------------------------------- | ------------------------ |
80+
| `sphinx-build -b html docs build` | Builds the documentation |
81+
| `python -m pytest` | Runs the test suite |
82+
| `python -m pytest -l` | Runs the long tests too |
83+
84+
When making commits, make sure to follow the
85+
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/)
86+
guidelines, i.e. prepending the message with `feat:`, `fix:`, `doc:`, etc...
87+
You can use `git status` to double check which files have not yet been staged
88+
for commit:
89+
90+
```bash
91+
git add <file> && git commit -m "feat/fix/doc: commit message"
92+
```
93+
94+
### When you're done
95+
96+
We would like you to format your code using `black`, and check that your type
97+
hints are coherent using `Pyright`, but there are not configured yet. This
98+
should be dealt with shortly.
99+
100+
Please make sure your changes are working as expected (and that you didn't break
101+
any previous feature) by making manual, running the automated tests and adding
102+
now ones corresponding to your feature.
103+
104+
When all that's done, it's time to file a pull request to upstream:
105+
106+
```bash
107+
gh pr create --web
108+
```
109+
110+
and fill out the title and body appropriately.
111+
112+
## Translations
113+
114+
For now, we only support the english language. If you would like to start a
115+
translation of the documentation, get in touch with us so we set it up together!
116+
117+
## Credits
118+
119+
This documented was inspired by the contributing guidelines for
120+
[t3-oss/create-t3-app](https://github.com/t3-oss/create-t3-app/blob/main/CONTRIBUTING.md).

docs/getting-started.rst

+19-10
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,28 @@ Installation
77
.. TODO: grab the compatibility matrix from MyQLM and relax our requirements
88
.. when possible, test on many different configurations (tox or other ?)
99
10-
For now, we support python versions 3.9 to 3.11, and both Windows and Linux
11-
(specifically, if was validated on Ubuntu LTS 20.04, while Ubuntu 18.04 is not
12-
supported). MacOS versions will come very soon!
10+
For now, we support python versions 3.9 to 3.11, and both Windows, Linux and
11+
MacOS (specifically, Linux was validated on Ubuntu LTS 20.04, while Ubuntu 18.04
12+
is not supported, so your milage may vary).
1313

1414
.. code-block:: console
1515
1616
$ pip install mpqp
1717
18+
.. note::
19+
For mac users, additional steps are required before the installation,
20+
specifically because of the ``myqlm`` library. To run these steps, you can
21+
either follow their instructions on
22+
`this page <https://myqlm.github.io/01_getting_started/%3Amyqlm%3Amacos.html#macos>`_
23+
or run the script we created to facilitate this step:
24+
25+
.. code-block:: bash
26+
27+
curl -L https://raw.githubusercontent.com/ColibrITD-SAS/mpqp/main/mac-install.sh | bash -s -- <your-python-bin>
28+
29+
where ``<your-python-bin>`` is the binary you use to invoke python. It could
30+
for instance be ``python``, ``python3``, ``python3.9``, etc...
31+
1832
Your first circuit
1933
------------------
2034

@@ -39,18 +53,13 @@ Setup remote connection
3953

4054
After you installed MPQP package using ``pip install``, the script
4155
:mod:`setup_connections.py<mpqp.execution.connection.setup_connections>` can be
42-
called from everywhere, not only in ``mpqp`` folder, using the following command
43-
line:
56+
called to setup your connection to the remote backends supported, using the
57+
following command:
4458

4559
.. code-block:: console
4660
4761
$ setup_connections
4862
49-
This script will allow you to configure and save your personal account to
50-
connect to remote machines. Depending on the provider, different credentials can
51-
be asked. Information concerning which provider is configured and related
52-
credentials are stored in the ``~/.mpqp`` file.
53-
5463
IBM Quantum
5564
^^^^^^^^^^^
5665

docs/measures.rst

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ Measuring using an observable
4343

4444
.. automodule:: mpqp.core.instruction.measurement.expectation_value
4545

46+
Pauli String
47+
^^^^^^^^^^^^
48+
49+
.. automodule:: mpqp.core.instruction.measurement.pauli_string

mac-install.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ $# -eq 0 ]]; then
4+
echo "Please pass as argument to this script the python binary you want to install mpqp to."
5+
echo "For example:"
6+
echo " $ ./mac-install.sh python3"
7+
exit 1
8+
fi
9+
python_exec=$1
10+
brew install cmake libomp
11+
if [[ ! -f /usr/local/lib/libomp.dylib ]]; then
12+
brew_dir=$(which brew | sed 's/\/bin\/brew//g')
13+
libom_location=$brew_dir/Cellar/libomp
14+
version=$(ls $libom_location)
15+
sudo mkdir /usr/local/lib
16+
sudo ln -sf $libom_location/$version/lib/libomp.dylib /usr/local/lib/libomp.dylib
17+
fi
18+
$python_exec -m pip install mpqp

mpqp/all.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
ComputationalBasis,
5454
ExpectationMeasure,
5555
HadamardBasis,
56-
Measure,
57-
Observable,
58-
VariableSizeBasis,
5956
)
57+
from .measures import I as Iop
58+
from .measures import Measure, Observable, VariableSizeBasis
59+
from .measures import X as Xop
60+
from .measures import Y as Yop
61+
from .measures import Z as Zop
6062
from .qasm import open_qasm_file_conversion_2_to_3, open_qasm_hard_includes
6163

6264
theta, k = symbols("θ k") # type: ignore
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pyright: reportUnusedImport=false
2-
from .basis import ComputationalBasis, Basis, HadamardBasis, VariableSizeBasis
2+
from .basis import Basis, ComputationalBasis, HadamardBasis, VariableSizeBasis
33
from .basis_measure import BasisMeasure
44
from .expectation_value import ExpectationMeasure, Observable
55
from .measure import Measure
6+
from .pauli_string import I, X, Y, Z

0 commit comments

Comments
 (0)