From 39c5a8a45ec24a88c26fcbf4cb5c4cd4fcc68f0c Mon Sep 17 00:00:00 2001 From: Christian Tremblay Date: Tue, 17 Nov 2015 23:28:13 -0500 Subject: [PATCH] Added __contains__ function to Device so it compares value to fx.points_names for super quick verification of point existence Signed-off-by: Christian Tremblay --- BAC0/core/devices/Device.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/BAC0/core/devices/Device.py b/BAC0/core/devices/Device.py index 83b4b365..7c3058b5 100644 --- a/BAC0/core/devices/Device.py +++ b/BAC0/core/devices/Device.py @@ -271,10 +271,11 @@ def poll(self, command='start', *, delay=10): def __getitem__(self, point_name): """ Get a point based on its name + If a list is passed, will return a dataframe - :param point_name: (str) name of the point + :param point_name: (str) name of the point or list of point_names :type point_name: str - :returns: (Point) the point (can be Numeric, Boolean or Enum) + :returns: (Point) the point (can be Numeric, Boolean or Enum) or pd.DataFrame """ if isinstance(point_name,list): return self.df(point_name) @@ -287,6 +288,10 @@ def __iter__(self): """ for each in self.points: yield each + + def __contains__(self, value): + "When using in..." + return value in self.points_name @property def points_name(self):