From 2f19ffcc2041fae56020f76d87579a9b65214ad3 Mon Sep 17 00:00:00 2001 From: Benjamin Reese Date: Wed, 8 Jan 2025 14:20:40 -0800 Subject: [PATCH] Use == False instead of is False, restrict allowed values for EnableVariable --- python/pyrogue/_DataReceiver.py | 2 +- python/pyrogue/_Device.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/python/pyrogue/_DataReceiver.py b/python/pyrogue/_DataReceiver.py index 9bb431c62..936352f39 100644 --- a/python/pyrogue/_DataReceiver.py +++ b/python/pyrogue/_DataReceiver.py @@ -88,7 +88,7 @@ def _acceptFrame(self, frame): """ # Do nothing if not yet started or enabled - if self.running is False or self.RxEnable.value() is False: + if self.running is False or self.RxEnable.value() == False: return # Lock frame diff --git a/python/pyrogue/_Device.py b/python/pyrogue/_Device.py index cc0bde492..3962bb113 100644 --- a/python/pyrogue/_Device.py +++ b/python/pyrogue/_Device.py @@ -31,6 +31,8 @@ def __init__(self, *, enabled, deps=None): groups='Enable', disp={False: 'False', True: 'True', 'parent': 'ParentFalse', 'deps': 'ExtDepFalse'}) + self.allowed_values = {True, False, 'parent', 'deps'} + if deps is None: self._deps = [] self._depDis = False @@ -97,6 +99,10 @@ def set(self, value, write=True, index=-1): ------- """ + if value not in self.allowed_values: + raise pr.VariableError( + f'Error calling {self.path}.set({value=}) - value must be one of {self.allowed_values}') + if value != 'parent' and value != 'deps': old = self.value()