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

prepare automated CD/CI #7

Merged
merged 12 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
with:
python-version: "3.8"
- uses: pre-commit/action@v3.0.0
- name: mypy
uses: jpetrucciani/mypy-check@master
with:
path: './qutree'
requirements: "."
mypy_flags: '--config-file ./pyproject.toml'

build:
runs-on: ubuntu-latest
Expand All @@ -32,8 +38,6 @@ jobs:
run: pip install .[test]
- name: test with pytest
run: pytest --color=yes --cov --cov-report=xml tests
- name: coverage
run: coverage report -m
#- name: codecov
# uses: codecov/codecov-action@v3
# with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
.ruff_cache/

# Translations
*.mo
Expand Down
16 changes: 5 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@ repos:
hooks:
- id: black
stages: [commit]
- repo: 'https://github.com/pycqa/flake8'
rev: 5.0.4
hooks:
- id: flake8
stages: [commit]
additional_dependencies: [Flake8-pyproject]
- repo: 'https://github.com/commitizen-tools/commitizen'
rev: v2.18.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: 'https://github.com/pycqa/isort'
rev: 5.10.1
hooks:
- id: isort
stages: [commit]
- repo: 'https://github.com/kynan/nbstripout'
rev: 0.5.0
hooks:
- id: nbstripout
stages: [commit]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.226"
hooks:
- id: ruff
stages: [commit]
90 changes: 43 additions & 47 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,83 +5,79 @@ After forking the projet, run the following command to start developing:

.. code-block:: console

$ git clone https://github.com/<github id>/<python_lib>.git
$ cd <python_lib>
$ pip install -e .[dev, test, doc]
git clone https://github.com/alice4space/qutree.git
cd qutree
pip install -e .[dev]

Nox
---

:code:`nox` can be used to automatically create isolated local development environments with all of the correct packages installed to work on the lib. The rest of this guide focuses on using nox to start with a basic environment.

You can call :code:`nox` from the command line in order to perform common actions that are needed in building the lib. :code:`nox` operates with isolated environments, so each action has its own packages installed in a local directory (:code:`.nox`). For common development actions, you’ll simply need to use :code:`nox` and won’t need to set up any other packages.

.. danger::
Pre-commit hooks
----------------

:code:`pre-commits` are installed in edit mode. Every commit that does not respect the conventional commits framework will be refused.
you can read this `documentation <https://www.conventionalcommits.org/en/v1.0.0/>`__ to learn more about them and we highly recommend to use the :code:`commitizen` lib to create your commits: `<https://commitizen-tools.github.io/commitizen>`__.
:code:`pre-commit` allows us to run several checks on the codebase every time a new Git commit is made. This ensures standards and basic quality control for our code.

Develop within the project
--------------------------
Install the pre-commit in the repository:

Since 2020-08-14, this repository follows these `development guidelines <https://nvie.com/posts/a-successful-git-branching-model/>`__.
.. code-block:: console

We need to provide the users with version informations. When a new function or class is created please use the `Deprecated <https://pypi.org/project/Deprecated/>`__ lib to specify that the feature is new in the documentation.
pre-commit install -t pre-commit -t commit-msg

.. code-block:: python
Linting operations will be run automatically for every downstream commit.

from deprecated.sphinx import deprecated
from deprecated.sphinx import versionadded
from deprecated.sphinx import versionchanged
.. note::

to run liniting operation without commiting your change execute the following:

@versionadded(version='1.0', reason="This function is new")
def function_one():
'''This is the function one'''
.. code-block:: console

nox -s lint

@versionchanged(version='1.0', reason="This function is modified")
def function_two():
'''This is the function two'''
Mypy
----

Mypy is a static type checker for Python.

@deprecated(version='1.0', reason="This function will be removed soon")
def function_three():
'''This is the function three'''

How to commit
-------------
Type checkers help ensure that you're using variables and functions in your code correctly. With mypy, add type hints (PEP 484) to your Python programs, and mypy will warn you when you use those types incorrectly.

In this repository we use the Conventional Commits specification.
The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.
Python is a dynamic language, so usually you'll only see errors in your code when you attempt to run it. Mypy is a static checker, so it finds bugs in your programs without even running them!

