-
Notifications
You must be signed in to change notification settings - Fork 333
Closed
Description
If you encounter a bug use the following template.
If you have a feature request feel free to freestyle.
Steps to reproduce
- make parameter with
self.add_parameter('is_quenched',
get_cmd='QU?',
get_parser=str,
val_mapping={False: '0', True: '1'})
- use
instrument.is_quenched()
Expected behaviour
no error
Actual behaviour
I get the error (see below):
from which it is apparent it uses _valmapping_get_parser
for which the docstring says:
"""
Get parser to be used in the case that a val_mapping is defined
and a separate get_parser is not defined.
Tries to match against defined strings in the mapping dictionary. If
there are no matches, we try to convert the val into an integer.
"""
So it seems to me that it ignores my get_parser
error traceback:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in _valmapping_get_parser(self, val)
831 val = int(val)
--> 832 return self._get_mapping[val]
833 except (ValueError, KeyError):
KeyError: 0
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-9-e839900e5e48> in <module>()
----> 1 station.AMI430_3D._magnet_x.is_quenched()
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in __call__(self, *args)
127 if len(args) == 0:
128 if self.has_get:
--> 129 return self.get()
130 else:
131 raise NotImplementedError('no get cmd found in' +
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in get(self)
809 except Exception as e:
810 e.args = e.args + ('getting {}'.format(self.full_name),)
--> 811 raise e
812
813 def _valmapping_get_parser(self, val):
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in get(self)
804 def get(self):
805 try:
--> 806 value = self._get()
807 self._save_val(value)
808 return value
d:\pycharmprojects\qcodes\qcodes\utils\command.py in __call__(self, *args)
175 raise TypeError(
176 'command takes exactly {} args'.format(self.arg_count))
--> 177 return self.exec_function(*args)
d:\pycharmprojects\qcodes\qcodes\utils\command.py in call_by_str_parsed_out(self, *args)
128 def call_by_str_parsed_out(self, *args):
129 """Execute a formatted string with output parsing."""
--> 130 return self.output_parser(self.exec_str(self.cmd_str.format(*args)))
131
132 def call_by_str_parsed_in(self, arg):
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in _valmapping_with_preparser(self, val)
835
836 def _valmapping_with_preparser(self, val):
--> 837 return self._valmapping_get_parser(self._get_preparser(val))
838
839 def _set_get(self, get_cmd, get_parser):
d:\pycharmprojects\qcodes\qcodes\instrument\parameter.py in _valmapping_get_parser(self, val)
832 return self._get_mapping[val]
833 except (ValueError, KeyError):
--> 834 raise KeyError('Unmapped value from instrument: {!r}'.format(val))
835
836 def _valmapping_with_preparser(self, val):
KeyError: ('Unmapped value from instrument: 0', 'getting AMI430_X_is_quenched')
System
operating system
win7
qcodes branch
local, related to driver/AMI_430
qcodes commit
latest merge with master
de88c36
Metadata
Metadata
Assignees
Labels
No labels