Skip to content

Commit 70a425e

Browse files
author
Moritz-Alexander-Kern
committed
add tuples and sets to IsIn class
1 parent ca82dcd commit 70a425e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

neo/core/filters.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:func:`neo.core.container.filter()` to perform specific filtering operations on data.
2121
"""
2222
from abc import ABC, abstractmethod
23+
from numbers import Number
2324

2425
class FilterCondition(ABC):
2526
"""
@@ -131,6 +132,10 @@ def __init__(self, z):
131132
def evaluate(self, x):
132133
if isinstance(self.control, list):
133134
return x in self.control
135+
if isinstance(self.control, tuple):
136+
return x in self.control
137+
if isinstance(self.control, set):
138+
return x in self.control
134139
if isinstance(self.control, int):
135140
return x == self.control
136141

@@ -151,8 +156,8 @@ class InRange(FilterCondition):
151156
right_closed: bool - If True, the range includes the upper bound (x <= upper_bound).
152157
"""
153158
def __init__(self, lower_bound, upper_bound, left_closed=False, right_closed=False):
154-
if not isinstance(lower_bound, int) or not isinstance(upper_bound, int):
155-
raise SyntaxError("parameters not of type int")
159+
if not isinstance(lower_bound, Number) or not isinstance(upper_bound, Number):
160+
raise ValueError("parameter is not a number")
156161

157162
self.lower_bound = lower_bound
158163
self.upper_bound = upper_bound

0 commit comments

Comments
 (0)