Repository navigation
[wip] Improve Ami430 annotations - #8679
Draft
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 11 commits into
Draft
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 11 commits into
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 11 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Jens Hedegaard Nielsen (jenshnielsen)
force-pushed
the
ami430_annotations
branch
from
October 27, 2026 08:55
9b78259 to
6faae0d
Compare
Jens Hedegaard Nielsen (jenshnielsen)
requested a balanced review from Copilot
October 27, 2026 09:23
Contributor
There was a problem hiding this comment.
🟡 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.
Jens Hedegaard Nielsen (jenshnielsen)
force-pushed
the
ami430_annotations
branch
from
October 28, 2026 05:50
6a7311f to
d69d1d5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.