Repository navigation
Example notebook type fixes - #8834
Open
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 12 commits into
Open
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 12 commits into
Jens Hedegaard Nielsen (jenshnielsen) wants to merge 12 commits into
Conversation
The test cells imported the Weinschel8320 driver from qcodes, replacing the class of the same name that the notebook defines, which ty reports as an invalid assignment. Remove those imports so the tests use the driver from the notebook, and annotate the fixtures and tests. test_init_v2 requested a driver fixture that does not exist, so request weinschel_driver_2 instead. Also clear the stale output of the first cell.
set_netcdf_location exists on DataSetInMem but not on the protocol that load_by_run_spec returns, so the exporting notebook narrows the dataset before calling it. The walkthrough notebook loses the two cells reading DataSet.started and DataSet.parameters, which are likewise not part of the protocol.
The parameters in these examples read the point count off the instrument they belong to, which only the concrete instrument class declares. Override root_instrument to return that class, so that the examples state what they already assume.
Overriding set_raw with a differently named argument is an invalid override, since callers are free to pass value as a keyword.
qc.config.current_config is optional, so the notebook has to establish that a configuration is loaded before reading values out of it.
dond returns a single dataset rather than a tuple of them unless squeeze=False is passed, so notebooks that unpack the result could not be type checked. Pass squeeze=False and index into the result instead.
dond returns a single dataset rather than a tuple of them unless squeeze=False is passed, so unpacking the result in the AMI430 example does not type check. Pass squeeze=False and take the first dataset.
by_kind and by_channel are keyed by ModuleKind and ChNr. Those are a StrEnum and an IntEnum, so a plain string or int is the same key at runtime, but the dicts are typed as taking the enums. Use constants.ModuleKind.SMU for the by_kind lookup, which is what the markdown just above it points at. The by_channel cell deliberately shows both the enum and the plain int and asserts they select the same module, so keep that and note that only the enum matches the type of the dict.
instrument.parameters is a dict of ParameterBase, which does not carry a label. Parameter and ArrayParameter do, but MultiParameter has labels instead, so the listing would raise for an instrument holding one. Read it with getattr and a default, and say why in the notebook.
The sample count and timer of the Keysight 344xxA are annotated as float | str, since they can also be set to the MIN, MAX and DEF keywords. Their values are always parsed as numbers when read, so convert them to int and float before computing the time of each sample, which makes the arithmetic type check.
The file is named with a placeholder, to be renamed to the number of the pull request once it is opened.
Jens Hedegaard Nielsen (jenshnielsen)
requested a review
from a team
as a code owner
December 4, 2026 08:19
| "# Top-level parameters\n", | ||
| "for name in sorted(awg1.parameters):\n", | ||
| " print(name, \": \", awg1.parameters[name].label)\n", | ||
| " print(name, \": \", getattr(awg1.parameters[name], \"label\", \"\"))\n", |
Collaborator
Author
There was a problem hiding this comment.
narrow to parameter instrad of using getattr hack
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8834 +/- ##
=======================================
Coverage 78.55% 78.55%
=======================================
Files 311 311
Lines 33162 33162
=======================================
Hits 26049 26049
Misses 7113 7113 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fix type checking issues in notebooks discovered by checking with TY