checking for number-ness in StandardParameter._sweep_steps
Open
@jenshnielsen is already working on this.
Since May 8, 2017.
bug
- Dominant language
- Python
- Stars
- 459
- Forks
- 359
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 73
Description
@giulioungaretti
Steps to reproduce
use a=np.arange(0, 1000, 1) to create an array of sweep values for, say the ivvi.dac1.
use ivvi.dac1(a[0]) to change the dac value
Expected behaviour
this should work without warnings
Actual behaviour
a warning is spit out:
WARNING:root:cannot sweep dac1 from 998 to 999 - jumping.
This is because the following code gives an error (copied from StandardParameter):
def _sweep_steps(self, value):
oldest_ok_val = datetime.now() - timedelta(seconds=self._max_val_age)
state = self._latest()
if state['ts'] is None or state['ts'] < oldest_ok_val:
start_value = self.get()
else:
start_value = state['value']
self.validate(start_value)
if not (isinstance(start_value, (int, float)) and
isinstance(value, (int, float))):
# something weird... parameter is numeric but one of the ends
# isn't, even though it's valid.
# probably a MultiType with a mix of numeric and non-numeric types
# just set the endpoint and move on
logging.warning('cannot sweep {} from {} to {} - jumping.'.format(
self.name, start_value, value))
return []
# drop the initial value, we're already there
return permissive_range(start_value, value, self._step)[1:]
the isinstance is probably not the correct way to check if something is a number,
(np.arange yields an array of int32's instead of int64's which is the root cause of the problem)
System
windows 7 (64 bit)
master branch
9602616bb924b540d56880b4f3437980271fcd9e
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.