Skip to content

Commit e58036f

Browse files
committed
Lookup: Assume that lookup_table is an array
1 parent 6c1c324 commit e58036f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Orange/preprocess/transformation.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, variable, lookup_table, unknown=np.nan):
143143
:param variable: The variable whose transformed value is returned.
144144
:type variable: int or str or :obj:`~Orange.data.DiscreteVariable`
145145
:param lookup_table: transformations for each value of `self.variable`
146-
:type lookup_table: np.array or list or tuple
146+
:type lookup_table: np.array
147147
:param unknown: The value to be used as unknown value.
148148
:type unknown: float or int
149149
"""
@@ -162,14 +162,10 @@ def transform(self, column):
162162
return np.where(mask, self.unknown, values)
163163

164164
def __eq__(self, other):
165-
def nan_equal(x, y):
166-
return x == y or np.isnan(x) and np.isnan(y)
167-
168165
return super().__eq__(other) \
169-
and len(self.lookup_table) == len(other.lookup_table) \
170-
and all(nan_equal(x, y) or np.isnan(x) and np.isnan(y)
171-
for x, y in zip(self.lookup_table, other.lookup_table)) \
172-
and nan_equal(self.unknown, other.unknown)
166+
and np.allclose(self.lookup_table, other.lookup_table,
167+
equal_nan=True) \
168+
and np.allclose(self.unknown, other.unknown, equal_nan=True)
173169

174170
def __hash__(self):
175171
return hash((type(self), self.variable,

0 commit comments

Comments
 (0)