Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
59d0b50
Moved everything to pyproject.toml including docs
marcosfrenkel Feb 11, 2026
4ebf920
Added src to project structure
marcosfrenkel Feb 11, 2026
f3dda61
Removed all deprecated and unused modules, scripts, and drivers.
marcosfrenkel Feb 18, 2026
95fba24
Added authors to pyproject.toml, removed py.typed, and introduced cod…
marcosfrenkel Feb 25, 2026
6953ed7
Added extensive unit tests for `record` and `sweep` modules and updat…
marcosfrenkel Feb 26, 2026
4183181
Added unit tests for `DataDict` and related utilities in `pytest/test…
marcosfrenkel Mar 2, 2026
dae8ccd
Added comprehensive unit tests for `datadict_storage` module in `pyte…
marcosfrenkel Mar 2, 2026
2b9d821
Added analysis_base tests
marcosfrenkel Mar 11, 2026
89c50fc
first pass of the formatter
marcosfrenkel Mar 11, 2026
223c636
Fixed failing tests
marcosfrenkel Mar 11, 2026
e175b76
First automatic linter fix errors
marcosfrenkel Mar 11, 2026
ef3b822
Second automatic linter fix errors
marcosfrenkel Mar 11, 2026
36ac967
ruff fix errors
marcosfrenkel Mar 11, 2026
7dd351a
import fixes
marcosfrenkel Mar 11, 2026
b8094dc
mypy changes
marcosfrenkel Mar 11, 2026
76f91ba
Brought Protocols with dummies and tests
marcosfrenkel Mar 13, 2026
688a5a6
ruff first pass
marcosfrenkel Mar 13, 2026
b06bc95
more ruff changes
marcosfrenkel Mar 13, 2026
a98dc87
mypy fixes and dependencies fix
marcosfrenkel Mar 16, 2026
2d4f11e
Added code_quality workflow
marcosfrenkel Mar 16, 2026
16ce3e8
bringing datagen to this branch
marcosfrenkel Mar 17, 2026
8f3f98c
Adding content to README.md
marcosfrenkel Mar 18, 2026
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
78 changes: 78 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Code quality

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv lock --locked

lint:
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --locked --group dev
- run: uv run ruff check

format:
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --locked --group dev
- run: uv run ruff format --check

typecheck:
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --locked --group dev
- run: uv run mypy

test:
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --locked --group dev
- run: uv run pytest test/ -v

build:
runs-on: ubuntu-latest
needs: [lint, format, typecheck, test]
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
- run: uv build
22 changes: 9 additions & 13 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@ jobs:
with:
persist-credentials: false

- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
auto-activate-base: true
activate-environment: labcore-docs
environment-file: environment-docs.yml

- name: Install labcore package
shell: bash -l {0}
run: pip install -e .

enable-cache: true
- name: Install system deps
run: sudo apt-get update && sudo apt-get install -y pandoc
- name: Install dependencies
run: uv sync --frozen --group docs
- name: Build HTML
shell: bash -l {0}
run: cd docs && make html
run: uv run --directory docs -- make html

- name: Upload artifacts
uses: actions/upload-artifact@v4
Expand All @@ -44,4 +40,4 @@ jobs:
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
publish_dir: docs/build/html
64 changes: 64 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## 1. Think Before Coding

**Don't assume. Don't hide confusion. Surface tradeoffs.**

Before implementing:

- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.

## 2. Simplicity First

**Minimum code that solves the problem. Nothing speculative.**

- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

## 3. Surgical Changes

**Touch only what you must. Clean up only your own mess.**

When editing existing code:

- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.

When your changes create orphans:

- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

## 4. Goal-Driven Execution

**Define success criteria. Loop until verified.**

Transform tasks into verifiable goals:

- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

---

**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Treat @AGENTS.md the same way you would CLAUDE.md
105 changes: 91 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,92 @@
# labcore
Code for measuring and such.

## installation
- clone from github
- make the right environment: use ``$ conda env create -n labcore --file environment.yml``
- install into your measurement environment:
``$ pip install -e <path_to_cloned_repository>``
- you should then be able to import:
``>>> import labcore``

## requirements
what other packages are needed will depend a lot on which tools from this package you'll be using.
In general, this will be used in a typical qcodes measurement environment.
The different submodules in this package should list in their documentation if additional packages are required.

A Python toolkit for acquiring, processing, and analyzing data in a condensed matter / quantum information physics lab.

labcore is designed to complement the [QCodes](https://qcodes.github.io/Qcodes/) ecosystem — it sits alongside QCodes instruments and parameters, adding a flexible sweep framework, structured HDF5 storage, and analysis tools.

**[Get started in 15 minutes →](https://toolsforexperiments.github.io/labcore/first_steps/15_min_guide.html)**

---

## What's inside

- **Sweep framework** — compose parameter sweeps with `+` (sequential), `*` (zip), and `@` (nested) operators; decorate functions with `@recording` to produce structured records automatically
- **Structured data storage** — `DataDict` and `DDH5Writer` for writing and reading HDF5 data files; `find_data`, `load_as_xr`, and `load_as_df` for data discovery and loading
- **Fitting** — lmfit-based fitting framework with built-in fit functions (cosine, exponential, linear, exponentially decaying sine, and more) and xarray integration
- **Analysis base** — a lightweight framework for organizing, saving, and loading analysis artifacts (figures, datasets, parameters)

---

## Installation

labcore is not yet on PyPI. Install directly from GitHub:

```bash
pip install git+https://github.com/toolsforexperiments/labcore.git
```

Or clone and install in editable mode:

```bash
git clone https://github.com/toolsforexperiments/labcore.git
pip install -e labcore/
```

Requires Python ≥ 3.11.

---

## Quick example

```python
from labcore.measurement import sweep_parameter, record_as, recording, dep, independent

# Define what to record
@recording(dep('signal', ['frequency']))
def measure(frequency):
return {'signal': my_instrument.read(frequency)}

# Run a sweep and save to HDF5
from labcore.measurement.storage import run_and_save_sweep
folder, _ = run_and_save_sweep(
sweep_parameter('frequency', range(100, 200)) @ measure,
data_dir='./data',
name='resonator_scan',
)

# Load the result as xarray
from labcore.data.datadict_storage import load_as_xr
ds = load_as_xr(folder)
```

See the [15-minute guide](https://toolsforexperiments.github.io/labcore/first_steps/15_min_guide.html) for a full walkthrough.

---

## Command-line tools

| Command | Description |
|---|---|
| `autoplot` | Live plotting server for monitoring running measurements |
| `reconstruct-data` | Reconstruct HDF5 files from safe-write temporary data |

---

## Development

```bash
git clone https://github.com/toolsforexperiments/labcore.git
cd labcore
uv sync --group dev
uv run pytest test/ -v
```

---

## License

MIT. See [LICENSE](LICENSE) for details.

## Authors

Wolfgang Pfaff and Marcos Frenkel.
13 changes: 0 additions & 13 deletions environment-docs.yml

This file was deleted.

30 changes: 0 additions & 30 deletions environment.yml

This file was deleted.

3 changes: 0 additions & 3 deletions labcore/analysis/__init__.py

This file was deleted.

Empty file.
Loading
Loading