Skip to content

[wip] Improve Ami430 annotations - #8679

Draft
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 11 commits into
microsoft:mainfrom
jenshnielsen:ami430_annotations
Draft

Jens Hedegaard Nielsen (jenshnielsen) wants to merge 11 commits into
microsoft:mainfrom
jenshnielsen:ami430_annotations

Conversation

@jenshnielsen

Copy link
Copy Markdown
Collaborator

No description provided.

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.04%. Comparing base (b7ac5bc) to head (d69d1d5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8679      +/-   ##
==========================================
+ Coverage   75.02%   75.04%   +0.01%     
==========================================
  Files         307      307              
  Lines       32506    32540      +34     
==========================================
+ Hits        24389    24421      +32     
- Misses       8117     8119       +2     

☔ 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

Unit changes mislabel stored setpoints, and callbacks to closed 3D drivers can interrupt live magnets’ unit updates.

2 open issues
What changed in this PR

This PR improves type annotations and field-unit metadata for QCoDeS’s AMI430 3D magnet driver.

Changes:

  • Separates scalar and vector accessors and adds precise parameter annotations.
  • Synchronizes field-unit labels with the magnets and warns about mixed units.
  • Adds regression tests, coordinate documentation, and a release note.
File Description
tests/​drivers/​test_ami430_visa.py Tests return types, scalar setters, and field-unit metadata.
src/​qcodes/​instrument_drivers/​american_magnetics/​AMI430_visa.py Refines annotations, accessors, unit synchronization, and coordinate documentation.
docs/​changes/​newsfragments/​8679.improved_driver Documents unit-label improvements and mixed-unit warnings.

Review effort: Balanced

Comment on lines +983 to +984
for parameter in field_parameters:
parameter.unit = unit
Comment on lines +587 to +588
if self._parent_instrument is not None:
self._parent_instrument._update_field_units()
The getters returned a float for one component and a list for three,
so none of the field parameters could be annotated. Single components
are now typed float and the read-only vectors list[float].
spherical and cylindrical had unit "tuple?". Their components have
mixed units, which are now described in the docstrings.
Create ramp_mode, ramping_state_check_interval and vector_ramp_rate
with add_parameter like the other parameters, so they can be typed.
vector_ramp_rate is float | None since it is unset until set.
The 3D field parameters are read from and set on the individual
magnets in their field units, which can be tesla or kilogauss, but
were always labelled T. Follow the magnets' units, and warn if they
differ.
The magnets kept a reference to the closed 3D driver, so set_field,
zero and changing units on a magnet that was still open failed.
The 3D driver's set point and field limit are in the field units of
the magnets, so changing them between tesla and kilogauss silently
changed their meaning by a factor of 10. Raise instead, and take the
units of the 3D field parameters from the magnets only at creation.
cartesian, spherical and cylindrical return a list but can be set from
any sequence or a numpy array, so type them as
Sequence[float] | npt.NDArray.
The coordinate vectors always have three components, so return a
tuple and type the read-only ones as tuple[float, float, float]. The
settable ones keep the Sequence[float] | NDArray type since Parameter
has a single type for get and set.
Add CartesianVector, SphericalVector and CylindricalVector named
tuples to qcodes.math_utils and return them from the AMI430 3D
coordinate vector parameters, so the components can be accessed by
name. They are tuples, so the previous tuple return still works.

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