Я попробовал два метода хеширования: один путем приведения обоих массивов к кортежам и их хеширования, а другой путем вызов метода tobytes() для каждого массива:
Код: Выделить всё
class MyClass:
# ... init, doA(), doB(), etc. ...
def __eq__(self, other):
if not type(self) == type(other):
return False
if not np.array_equal(self._x, other._x, equal_nan=True):
return False
if not np.array_equal(self._y, other._y, equal_nan=True):
return False
return True
def hash1(self):
return hash((tuple(self._x), tuple(self._y)))
def hash2(self):
return hash((self._x.tobytes(), self._y.tobytes()))
Подробнее здесь: https://stackoverflow.com/questions/781 ... umpy-array