Skip to content

Conversation

@jenshnielsen
Copy link
Collaborator

@jenshnielsen jenshnielsen commented Dec 16, 2025

Make parameter generic in data and instrument type. This enables significantly better introspection of qcodes instruments and their data returned from parameters.

This takes the core infrastructure changes from #7655 and breaks it out into a pr with clean commits. The instrument improvements will land independently. Consult that pr for examples of improvements.

  • Changelog

@jenshnielsen jenshnielsen requested a review from a team as a code owner December 16, 2025 09:33
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 30.13699% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.78%. Comparing base (5e04d0b) to head (a28f919).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/qcodes/parameters/parameter_base.py 55.55% 16 Missing ⚠️
src/qcodes/parameters/delegate_parameter.py 8.33% 11 Missing ⚠️
src/qcodes/parameters/cache.py 10.00% 9 Missing ⚠️
src/qcodes/parameters/parameter.py 0.00% 5 Missing ⚠️
src/qcodes/parameters/parameter_with_setpoints.py 0.00% 4 Missing ⚠️
src/qcodes/parameters/array_parameter.py 0.00% 3 Missing ⚠️
src/qcodes/parameters/multi_parameter.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7730      +/-   ##
==========================================
- Coverage   59.80%   59.78%   -0.02%     
==========================================
  Files         352      352              
  Lines       31805    31815      +10     
==========================================
  Hits        19022    19022              
- Misses      12783    12793      +10     

☔ 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.

class Parameter(
ParameterBase[ParameterDataTypeVar, InstrumentType_co],
Generic[ParameterDataTypeVar, InstrumentType_co],
):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to agree on this order of generic arguments before merging since changing this would be a breaking change for all Parameter usage and implementations.

Roughly there are four relevant generic parameters for an instrument.

  1. ParameterData type (input/output from get/set)
  2. InstrumentType (what self.instrument returns)
  3. RootInstrumentType (what self.root_instrument) returns
  4. RawParameterData. What is passed to self.write/ask etc

Here I propose that we add 1 and 2 but omit 3 and 4 for the time being.
That is a tradeoff between the features and the amount of parameters
that needs to be passed to each generic Parameter since currently if
one generic parameter is supplied to a Generic function/class they must all be supplied.

This, however, also means that we cannot add these in a non-breaking way before we drop 3.12 support.
In 3.13 onwards it becomes possible to omit values for type parameters that have default values so we can simply append these and omit them when they don't add value

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