Skip to content

[wip] Add structured parameter#8095

Open
jenshnielsen wants to merge 4 commits intomicrosoft:mainfrom
jenshnielsen:qcodes_struct_parameter
Open

[wip] Add structured parameter#8095
jenshnielsen wants to merge 4 commits intomicrosoft:mainfrom
jenshnielsen:qcodes_struct_parameter

Conversation

@jenshnielsen
Copy link
Copy Markdown
Collaborator

This is an idea to implement something like multi parameter but with a more modern and structured interface.
This pr currently is an early prototype for comments mostly.

  • This does not really handle set points at all.

jenshnielsen and others added 4 commits May 4, 2026 10:01
Introduce StructParameter, a new parameter type that returns structured data
as a Python dataclass or Pydantic v2 BaseModel. Each field of the struct is
automatically unpacked into a separate dataset column when used with
Measurement.

Key features:
- Subclass of ParameterBase (get-only, read-only)
- Introspects struct fields and creates synthetic child parameters
- Maps field types to QCoDeS paramtypes (numeric, text, complex, array)
- Dedicated registration path in Measurement.register_parameter()
- Pydantic support is optional (lazy import)
- snapshot_value defaults to False

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Demonstrates:
- Defining struct types with dataclasses
- Creating StructParameter subclasses with get_raw
- Using StructParameter with Measurement for dataset recording
- Customising field labels, units, and paramtypes
- Using get_cmd callable instead of subclassing
- Snapshot behaviour

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add get_cmd parameter to StructParameter so users can pass a callable
instead of subclassing. This mirrors the Pattern from Parameter.

Also adds the StructParameter example notebook covering struct type
definition, subclassing, get_cmd usage, Measurement integration,
mixed field types, and snapshot behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jenshnielsen jenshnielsen requested a review from a team as a code owner May 4, 2026 08:03
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 88.27586% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.72%. Comparing base (a0c0d0d) to head (14fa31c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/qcodes/parameters/struct_parameter.py 87.68% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8095      +/-   ##
==========================================
- Coverage   70.61%   69.72%   -0.89%     
==========================================
  Files         333      334       +1     
  Lines       32533    32678     +145     
==========================================
- Hits        22972    22786     -186     
- Misses       9561     9892     +331     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant