Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't wrap _BaseParameter get and set #797

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions qcodes/instrument/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class _BaseParameter(Metadatable, DeferredOperations):
``MultiParameter``, or ``CombinedParameter``.
Note that ``CombinedParameter`` is not yet a subclass of ``_BaseParameter``

Note:
If you subclass _BaseParameter you will not automatically get
the validation and delay control implemented in the get and set
wrappers. If you want this behaviour but cannot subclass Parameter
you can manually wrap get and set as below with
`self.get = self._wrap_get(self.get_raw)`


Args:
name (str): the local name of the parameter. Should be a valid
identifier, ie no spaces or special characters. If this parameter
Expand Down Expand Up @@ -201,21 +209,6 @@ def __init__(self, name: str,
self._latest = {'value': None, 'ts': None, 'raw_value': None}
self.get_latest = GetLatest(self, max_val_age=max_val_age)

if hasattr(self, 'get_raw'):
self.get = self._wrap_get(self.get_raw)
elif hasattr(self, 'get'):
warnings.warn('Wrapping get method, original get method will not '
'be directly accessible. It is recommended to '
'define get_raw in your subclass instead.' )
self.get = self._wrap_get(self.get)
if hasattr(self, 'set_raw'):
self.set = self._wrap_get(self.set_raw)
elif hasattr(self, 'set'):
warnings.warn('Wrapping set method, original set method will not '
'be directly accessible. It is recommended to '
'define get_raw in your subclass instead.' )
self.set = self._wrap_set(self.set)

# subclasses should extend this list with extra attributes they
# want automatically included in the snapshot
self._meta_attrs = ['name', 'instrument', 'step', 'scale',
Expand Down