def test_group(): dm = DataMatrix(length=4) dm.a = 'b', 'b', 'a', 'a' dm.b = 'x', 'x', 'x', 'y' dm.c = IntColumn dm.c = 0, 1, 2, 3 dm = ops.group(dm, [dm.a, dm.b]) check_series(dm.c, [[2, np.nan], [3, np.nan], [0, 1]])
def test_group(): dm = DataMatrix(length=4) dm.a = 'b', 'b', 'a', 'a' dm.b = 'x', 'x', 'x', 'y' dm.c = IntColumn dm.c = 0, 1, 2, 3 dm = ops.group(dm, [dm.a, dm.b]) check_series(dm.c, [[3, np.nan], [2, np.nan], [0, 1]]) # Order guaranteed?
def test_group(): dm = DataMatrix(length=4) dm.a = 'b', 'b', 'a', 'a' dm.b = 'x', 'x', 'x', 'y' dm.c = IntColumn dm.c = 0, 1, 2, 3 dm = ops.group(dm, [dm.a, dm.b]) # Assert that at least one of the permutations passes for ref in itertools.permutations([[3, np.nan], [2, np.nan], [0, 1]]): try: check_series(dm.c, ref) break except AssertionError: pass else: assert (False)
def descriptives(dm): """ desc: Provides basic descriptives of response times. These are printed directly to the stdout. arguments: dm: type: DataMatrix """ ops.keep_only(dm, cols=['type', 'rt']) gm = ops.group(dm, by=[dm.type]) gm.mean_rt = series.reduce_(gm.rt) gm.se_rt = series.reduce_(gm.rt, lambda x: np.nanstd(x)/np.sqrt(len(x))) gm.n = series.reduce_(gm.rt, lambda x: np.sum(~np.isnan(x))) del gm.rt print(gm)