def test_safe_indexing(self): npt.assert_array_equal( safe_indexing(np.asarray([3, 2, 1]), np.asarray([1, 2])), np.asarray([2, 1])) npt.assert_array_equal(safe_indexing(np.asarray([3, 2, 1]), [1, 2]), np.asarray([2, 1])) self.assertListEqual(safe_indexing([3, 2, 1], [1, 2]), [2, 1])
def test_safe_indexing(): assert all([ a == b for a, b in zip( safe_indexing(np.asarray([3, 2, 1]), np.asarray([1, 2])), np.asarray([2, 1])) ]) assert all([ a == b for a, b in zip(safe_indexing(np.asarray([3, 2, 1]), [1, 2]), np.asarray([2, 1])) ]) assert all( [a == b for a, b in zip(safe_indexing([3, 2, 1], [1, 2]), [2, 1])])
def _split(self): data_idx = self.rng.permutation(len(self._data)) train_idx = data_idx[:self.train_size] test_idx = data_idx[-self.test_size:] val_idx = data_idx[self.train_size:-self.test_size] train_data = safe_indexing(self._data, train_idx) test_data = safe_indexing(self._data, test_idx) val_data = safe_indexing(self._data, val_idx) if len( val_idx) > 0 else None self._build_stratified_datasets(train_data=train_data, test_data=test_data, val_data=val_data)