Skip to content

Commit 09b5ade

Browse files
committed
Fix type checking in parameter notebook
1 parent dba14c0 commit 09b5ade

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

docs/examples/Parameters/Parameter-With-Setpoints-defined-on-a-different-instrument.ipynb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
},
8282
{
8383
"cell_type": "code",
84-
"execution_count": 5,
84+
"execution_count": null,
8585
"metadata": {},
8686
"outputs": [],
8787
"source": [
@@ -108,6 +108,18 @@
108108
" npoints = self.root_instrument.sweep_n_points.get_latest()\n",
109109
" return np.random.default_rng().random(npoints)\n",
110110
"\n",
111+
" @property\n",
112+
" def root_instrument(self) -> \"DummyBufferedDMM\":\n",
113+
" # we override this to enforce that the root instrument is a DummyBufferedDMM\n",
114+
" # to ensure that we can get the value of the n_points parameter\n",
115+
" if self._instrument is None:\n",
116+
" raise ValueError(\"Instrument is not set for this parameter\")\n",
117+
" root_instrument = self._instrument.root_instrument\n",
118+
" if not isinstance(root_instrument, DummyBufferedDMM):\n",
119+
" raise TypeError(\"root_instrument must be an instance of DummyBufferedDMM\")\n",
120+
"\n",
121+
" return root_instrument\n",
122+
"\n",
111123
"\n",
112124
"class DummyBufferedDMM(Instrument):\n",
113125
" def __init__(self, name, **kwargs):\n",
@@ -655,7 +667,7 @@
655667
],
656668
"metadata": {
657669
"kernelspec": {
658-
"display_name": "Python 3",
670+
"display_name": "qcodes",
659671
"language": "python",
660672
"name": "python3"
661673
},
@@ -669,7 +681,7 @@
669681
"name": "python",
670682
"nbconvert_exporter": "python",
671683
"pygments_lexer": "ipython3",
672-
"version": "3.7.9"
684+
"version": "3.14.7"
673685
},
674686
"toc": {
675687
"base_numbering": 1,

docs/examples/Parameters/Simple-Example-of-ParameterWithSetpoints.ipynb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
},
8484
{
8585
"cell_type": "code",
86-
"execution_count": 5,
86+
"execution_count": null,
8787
"metadata": {},
8888
"outputs": [],
8989
"source": [
@@ -110,6 +110,20 @@
110110
" npoints = self.root_instrument.n_points.get_latest()\n",
111111
" return np.random.default_rng().random(npoints)\n",
112112
"\n",
113+
" @property\n",
114+
" def root_instrument(self) -> \"DummySpectrumAnalyzer\":\n",
115+
" # we override this to enforce that the root instrument is a DummySpectrumAnalyzer\n",
116+
" # to ensure that we can get the value of the n_points parameter\n",
117+
" if self._instrument is None:\n",
118+
" raise ValueError(\"Instrument is not set for this parameter\")\n",
119+
" root_instrument = self._instrument.root_instrument\n",
120+
" if not isinstance(root_instrument, DummySpectrumAnalyzer):\n",
121+
" raise TypeError(\n",
122+
" \"root_instrument must be an instance of DummySpectrumAnalyzer\"\n",
123+
" )\n",
124+
"\n",
125+
" return root_instrument\n",
126+
"\n",
113127
"\n",
114128
"class DummySpectrumAnalyzer(Instrument):\n",
115129
" def __init__(self, name, **kwargs):\n",

0 commit comments

Comments
 (0)