Skip to content

Add generic annotations to Keysight drivers - #8695

Open
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 8 commits into
microsoft:mainfrom
jenshnielsen:keysight_annotations
Open

Jens Hedegaard Nielsen (jenshnielsen) wants to merge 8 commits into
microsoft:mainfrom
jenshnielsen:keysight_annotations

Conversation

@jenshnielsen

@jenshnielsen Jens Hedegaard Nielsen (jenshnielsen) commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Annotated

  • Keysight B1500: the enum parameters of KeysightB1517A and KeysightB1520A (e.g. sweep_mode, measurement_mode, impedance_model) with their enum types, and KeysightB1517A.time_axis as a numpy array. KeysightB1517A.setup_staircase_sweep now types post_sweep_voltage_val as constants.WM.Post rather than the B1520A constants.WMDCV.Post (same values, so existing calls still work).
  • Keysight B220x switch matrix parameters.
  • phase of AgilentE8257D / AgilentE8267C (float, degrees).
  • Keysight 344xxA and 33XXX parameters that also accept SCPI keywords ("MIN", "MAX", "DEF", "INF") as float | str / int | str, with docstrings explaining that get returns a number but the cache holds the keyword until the next get.

Breaking

  • KeysightE4980ACorrection.open / .short are now methods instead of command-only parameters. Previously meter.correction.open(), as used in the example notebook, only returned the cached value and never ran the correction.

Bug fixes

  • Setting resolution on the Keysight 344xxA to "MIN", "MAX" or "DEF" raised ValueError instead of sending the keyword.
  • The E4980A OPEN/SHORT correction was never executed (see above).

Not included: B1517A measurement_operation_mode / current_measurement_range and E4980A measurement_function, where get returns a different type than set accepts. These will need to be fixed in a follow-up PR so that get returns the type that set takes.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.31373% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.83%. Comparing base (7008064) to head (19cfd82).

Files with missing lines Patch % Lines
...t_drivers/Keysight/keysightb1500/KeysightB1517A.py 60.00% 4 Missing ⚠️
...t_drivers/Keysight/keysightb1500/KeysightB1520A.py 60.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8695      +/-   ##
==========================================
+ Coverage   77.80%   77.83%   +0.03%     
==========================================
  Files         308      308              
  Lines       32888    32888              
==========================================
+ Hits        25587    25597      +10     
+ Misses       7301     7291      -10     

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new correction commands are defined as properties without required defaults, causing pyvisa-sim to fail loading and blocking all E4980A driver tests.

1 open issue
What changed in this PR

This PR improves parameter typing across QCoDeS Keysight drivers and makes E4980A correction calls execute instrument commands.

Changes:

  • Add generic parameter annotations and explicit enum conversions to B1500 and B220x drivers.
  • Replace E4980A OPEN and SHORT correction parameters with methods, with simulator support and regression tests.
  • Document typing improvements and the correction API breaking change.
File Description
tests/​drivers/​test_keysight_e4980a.py Test correction command dispatch and subsequent queries.
tests/​drivers/​keysight_b1500/​b1500_driver_tests/​test_b1517a_smu.py Align enum usage and annotate intentional integer input.
src/​qcodes/​instrument/​sims/​Keysight_E4980A.yaml Add simulated correction commands.
src/​qcodes/​instrument_drivers/​Keysight/​keysightb1500/​KeysightB1520A.py Type enum parameters and convert setup arguments.
src/​qcodes/​instrument_drivers/​Keysight/​keysightb1500/​KeysightB1517A.py Type parameters and correct the post-sweep enum.
src/​qcodes/​instrument_drivers/​Keysight/​keysight_e4980a.py Replace correction parameters with command methods.
src/​qcodes/​instrument_drivers/​Keysight/​keysight_b220x.py Type integer and list parameters.
docs/​changes/​newsfragments/​8695.improved_driver Describe driver typing improvements.
docs/​changes/​newsfragments/​8695.breaking Explain correction API migration.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the driver typing and command-handling changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

The staircase sweep setup methods now convert their enum or int
arguments before setting the parameters, and the B1517A one takes the
WM post sweep condition rather than the B1520A WMDCV one.
open and short were command-only parameters, so calling them without
an argument, as the example does, returned the cached value and did
not execute the correction.
Since NumericScpiMnemonic became a PEP 695 type alias, get_args returns
an empty tuple for it, so "MIN", "MAX" and "DEF" were formatted as
numbers and raised a ValueError.
Getting these parameters returns a number, but they can also be set to
keywords such as MIN or MAX, which stay in the cache until the next
get, so they are annotated as float | str and their docstrings say so.
OPEN and SHORT correction take no argument and give no reply, so they
are plain dialogues like *RST and *CLS rather than properties without
a getter.

This branch has not been deployed

No deployments
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.

2 participants