@@ -33,23 +33,23 @@ class FilterCondition(ABC):
33
33
segment=filter({'my_annotation': <FilterCondition>})
34
34
"""
35
35
@abstractmethod
36
- def __init__ (self , z ) -> None :
36
+ def __init__ (self , control : Any ) -> None :
37
37
"""
38
38
Initialize new FilterCondition object.
39
39
40
40
Parameters:
41
- z : Any - The control value to be used for filtering.
41
+ control : Any - The control value to be used for filtering.
42
42
43
43
This is an abstract base class and should not be instantiated directly.
44
44
"""
45
45
46
46
@abstractmethod
47
- def evaluate (self , x ) :
47
+ def evaluate (self , compare : Any ) -> bool :
48
48
"""
49
49
Evaluate the filter condition for given value.
50
50
51
51
Parameters:
52
- x : Any - The value to be compared with the control value.
52
+ compare : Any - The value to be compared with the control value.
53
53
54
54
Returns:
55
55
bool: True if the condition is satisfied, False otherwise.
@@ -62,80 +62,80 @@ class Equals(FilterCondition):
62
62
"""
63
63
Filter condition to check if target value is equal to the control value.
64
64
"""
65
- def __init__ (self , z : Any ) -> None :
66
- self .control = z
65
+ def __init__ (self , control : Any ) -> None :
66
+ self .control = control
67
67
68
- def evaluate (self , x : Any ) -> bool :
69
- return x == self .control
68
+ def evaluate (self , compare : Any ) -> bool :
69
+ return compare == self .control
70
70
71
71
72
72
class IsNot (FilterCondition ):
73
73
"""
74
74
Filter condition to check if target value is not equal to the control value.
75
75
"""
76
- def __init__ (self , z : Any ) -> None :
77
- self .control = z
76
+ def __init__ (self , control : Any ) -> None :
77
+ self .control = control
78
78
79
- def evaluate (self , x : Any ) -> bool :
80
- return x != self .control
79
+ def evaluate (self , compare : Any ) -> bool :
80
+ return compare != self .control
81
81
82
82
83
83
class LessThanOrEquals (FilterCondition ):
84
84
"""
85
85
Filter condition to check if target value is less than or equal to the control value.
86
86
"""
87
- def __init__ (self , z : Number ) -> None :
88
- self .control = z
87
+ def __init__ (self , control : Number ) -> None :
88
+ self .control = control
89
89
90
- def evaluate (self , x : Number ) -> bool :
91
- return x <= self .control
90
+ def evaluate (self , compare : Number ) -> bool :
91
+ return compare <= self .control
92
92
93
93
94
94
class GreaterThanOrEquals (FilterCondition ):
95
95
"""
96
96
Filter condition to check if target value is greater than or equal to the control value.
97
97
"""
98
- def __init__ (self , z : Number ) -> None :
99
- self .control = z
98
+ def __init__ (self , control : Number ) -> None :
99
+ self .control = control
100
100
101
- def evaluate (self , x : Number ) -> bool :
102
- return x >= self .control
101
+ def evaluate (self , compare : Number ) -> bool :
102
+ return compare >= self .control
103
103
104
104
105
105
class LessThan (FilterCondition ):
106
106
"""
107
107
Filter condition to check if target value is less than the control value.
108
108
"""
109
- def __init__ (self , z : Number ) -> None :
110
- self .control = z
109
+ def __init__ (self , control : Number ) -> None :
110
+ self .control = control
111
111
112
- def evaluate (self , x : Number ) -> bool :
113
- return x < self .control
112
+ def evaluate (self , compare : Number ) -> bool :
113
+ return compare < self .control
114
114
115
115
116
116
class GreaterThan (FilterCondition ):
117
117
"""
118
118
Filter condition to check if target value is greater than the control value.
119
119
"""
120
- def __init__ (self , z : Number ) -> None :
121
- self .control = z
120
+ def __init__ (self , control : Number ) -> None :
121
+ self .control = control
122
122
123
- def evaluate (self , x : Number ) -> bool :
124
- return x > self .control
123
+ def evaluate (self , compare : Number ) -> bool :
124
+ return compare > self .control
125
125
126
126
127
127
class IsIn (FilterCondition ):
128
128
"""
129
129
Filter condition to check if target is in control.
130
130
"""
131
- def __init__ (self , z : Union [list , tuple , set , int ]) -> None :
132
- self .control = z
131
+ def __init__ (self , control : Union [list , tuple , set , int ]) -> None :
132
+ self .control = control
133
133
134
- def evaluate (self , x : Any ) -> bool :
134
+ def evaluate (self , compare : Any ) -> bool :
135
135
if isinstance (self .control , (list , tuple , set )):
136
- return x in self .control
136
+ return compare in self .control
137
137
if isinstance (self .control , int ):
138
- return x == self .control
138
+ return compare == self .control
139
139
140
140
raise SyntaxError ('parameter not of type list, tuple, set or int' )
141
141
@@ -150,8 +150,8 @@ class InRange(FilterCondition):
150
150
Parameters:
151
151
lower_bound: int - The lower bound of the range.
152
152
upper_bound: int - The upper bound of the range.
153
- left_closed: bool - If True, the range includes the lower bound (lower_bound <= x ).
154
- right_closed: bool - If True, the range includes the upper bound (x <= upper_bound).
153
+ left_closed: bool - If True, the range includes the lower bound (lower_bound <= compare ).
154
+ right_closed: bool - If True, the range includes the upper bound (compare <= upper_bound).
155
155
"""
156
156
def __init__ (self , lower_bound : Number , upper_bound : Number ,
157
157
left_closed : bool = False , right_closed : bool = False ) -> None :
@@ -163,11 +163,11 @@ def __init__(self, lower_bound: Number, upper_bound: Number,
163
163
self .left_closed = left_closed
164
164
self .right_closed = right_closed
165
165
166
- def evaluate (self , x : Number ) -> bool :
166
+ def evaluate (self , compare : Number ) -> bool :
167
167
if not self .left_closed and not self .right_closed :
168
- return self .lower_bound <= x <= self .upper_bound
168
+ return self .lower_bound <= compare <= self .upper_bound
169
169
if not self .left_closed and self .right_closed :
170
- return self .lower_bound <= x < self .upper_bound
170
+ return self .lower_bound <= compare < self .upper_bound
171
171
if self .left_closed and not self .right_closed :
172
- return self .lower_bound < x <= self .upper_bound
173
- return self .lower_bound < x < self .upper_bound
172
+ return self .lower_bound < compare <= self .upper_bound
173
+ return self .lower_bound < compare < self .upper_bound
0 commit comments