Skip to content

Commit 9c30bde

Browse files
author
Moritz-Alexander-Kern
committed
refactor naming for x to compare and z to control
1 parent d655ac6 commit 9c30bde

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

neo/core/filters.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ class FilterCondition(ABC):
3333
segment=filter({'my_annotation': <FilterCondition>})
3434
"""
3535
@abstractmethod
36-
def __init__(self, z) -> None:
36+
def __init__(self, control: Any) -> None:
3737
"""
3838
Initialize new FilterCondition object.
3939
4040
Parameters:
41-
z: Any - The control value to be used for filtering.
41+
control: Any - The control value to be used for filtering.
4242
4343
This is an abstract base class and should not be instantiated directly.
4444
"""
4545

4646
@abstractmethod
47-
def evaluate(self, x):
47+
def evaluate(self, compare: Any) -> bool:
4848
"""
4949
Evaluate the filter condition for given value.
5050
5151
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.
5353
5454
Returns:
5555
bool: True if the condition is satisfied, False otherwise.
@@ -62,80 +62,80 @@ class Equals(FilterCondition):
6262
"""
6363
Filter condition to check if target value is equal to the control value.
6464
"""
65-
def __init__(self, z: Any) -> None:
66-
self.control = z
65+
def __init__(self, control: Any) -> None:
66+
self.control = control
6767

68-
def evaluate(self, x: Any) -> bool:
69-
return x == self.control
68+
def evaluate(self, compare: Any) -> bool:
69+
return compare == self.control
7070

7171

7272
class IsNot(FilterCondition):
7373
"""
7474
Filter condition to check if target value is not equal to the control value.
7575
"""
76-
def __init__(self, z: Any) -> None:
77-
self.control = z
76+
def __init__(self, control: Any) -> None:
77+
self.control = control
7878

79-
def evaluate(self, x: Any) -> bool:
80-
return x != self.control
79+
def evaluate(self, compare: Any) -> bool:
80+
return compare != self.control
8181

8282

8383
class LessThanOrEquals(FilterCondition):
8484
"""
8585
Filter condition to check if target value is less than or equal to the control value.
8686
"""
87-
def __init__(self, z: Number) -> None:
88-
self.control = z
87+
def __init__(self, control: Number) -> None:
88+
self.control = control
8989

90-
def evaluate(self, x: Number) -> bool:
91-
return x <= self.control
90+
def evaluate(self, compare: Number) -> bool:
91+
return compare <= self.control
9292

9393

9494
class GreaterThanOrEquals(FilterCondition):
9595
"""
9696
Filter condition to check if target value is greater than or equal to the control value.
9797
"""
98-
def __init__(self, z: Number) -> None:
99-
self.control = z
98+
def __init__(self, control: Number) -> None:
99+
self.control = control
100100

101-
def evaluate(self, x: Number) -> bool:
102-
return x >= self.control
101+
def evaluate(self, compare: Number) -> bool:
102+
return compare >= self.control
103103

104104

105105
class LessThan(FilterCondition):
106106
"""
107107
Filter condition to check if target value is less than the control value.
108108
"""
109-
def __init__(self, z: Number) -> None:
110-
self.control = z
109+
def __init__(self, control: Number) -> None:
110+
self.control = control
111111

112-
def evaluate(self, x: Number) -> bool:
113-
return x < self.control
112+
def evaluate(self, compare: Number) -> bool:
113+
return compare < self.control
114114

115115

116116
class GreaterThan(FilterCondition):
117117
"""
118118
Filter condition to check if target value is greater than the control value.
119119
"""
120-
def __init__(self, z: Number) -> None:
121-
self.control = z
120+
def __init__(self, control: Number) -> None:
121+
self.control = control
122122

123-
def evaluate(self, x: Number) -> bool:
124-
return x > self.control
123+
def evaluate(self, compare: Number) -> bool:
124+
return compare > self.control
125125

126126

127127
class IsIn(FilterCondition):
128128
"""
129129
Filter condition to check if target is in control.
130130
"""
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
133133

134-
def evaluate(self, x: Any) -> bool:
134+
def evaluate(self, compare: Any) -> bool:
135135
if isinstance(self.control, (list, tuple, set)):
136-
return x in self.control
136+
return compare in self.control
137137
if isinstance(self.control, int):
138-
return x == self.control
138+
return compare == self.control
139139

140140
raise SyntaxError('parameter not of type list, tuple, set or int')
141141

@@ -150,8 +150,8 @@ class InRange(FilterCondition):
150150
Parameters:
151151
lower_bound: int - The lower bound of the range.
152152
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).
155155
"""
156156
def __init__(self, lower_bound: Number, upper_bound: Number,
157157
left_closed: bool=False, right_closed: bool=False) -> None:
@@ -163,11 +163,11 @@ def __init__(self, lower_bound: Number, upper_bound: Number,
163163
self.left_closed = left_closed
164164
self.right_closed = right_closed
165165

166-
def evaluate(self, x: Number) -> bool:
166+
def evaluate(self, compare: Number) -> bool:
167167
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
169169
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
171171
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

Comments
 (0)