You can learn more about Conventional Commits following this `link <https://www.conventionalcommits.org/en/v1.0.0/>`__.
to run the MyPy checks run:

What can I push and where
-------------------------
.. code-block:: console

nox -s mypy

Documentation
-------------

Our branching system embed some rules to avoid crash of the production environment. If you want to contribute to this framework, here are some basic rules that we try our best to follow :
We build our documentation within the :code:`Sphinx` framework. execute the associated nox to build the file and produce the associated HTML:

- PR should answer issues. describe your problem or feature request in a GitHub issue and discuss with our team before starting coding.
- start a new branch from the :code:`develop` branch
- when ready open a PR on our repository on the same :code:`develop` branch
.. code-block:: console

the maintainers will try their best to use PR for new features, to help the community follow the development, for other modification they will simply push to the appropriate branch
nox -s docs

Create a new release
--------------------
The index file will be in :code:`./docs/build/html/index.html`.

.. danger::
Release
-------

for maintainers only

.. warning::

You need to use the :code:`commitizen` lib to create your release: `<https://commitizen-tools.github.io/commitizen>`__
You need to use the :code:`commitizen` lib to create your release: `<https://commitizen-tools.github.io/commitizen>`__.

In the files change the version number by runnning commitizen `bump`:

.. code-block:: console

cz bump

It should modify for you the version number in :code:`src/__init__.py` and :code:`setup.cfg` according to sementic versionning thanks to the conventional commit that we use in the lib.
It should modify for you the version number in :code:`qutree/__init__.py` and :code:`pyproject.toml` according to sementic versionning thanks to the conventional commit that we use in the lib.

It will also update the :code:`CHANGELOG.md` file with the latest commits, sorted by categories.

Then you can now create a new tag with your new version number. use the same convention as the one found in :code:`setup.cfg`: :code:`v$minor.$major.$patch$prerelease`.
You can now create a new tag with your new version number. use the same convention as the one found in :code:`pyproject.toml`: :code:`v$minor.$major.$patch$prerelease`.

The CI should take everything in control from here and execute the :code:`Upload Python Package` GitHub Action that is publishing the new version on `PyPi <#>`_.
The CI should take everything in control from here and execute the :code:`Upload Python Package` GitHub Action that is publishing the new version on `PyPi <https://pypi.org/project/qutree>`_.
88 changes: 53 additions & 35 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,52 +1,70 @@
qutree
======

.. image:: https://img.shields.io/badge/License-MIT-yellow
:target: https://github.com/alice4space/qutree/blob/main/LICENSE
:alt: License: MIT

.. image:: https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square
:alt: All contributors
:target: AUTHORS.rst
.. image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow
:target: https://conventionalcommits.org
:alt: conventional commit

.. image:: https://img.shields.io/badge/License-MIT-orange.svg
:target: LICENSE
:alt: License: MIT

.. image:: https://badge.fury.io/py/template.svg
:target: https://badge.fury.io/py/template
:alt: PyPI version


.. image:: https://img.shields.io/pypi/dm/template?color=307CC2&logo=python&logoColor=gainsboro
:target: https://pypi.org/project/template/
:alt: PyPI - Downloads

.. image:: https://img.shields.io/pypi/pyversions/template
:target: https://pypi.org/project/template/
:alt: supported Python version

.. image:: https://github.com/alice4space/qutree/actions/workflows/unit.yml/badge.svg
.. image:: https://img.shields.io/badge/code%20style-black-000000
:target: https://github.com/psf/black
:alt: Black badge

.. image:: https://img.shields.io/pypi/v/qutree?color=orange&logo=python&logoColor=white
:target: https://pypi.org/project/qutree
:alt: PyPI

.. image:: https://img.shields.io/github/actions/workflow/status/alice4space/qutree/unit.yml?logo=github&logoColor=white
:target: https://github.com/alice4space/qutree/actions/workflows/unit.yml
:alt: build

.. image:: https://codecov.io/gh/alice4space/qutree/branch/main/graph/badge.svg?token=YZ3mVcuaCq
.. image:: https://img.shields.io/codecov/c/github/alice4space/qutree?logo=codecov&logoColor=white
:target: https://codecov.io/gh/alice4space/qutree
:alt: Test Coverage

.. image:: https://readthedocs.org/projects/template/badge/?version=latest
:target: https://template.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Black badge

