Skip to content
Open
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
37 changes: 37 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python Lint and Format

# Run on every push to any branch.
on:
push:
workflow_dispatch: # lets you trigger it manually from the Actions tab

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v6
# 1. Install uv (much faster than actions/setup-python)
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true # Automatically caches your dependencies

# 2. Install using uv
- name: Install qkernel and testing dependencies
run: |
uv sync --dev

# 3. Lint & Format
- name: Lint and Format with Ruff
run: |
uv run ruff check . --output-format github
uv run ruff format --check .
47 changes: 11 additions & 36 deletions docs/tutorials/pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@
"metadata": {},
"outputs": [],
"source": [
"df_train = pd.read_csv(\n",
" \"./train_toy.csv\"\n",
").rename(columns=str.lower)\n",
"df_test = pd.read_csv(\n",
" \"./test_toy.csv\"\n",
").rename(columns=str.lower)"
"df_train = pd.read_csv(\"./train_toy.csv\").rename(columns=str.lower)\n",
"df_test = pd.read_csv(\"./test_toy.csv\").rename(columns=str.lower)"
]
},
{
Expand Down Expand Up @@ -88,8 +84,7 @@
"x_test_chain = ChainEmbedding(x_test).embed()\n",
"\n",
"x_train_radial = RadialEmbedding(x_train).embed()\n",
"x_test_radial = RadialEmbedding(x_test).embed()\n",
"\n"
"x_test_radial = RadialEmbedding(x_test).embed()"
]
},
{
Expand Down Expand Up @@ -232,42 +227,22 @@
"source": [
"import numpy as np\n",
"\n",
"pipeline_args = {\"hamiltonian\": {\n",
"pipeline_args = {\n",
" \"hamiltonian\": {\n",
" \"backend\": \"qutip\",\n",
" \"kwargs\": {\n",
" \"omega\": 2 * np.pi,\n",
" \"delta\": 0.3,\n",
" \"c6\": 865723.02\n",
" }\n",
" },\n",
" \"simulator\": {\n",
" \"backend\": \"qutip\",\n",
" \"kwargs\": {\n",
" \"duration\": 0.68\n",
" }\n",
" \"kwargs\": {\"omega\": 2 * np.pi, \"delta\": 0.3, \"c6\": 865723.02},\n",
" },\n",
" \"simulator\": {\"backend\": \"qutip\", \"kwargs\": {\"duration\": 0.68}},\n",
" \"kernel\": {\n",
" \"kwargs\": {\n",
" \"excitations\": False,\n",
" \"distance_fn\": \"exp\",\n",
" \"distance_kwargs\": {\n",
" \"mu\": 0.75\n",
" },\n",
" \"distance_kwargs\": {\"mu\": 0.75},\n",
" }\n",
" },\n",
" \"model\": {\n",
" \"type\": \"svc\",\n",
" \"kwargs\": {\n",
" \"C\": 0.9,\n",
" \"tol\": 0.02\n",
" }\n",
" },\n",
" \"results\": {\n",
" \"path\" : \"./\",\n",
" \"name\" : \"experiment_trial\"\n",
" }\n",
"}\n",
"\n"
" \"model\": {\"type\": \"svc\", \"kwargs\": {\"C\": 0.9, \"tol\": 0.02}},\n",
" \"results\": {\"path\": \"./\", \"name\": \"experiment_trial\"},\n",
"}"
]
},
{
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ dependencies = [
"myqlm",
"numpy",
"pandas",
"qkernel4eo",
"qutip",
"scipy",
"scikit-learn"
"scikit-learn",
]


Expand All @@ -34,9 +33,6 @@ line-length = 88
[tool.ruff.lint]
select = ["E", "F", "W", "I"] # pycodestyle, pyflakes, isort rules

[tool.uv.sources]
qkernel4eo = { git = "ssh://git@github.com/ICHEC/qkernel4eo.git" }

[dependency-groups]
dev = [
"ruff",
Expand Down
1 change: 0 additions & 1 deletion qkernel/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def _qutip_op(
ops[j] = op_j
return qutip.tensor(ops)


def generate_single_hamiltonian(self, qbits: np.ndarray) -> qutip.Qobj:
"""
Construct full QuTiP Hamiltonian for a single configuration.
Expand Down
2 changes: 1 addition & 1 deletion qkernel/kernel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Callable, Dict, Optional
from typing import Dict, Optional

import numpy as np
from scipy.spatial import distance
Expand Down
2 changes: 1 addition & 1 deletion qkernel/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
x_test: np.ndarray,
y_train: np.ndarray,
y_test: np.ndarray,
args: dict
args: dict,
):
"""
Initialize pipeline with configuration arguments and qbit data.
Expand Down
3 changes: 1 addition & 2 deletions qkernel/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

from .hamiltonian import Hamiltonian


try:
import qlmaas.qpus

AQPU_remote = qlmaas.qpus.AnalogQPU()
qlmaas_available = True
except:
except (ModuleNotFoundError, ImportError):
AQPU_remote = None
qlmaas_available = False

Expand Down
Loading
Loading