diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..b802568 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Linting + +on: + push: + branches: + - main + pull_request: {} + workflow_dispatch: {} + +jobs: + lint: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Qadence + uses: actions/checkout@v4 + + - name: Set up Python 3.x + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install pre-commit + run: | + pip install pre-commit + pre-commit install + + - name: Check files + run: | + pre-commit run --all-files diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4d65965 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,108 @@ +name: Tests + +on: + push: + branches: + - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + pull_request: + branches: + - main + workflow_dispatch: {} + +concurrency: + group: fast-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + + test_qadence_ubuntu: + name: Qadence (ubuntu) + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11"] + steps: + - name: Checkout Qadence + uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Hatch + run: | + pip install hatch + - name: Run tests + run: | + hatch -v run test + - name: Upload coverage data + uses: actions/upload-artifact@v4 + with: + name: "coverage-data" + path: .coverage.* + if-no-files-found: ignore + + publish: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/v') + needs: test_qadence_ubuntu + runs-on: ubuntu-latest + steps: + - name: Check out Qadence + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install hatch + - name: Build and publish package + run: | + hatch build + hatch publish -u ${{ secrets.HATCH_PYPI_USER }} -a ${{ secrets.HATCH_PYPI_AUTH }} + - name: Confirm deployment + timeout-minutes: 5 + run: | + VERSION=${GITHUB_REF#refs/tags/v} + until pip download qadence==$VERSION + do + echo "Failed to download from PyPI, will wait for upload and retry." + sleep 1 + done + + deploy_docs: + name: Deploy Qadence docs (ubuntu) + if: startsWith(github.ref, 'refs/tags/v') + needs: test_qadence_ubuntu + runs-on: ubuntu-latest + steps: + - name: Checkout Qadence + uses: actions/checkout@v4 + - name: Install JetBrains Mono font + run: | + sudo apt install -y wget unzip fontconfig + wget https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip + unzip JetBrainsMono-2.304.zip -d JetBrainsMono + mkdir -p /usr/share/fonts/truetype/jetbrains + cp JetBrainsMono/fonts/ttf/*.ttf /usr/share/fonts/truetype/jetbrains/ + fc-cache -f -v + - name: Install graphviz + run: sudo apt-get install -y graphviz + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install Hatch + run: | + pip install hatch + - name: Deploy docs + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git fetch origin gh-pages + hatch -v run docs:mike deploy --push --update-aliases ${{ github.ref_name }} latest diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e533b21..0000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "qadence2-expressions"] - path = qadence2-expressions - url = https://github.com/pasqal-io/wip-qadence2-expressions.git -[submodule "qadence2-platforms"] - path = qadence2-platforms - url = https://github.com/pasqal-io/wip-qadence2-platforms.git -[submodule "qadence2-ir"] - path = qadence2-ir - url = https://github.com/pasqal-io/qadence2-ir.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c0e99a5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/ambv/black + rev: 23.3.0 + hooks: + - id: black + +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: "v0.0.274" + hooks: + - id: ruff + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.4.0 + hooks: + - id: mypy + exclude: examples|docs diff --git a/README.md b/README.md index 19e8609..b5b91ff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # Qadence 2 core House for blocks, expressions, compiler, runtime, platforms (quantum model and backends) and data types handling modules. + +## Installation +Installation guidelines + +## Usage +Usage guidelines + +## Documentation +Documentation guidelines + +## Contribute +Contribution guidelines diff --git a/docs/css/mkdocstrings.css b/docs/css/mkdocstrings.css new file mode 100644 index 0000000..f8502f7 --- /dev/null +++ b/docs/css/mkdocstrings.css @@ -0,0 +1,11 @@ +/* Indentation. */ +div.doc-contents:not(.first) { + padding-left: 25px; + border-left: 4px solid rgba(230, 230, 230); + margin-bottom: 80px; + } + +/* Avoid breaking parameters name, etc. in table cells. */ +td code { + word-break: normal !important; +} diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..2987e32 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,12 @@ +# "qadence2 core" +## Installation +Installation guidelines + +## Usage +Usage guidelines + +## Documentation +Documentation guidelines + +## Contribute +Contribution guidelines diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js new file mode 100644 index 0000000..fd764a7 --- /dev/null +++ b/docs/javascripts/mathjax.js @@ -0,0 +1,16 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], + displayMath: [["\\[", "\\]"]], + processEscapes: true, + processEnvironments: true + }, + options: { + ignoreHtmlClass: ".*|", + processHtmlClass: "arithmatex" + } +}; + +document$.subscribe(() => { + MathJax.typesetPromise() +}) diff --git a/docs/sample_page.md b/docs/sample_page.md new file mode 100644 index 0000000..cb5fa97 --- /dev/null +++ b/docs/sample_page.md @@ -0,0 +1,8 @@ +This is just a sample notebook to showcase the rendering of Jupyter notebooks in the documentation. + +```python exec="on" source="material-block" session="main" +from qadence2-core.main import main + +msg = main() +print(msg) +``` diff --git a/examples/demo.ipynb b/examples/demo.ipynb deleted file mode 100644 index 83b5cf4..0000000 --- a/examples/demo.ipynb +++ /dev/null @@ -1,602 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What is new in Qadence 2?\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Syntax\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Improve notation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
\n", - "
\n", - "\n", - "
From Qadence tutorial
\n", - "
\n", - "
\n", - "\n", - "Mathematically\n", - "$$\n", - "X_0 \\otimes Y_1 \\otimes RX_2(x) \\otimes RX_3(0.5) \\otimes CX_{2,3} \\otimes e^{-it\\sum_{i=0}^3 Z_i}\n", - "$$\n", - "\n", - "or\n", - "\n", - "$$\n", - "X_0 Y_1 \\, RX_2(x) \\, RX_3(0.5) \\, CX_{2,3} \\, e^{-it\\sum_{i=0}^3 Z_i}\n", - "$$\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "X[0] Y[1] RX(x)[2] RX(0.5)[3] X[3| 2] E ^ ((-0-1j) t Z[0] + (-0-1j) t Z[1] + (-0-1j) t Z[2] + (-0-1j) t Z[3])[0, 1, 2, 3]" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from qadence2.expressions import *\n", - "\n", - "x = parameter(\"x\")\n", - "t = parameter(\"t\")\n", - "\n", - "X(0) * Y(1) * RX(x)(2) * RX(0.5)(3) * X(target=(3,), control=(2,)) * exp(-1j * t * sum(Z(i) for i in range(4)))" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "X[0] Y[1] RX(x)[2] RX(0.5)[3] X[3| 2] E ^ ((-0-1j) t Z[0] + (-0-1j) t Z[1] + (-0-1j) t Z[2] + (-0-1j) t Z[3])[0, 1, 2, 3]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "RX(x)(2) * RX(0.5)(3) * X(target=(3,), control=(2,)) * X(0) * Y(1) * exp(-1j * t * sum(Z(i) for i in range(4)))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Different types of symbols for different purposes\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Qadence 2 is designed for QML and supports specialised types for different optimisation strategies. For instance, `parameter` types are treated as constants and only `variable` types are considered during gradient calculations." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "a = parameter(\"a\")\n", - "b = parameter(\"b\")\n", - "phi = variable(\"phi\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Automatic basic simplifications\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Distributive property." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "a cos(0.5 phi) X[1] - a sin(0.5 phi) Y[1] - b Z[1]" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "a * (cos(phi / 2) * X(1) - sin(phi / 2) * Y(1)) - b * Z(1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Unitary Hermitian operatins automatic cancelation." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Y[1] Z[2] X[3] + X[3]" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "X(3) * (Y(1) + Z(2)) * Z(2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Subspace\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Local operations can be spanned over multiple qubits; `X(1, 2)` is mathematically equivalent to $X_1 \\otimes X_2$.\n", - "\n", - "Any operation can be used as a controlled operation by providing `target` and `control` indices." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "X[1| 0, 2]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "X(target=(1,), control=(0,2))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Declaring new operators\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Direct declaration." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "MyGate[0] MyGate[1, 2]" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "MyGate = unitary_hermitian_operator('MyGate')\n", - "\n", - "MyGate(2, 1) * MyGate(0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As a regular Python function." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "0.5 - 0.5 Z[2] - 0.25 Z[1] + 0.25 Z[1] Z[2] - 0.25 Z[3] + 0.25 Z[2] Z[3]" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "n = lambda l: (1 - Z(l)) / 2\n", - "\n", - "n(1) * n(2) + n(2) * n(3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hardware elements without implementation details\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "In this example, the `FreeEvolution(2.5)(1, 2)` indicates an interaction between qubits 1 and 2 over 2.5 unit times. The backend decides how the unit time is defined and how the dynamic decoupling is performed." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "NativeDrive(0.5 t, omega, detuning, phase)[*] FreeEvolution(2.5)[1, 2] NativeDrive(0.5 t, omega, -detuning, phase)[*]" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "t = time_variable(\"t\")\n", - "omega = array_variable(\"omega\", 4)\n", - "detuning = array_variable(\"detuning\", 3)\n", - "phase = parameter(\"phase\")\n", - "\n", - "expr = (\n", - " NativeDrive(t / 2, omega, detuning, phase)()\n", - " * FreeEvolution(2.5)(1, 2)\n", - " * NativeDrive(t / 2, omega, -detuning, phase)()\n", - ")\n", - "\n", - "expr" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Symbolic analysis 🚧" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "RX(0.5 x)[*] CZ[0, 1] RX(0.5 theta)[0]" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "x = parameter(\"x\")\n", - "theta = variable(\"theta\")\n", - "expr = RX(x/2)() * CZ(0, 1) * RX(theta/2)(0)\n", - "expr" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "RX(0.5 x)[*] FreeEvolution(2.7)[*] RX(0.5 theta)[0]" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "replace(expr, {CZ(0, 1): FreeEvolution(2.7)()})" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Intermidiate representation" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "RX(0.5 a phi)[2] CZ[*] RY(0.5 b phi)[0]\n" - ] - }, - { - "data": { - "text/plain": [ - "Model(\n", - " register=AllocQubits(\n", - " num_qubits=3,\n", - " qubit_positions=[(0, 0), (0, 1), (1, 0)],\n", - " grid_type=triangular,\n", - " grid_scale=1.0,\n", - " options={},\n", - " ),\n", - " inputs={\n", - " 'a': Alloc(1, trainable=False),\n", - " 'phi': Alloc(1, trainable=True),\n", - " 'b': Alloc(1, trainable=False),\n", - " },\n", - " instructions=[\n", - " Assign('%0', Call('mul', 0.5, Load('a'))),\n", - " Assign('%1', Call('mul', Load('%0'), Load('phi'))),\n", - " QuInstruct('rx', Support(target=(2,)), Load('%1')),\n", - " QuInstruct('cz', Support.target_all()),\n", - " Assign('%2', Call('mul', 0.5, Load('b'))),\n", - " Assign('%3', Call('mul', Load('%2'), Load('phi'))),\n", - " QuInstruct('ry', Support(target=(0,)), Load('%3')),\n", - " ],\n", - " directives={\n", - " 'enable_digital_analog': True,\n", - " },\n", - " settings={},\n", - ")" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "expr = RX(a * phi / 2)(2) * CZ() * RY(b * phi / 2)(0)\n", - "print(expr)\n", - "\n", - "irc(expr)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Model(\n", - " register=AllocQubits(\n", - " num_qubits=4,\n", - " qubit_positions=[(-1, 0), (-1, 1), (1, 0), (1, 1)],\n", - " grid_type=triangular,\n", - " grid_scale=1.0,\n", - " options={},\n", - " ),\n", - " inputs={\n", - " 't': Alloc(1, trainable=True, attrs={'time_parameter': True}),\n", - " 'omega': Alloc(4, trainable=True),\n", - " 'detuning': Alloc(3, trainable=True),\n", - " 'phase': Alloc(1, trainable=False),\n", - " },\n", - " instructions=[\n", - " Assign('%0', Call('mul', 0.5, Load('t'))),\n", - " QuInstruct('dyn_pulse', Support.target_all(), Load('%0'), Load('omega'), Load('detuning'), Load('phase')),\n", - " QuInstruct('dyn_wait', Support(target=(1, 2)), 2.5),\n", - " Assign('%1', Call('mul', -1.0, Load('detuning'))),\n", - " QuInstruct('dyn_pulse', Support.target_all(), Load('%0'), Load('omega'), Load('%1'), Load('phase')),\n", - " ],\n", - " directives={},\n", - " settings={},\n", - ")" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "reset_ir_options()\n", - "set_qubits_positions([(-1,0), (-1, 1), (1, 0), (1, 1)])\n", - "set_grid_type(\"triangular\")\n", - "\n", - "t = time_variable(\"t\")\n", - "omega = array_variable(\"omega\", 4)\n", - "detuning = array_variable(\"detuning\", 3)\n", - "phase = parameter(\"phase\")\n", - "\n", - "expr = (\n", - " NativeDrive(t / 2, omega, detuning, phase)()\n", - " * FreeEvolution(2.5)(1, 2)\n", - " * NativeDrive(t / 2, omega, -detuning, phase)()\n", - ")\n", - "\n", - "irc(expr)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Pulser example" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "RX(0.5 x)[*]\n", - "-----\n", - "Model(\n", - " register=AllocQubits(\n", - " num_qubits=3,\n", - " qubit_positions=[(0, 0), (0, 1), (1, 0)],\n", - " grid_type=triangular,\n", - " grid_scale=1.0,\n", - " options={},\n", - " ),\n", - " inputs={\n", - " 'x': Alloc(1, trainable=False),\n", - " },\n", - " instructions=[\n", - " Assign('%0', Call('mul', 0.5, Load('x'))),\n", - " QuInstruct('rx', Support.target_all(), Load('%0')),\n", - " ],\n", - " directives={\n", - " 'enable_digital_analog': True,\n", - " },\n", - " settings={},\n", - ")\n" - ] - }, - { - "data": { - "text/plain": [ - "Counter({'100': 138,\n", - " '110': 134,\n", - " '010': 132,\n", - " '101': 130,\n", - " '000': 124,\n", - " '011': 120,\n", - " '111': 114,\n", - " '001': 108})" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from qadence2.platforms.compiler import compile\n", - "from qadence2.platforms.types import DeviceName\n", - "\n", - "reset_ir_options()\n", - "set_qubits_positions([(0,0), (0, 1), (1, 0)])\n", - "set_grid_type(\"triangular\")\n", - "add_qpu_directives({\"enable_digital_analog\": True})\n", - "\n", - "x = parameter(\"x\")\n", - "expr = RX(x/2)()\n", - "\n", - "model = irc(expr)\n", - "api = compile(model, \"pulser\", DeviceName.FRESNEL_EOM)\n", - "result = api.run(num_shots=1000, values={\"x\": 3.14})\n", - "\n", - "print(expr, model, sep=\"\\n-----\\n\")\n", - "result" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.14" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/examples/fig1.png b/examples/fig1.png deleted file mode 100644 index 4cca0e9..0000000 Binary files a/examples/fig1.png and /dev/null differ diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..1c23b6f --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,79 @@ +site_name: qadence2 core +repo_url: "https://gitlab.pasqal.com/pqs/qadence2-core" +repo_name: "qadence2_core" + +nav: + - Overview: index.md + - Sample page: sample_page.md + +theme: + name: material + features: + - content.code.annotate + - content.action.view + - content.action.edit + - navigation.tabs + - navigation.indexes + - navigation.sections + - content.code.copy + + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + primary: light green + accent: purple + toggle: + icon: material/weather-sunny + name: Switch to dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: black + accent: light green + toggle: + icon: material/weather-night + name: Switch to light mode + +markdown_extensions: +- admonition # for notes +- pymdownx.arithmatex: # for mathjax + generic: true +- pymdownx.highlight: + anchor_linenums: true +- pymdownx.inlinehilite +- pymdownx.snippets +- pymdownx.superfences + +plugins: +- search +- section-index +- markdown-exec +- mkdocstrings: + default_handler: python + handlers: + python: + selection: + filters: + - "!^_" # exlude all members starting with _ + - "^__init__$" # but always include __init__ modules and methods + options: + show_root_toc_entry: false + heading_level: 3 + merge_init_into_class: true + docstring_section_style: spacy + +watch: + - qadence2-core + +extra: + version: + provider: mike + +# To get nice tabs +extra_css: +- css/mkdocstrings.css + +# For mathjax +extra_javascript: + - javascripts/mathjax.js + - https://polyfill.io/v3/polyfill.min.js?features=es6 + - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js diff --git a/pyproject.toml b/pyproject.toml index 2e95b18..66cc015 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,11 @@ build-backend = "hatchling.build" [project] name = "qadence2" -description = "Qadence 2 - WIP." +description = "Qadence 2" readme = "README.md" version = "0.1.0" requires-python = ">=3.10,<3.12" -license = {text = "Proprietary"} +license = { text = "Apache 2.0" } keywords = ["quantum"] authors = [ { name = "Eduardo Maschio", email = "eduardo.maschio@pasqal.com" }, @@ -40,8 +40,8 @@ extras = [ ] [project.urls] # Documentation = "https://pqs.pages.pasqal.com/qadence2-core/" -Issues = "https://github.com/pasqal-io/wip-qadence2-core/issues" -Source = "https://github.com/pasqal-io/wip-qadence2-core" +Issues = "https://github.com/pasqal-io/qadence2-core/issues" +Source = "https://github.com/pasqal-io/qadence2-core" [tool.hatch.envs.default] features = ["extras"] @@ -53,9 +53,14 @@ dependencies = [ "ipykernel", "pre-commit", "black", - "ruff" + "isort", + "ruff", + "pydocstringformatter", ] +[tool.hatch.envs.default.scripts] +test = "pytest -n auto --cov-config=pyproject.toml --ignore=./tests/test_examples.py {args}" + [tool.pytest.ini_options] testpaths = ["tests"] addopts = """-vvv --cov-report=term-missing --cov-config=pyproject.toml --cov=template_python --cov=tests""" @@ -88,7 +93,16 @@ serve = "mkdocs serve --dev-addr localhost:8000" test = "mkdocs build --clean --strict" [[tool.hatch.envs.test.matrix]] -python = ["39", "310", "311"] +python = ["310", "311"] + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.gitignore", + "/.pre-commit-config.yml", + "/tests", + "/docs", + "/examples", +] [tool.hatch.build.targets.wheel] packages = ["qadence2"] @@ -127,6 +141,23 @@ max-complexity = 15 [tool.ruff.flake8-quotes] docstring-quotes = "double" +[tool.black] +line-length = 100 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' + [tool.mypy] python_version = "3.10" warn_return_any = true diff --git a/qadence2-expressions b/qadence2-expressions deleted file mode 160000 index 99a30dd..0000000 --- a/qadence2-expressions +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 99a30ddb38cdecb49e22f7d962672facd889d039 diff --git a/qadence2-ir b/qadence2-ir deleted file mode 160000 index 56081b7..0000000 --- a/qadence2-ir +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 56081b74520a77174bcbeebcc8791c878a5cdf7d diff --git a/qadence2-platforms b/qadence2-platforms deleted file mode 160000 index d92edeb..0000000 --- a/qadence2-platforms +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d92edeb1a7117972f20b8cc34f3dddaee006cd65 diff --git a/qadence2/expressions b/qadence2/expressions deleted file mode 120000 index 227f2dd..0000000 --- a/qadence2/expressions +++ /dev/null @@ -1 +0,0 @@ -../qadence2-expressions/qadence2_expressions \ No newline at end of file diff --git a/qadence2/main.py b/qadence2/main.py new file mode 100644 index 0000000..0b02405 --- /dev/null +++ b/qadence2/main.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from typing import Optional + + +def main(str_to_add: Optional[str] = None) -> str: + msg = "Welcome to qadence2!" + if str_to_add is not None: + msg += str_to_add + return msg + + +if __name__ == "__main__": + msg = main(str_to_add="\n(Executed from main.py)") + print(msg) diff --git a/qadence2/platforms b/qadence2/platforms deleted file mode 120000 index 1cd1526..0000000 --- a/qadence2/platforms +++ /dev/null @@ -1 +0,0 @@ -../qadence2-platforms/qadence2_platforms \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..a03590f --- /dev/null +++ b/setup.py @@ -0,0 +1,5 @@ +from __future__ import annotations + +from setuptools import setup + +setup() diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..3014d28 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,2 @@ +# use this file for configuring test fixtures and +# functions common to every test diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..784821a --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +from qadence2.main import main + +expected_msg = "Welcome to qadence2!" + + +def test_main() -> None: + msg = main() + assert msg == expected_msg + + +def test_main_with_str() -> None: + str_to_add = "\nExecuted from test file" + msg = main(str_to_add=str_to_add) + assert msg == expected_msg + str_to_add