def contains(self, x): if not isinstance(x, (tuple, list, np.generic, np.ndarray)): return False return np.shape(x) == self.shape and np.sum(x) == 1 and np.max(x) == 1