.. image:: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
:target: https://conventionalcommits.org
:alt: conventional commit

.. image:: https://img.shields.io/codeclimate/maintainability/alice4space/qutree?logo=codeclimate&logoColor=white
:alt: Code Climate maintainability

.. image:: https://img.shields.io/readthedocs/pyqutree/latest?logo=readthedocs&logoColor=white
:target: https://pyqutree.readthedocs.io/en/latest/
:alt: Documentation Status

.. image:: https://img.shields.io/badge/all_contributors-2-purple
:alt: All contributors
:target: https://github.com/alice4space/qutree/blob/main/AUTHORS.rst


Overview
--------
Plot sets of multiqubit quantum pure states as a binary tree of Bloch spheres

Plot sets of multiqubit quantum pure states as a binary tree of Bloch spheres.

We present a representation that can display several arbitrary multi-qubit pure states, using a combination of the Bloch Sphere and the Schmidt decomposition.

Our current approaches to visualization of quantum states allow to display:

- several mono-qubit states, using the Bloch sphere
- a single multi-qubit state, sometimes with additional restrictions such as symmetry

Usage
-----

install with pip:

.. code-block:: console

pip install qutree

And you will be able to produce this type of Bloch sphere's tree:

.. image:: https://raw.githubusercontent.com/12rambau/qutree/pre-release/docs/source/_static/example.png
:alt: example tree

More information can be found in our `documentation <https://pyqutree.readthedocs.io/en/latest/>`__.

If you want to contribute you can fork the project in your own repository and then use it. If you consider working with us, please follow the `contributing guidelines <https://pyqutree.readthedocs.io/en/latest/contribute.html>`__.

Meet our `contributor <https://pyqutree.readthedocs.io/en/latest/authors.html>`__.
11 changes: 10 additions & 1 deletion docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@
border-right: 1px solid var(--pst-color-text-base);
margin-right: 0.5em;
padding-right: 0.5em;
}
}

/*******************************************************************************
* add the dollar sign in console block
*/
div.highlight-console pre span.go::before {
content: "$";
margin-right: 10px;
margin-left: 5px;
}
Binary file added docs/source/_static/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/source/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Authors
=======

.. include :: ../../AUTHORS.rst
24 changes: 15 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Configuration file for the Sphinx documentation builder.
"""Configuration file for the Sphinx documentation builder.

This file only contains a selection of the most common options. For a full
list see the documentation:
Expand Down Expand Up @@ -42,15 +41,28 @@
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
html_css_files = ["custom.css"]
html_context = {
"default_mode": "light",
"github_user": "alice4space",
"github_repo": "qutree",
"github_version": "main",
"doc_path": "docs/source",
}

# -- Options for autosummary/autodoc output ------------------------------------
autosummary_generate = True
autoclass_content = "class"
autoclass_content = "init"
autodoc_typehints = "description"

# -- Option for Napoleon styling of tuple output -------------------------------
napoleon_custom_sections = [("Returns", "params_style")]

# -- Options of the HTML theme -------------------------------------------------
html_theme_options = {
"logo": {"text": project},
"use_edit_page_button": True,
"show_prev_next": True,
"navbar_end": ["navbar-icon-links"], # remove theme change
"icon_links": [
{
"name": "GitHub",
Expand All @@ -64,9 +76,3 @@
},
],
}
html_context = {
"github_user": "alice4space",
"github_repo": "qutree",
"github_version": "main",
"doc_path": "docs/source",
}
1 change: 1 addition & 0 deletions docs/source/contribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include :: ../../CONTRIBUTING.rst
12 changes: 2 additions & 10 deletions docs/source/examples/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"source": [
"bbt = BBT(2)\n",
"bbt.add_data(Ss)\n",
"bbt.plot_tree('bell.png')"
"bbt.plot_tree()"
]
},
{
Expand Down Expand Up @@ -281,14 +281,6 @@
"bbt.add_data(Sts,cmap='jet')\n",
"bbt.plot_tree()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0adf9708-a346-4327-a037-3a6f9df15b84",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -307,7 +299,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.8.3 (default, Oct 14 2020, 12:53:46) \n[Clang 11.0.3 (clang-1103.0.32.29)]"
},
"vscode": {
"interpreter": {
Expand Down
Loading