Optionally raise an exception if a Manual Parameter returns None /validate on get
- Dominant language
- Python
- Stars
- 459
- Forks
- 359
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 73
Description
We use a lot of ManualParameters in our meta instruments (I guess @nulinspiratie you do something similar). Sometimes we forget to set the value of such a parameter. When we then try to use it we get strange type errors resulting from using the `None` as a value somewhere else.
Below is an example of such an exception that can be hard to debug if you are not aware of this.
```
d:\githubrepos\pycqed_py3\pycqed\instrument_drivers\meta_instrument\qubit_objects\CCL_Transmon.py in _prep_td_sources(self)
646 # Set source to fs =f-f_mod such that pulses appear at f = fs+f_mod
647 self.instr_LO_mw.get_instr().frequency.set(
--> 648 self.freq_qubit.get() - self.mw_freq_mod.get())
649
650 self.instr_LO_mw.get_instr().power.set(self.mw_pow_td_source.get())
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
```
I would propose adding a validate on get (`Boolean`) attribute to the parameter class so that we get the full context power (and checks) of the validators.
Contributor guide
Research direction
Start with the parameter class and its get/validator path; the issue proposes an optional Boolean that validates values returned by ManualParameters. Use the failing call in pycqed/instrument_drivers/meta_instrument/qubit_objects/CCL_Transmon.py as the behavioral example. Done means an unset parameter reports its parameter context through validation instead of producing a later NoneType error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100