def test_groupby(): shuffle_idx = np.random.permutation(np.arange(100)) index = np.tile(np.arange(10), 10) data = np.vstack([np.identity(10) for _ in range(10)]) t = SparseFrame(data[shuffle_idx, :], index=index[shuffle_idx]) res = t.groupby_sum().data.todense() assert np.all(res == (np.identity(10) * 10))
def test_groupby_dense_random_data(): shuffle_idx = np.random.permutation(np.arange(100)) index = np.tile(np.arange(10), 10) single_tile = np.random.rand(10, 10) data = np.vstack([single_tile for _ in range(10)]) t = SparseFrame(data[shuffle_idx, :], index=index[shuffle_idx]) res = t.groupby_sum().data.todense() np.testing.assert_array_almost_equal(res, (single_tile * 10))