def test_binify(bins, df1): from flotilla.compute.infotheory import bin_range_strings, binify binned = binify(df1, bins) true_binned = df1.apply(lambda x: pd.Series(np.histogram(x, bins=bins)[0])) true_binned.index = bin_range_strings(bins) true_binned = true_binned / true_binned.sum().astype(float) pdt.assert_frame_equal(binned, true_binned)
def test_bin_range_strings(bins): from flotilla.compute.infotheory import bin_range_strings bin_ranges = bin_range_strings(bins) true_bin_ranges = ['{}-{}'.format(i, j) for i, j in zip(bins, bins[1:])] npt.assert_equal(bin_ranges, true_bin_ranges)