Skip to content

Commit

Permalink
Restore deprecated parameter setters and getters (#790)
Browse files Browse the repository at this point in the history
* set private variable in init

This is how the official documentation does it and avoids a number of linter warnings

* revert setting parameter via _private value

* restore get/set as deprecated

unbreaks some scripts and drivers that may be relying on this

* restore meaning of step=0 to no step

* update tutorial notebook to use non deprecated api

* readd deprecated delay kwarg

the order is still scrambled but there is not much we can do about that
  • Loading branch information
jenshnielsen authored and WilliamHPNielsen committed Oct 16, 2017
1 parent 7b20f44 commit b087b32
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 99 deletions.
174 changes: 77 additions & 97 deletions docs/examples/Tutorial.ipynb

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions qcodes/instrument/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def __init__(self, name: str,
set_parser: Optional[Callable]=None,
snapshot_value: bool=True,
max_val_age: Optional[float]=None,
vals: Optional[Validator]=None):
vals: Optional[Validator]=None,
delay: Optional[Union[int, float]]=None):
super().__init__(metadata)
self.name = str(name)
self._instrument = instrument
Expand All @@ -177,6 +178,11 @@ def __init__(self, name: str,
self.step = step
self.scale = scale
self.raw_value = None
if delay is not None:
warnings.warn("Delay kwarg is deprecated. Replace with "
"inter_delay or post_delay as needed")
if post_delay == 0:
post_delay = delay
self.inter_delay = inter_delay
self.post_delay = post_delay

Expand Down Expand Up @@ -466,7 +472,7 @@ def step(self):
return self._step

@step.setter
def step(self, step):
def step(self, step: Union[int, float]):
"""
Configure whether this Parameter uses steps during set operations.
If step is a positive number, this is the maximum value change
Expand All @@ -490,13 +496,39 @@ def step(self, step):
raise TypeError('you can only step numeric parameters')
elif not isinstance(step, (int, float)):
raise TypeError('step must be a number')
elif step == 0:
self._step = None
elif step <= 0:
raise ValueError('step must be positive')
elif isinstance(self.vals, Ints) and not isinstance(step, int):
raise TypeError('step must be a positive int for an Ints parameter')
else:
self._step = step

def set_step(self, value):
warnings.warn(
"set_step is deprecated use step property as in `inst.step = "
"stepvalue` instead")
self.step = value

def get_step(self):
warnings.warn(
"set_step is deprecated use step property as in `a = inst.step` "
"instead")
return self._step

def set_delay(self, value):
warnings.warn(
"set_delay is deprecated use inter_delay or post_delay property "
"as in `inst.inter_delay = delayvalue` instead")
self.post_delay = value

def get_delay(self):
warnings.warn(
"get_delay is deprecated use inter_delay or post_delay property "
"as in `a = inst.inter_delay` instead")
return self._post_delay

@property
def post_delay(self):
"""Property that returns the delay time of this parameter"""
Expand Down

0 comments on commit b087b32

Please sign in to comment.