Example #1
0
def test_accounting_no_replacment_raises(random_df):
    control = 200
    with pytest.raises(ValueError):
        sample_rows(control,
                    random_df,
                    accounting_column='some_count',
                    replace=False)
def test_no_accounting_with_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df)
    assert control == len(rows)

    # test with probabilities
    rows, matched = sample_rows(
        control, random_df, prob_column='p', return_status=True)
    assert control == len(rows)
    assert matched
def test_no_accounting_no_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df, replace=False)
    print(random_df)
    assert control == len(rows)

    rows, matched = sample_rows(
        control, random_df, replace=False, prob_column='p', return_status=True)
    assert control == len(rows)
    assert matched
    assert rows.index.is_unique
def test_accounting_with_replacment(random_df):
    control = 10

    rows, matched = sample_rows(
        control, random_df, accounting_column='some_count', return_status=True)
    assert control == rows['some_count'].sum()
    assert matched

    # test with probabilities
    rows, matched = sample_rows(
        control, random_df, accounting_column='some_count', prob_column='p', return_status=True)
    assert control == rows['some_count'].sum()
    assert matched
Example #5
0
def test_accounting_no_replacment(random_df):
    control = 10
    rows = sample_rows(control,
                       random_df,
                       accounting_column='some_count',
                       replace=False)
    assert control == rows['some_count'].sum()
def test_accounting_no_replacment(random_df):

    def assert_results(control, rows, matched):
        assert control == rows['some_count'].sum()
        assert matched
        assert rows.index.is_unique

    control = 10
    rows, matched = sample_rows(
        control, random_df, accounting_column='some_count', replace=False, return_status=True)
    assert_results(control, rows, matched)

    # test with probabilities
    rows, matched = sample_rows(control, random_df, accounting_column='some_count',
                                replace=False, prob_column='p', return_status=True)
    assert_results(control, rows, matched)
Example #7
0
def test_no_accounting_no_replacment_raises(random_df):
    control = 21
    with pytest.raises(ValueError):
        sample_rows(control, random_df, replace=False)
Example #8
0
def test_non_unique_raises(random_df):
    control = 10
    df = pd.concat([random_df, random_df])
    with pytest.raises(ValueError):
        sample_rows(control, df)
Example #9
0
def test_no_accounting_no_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df, replace=False)
    print random_df
    assert control == len(rows)
Example #10
0
def test_no_accounting_with_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df)
    assert control == len(rows)
Example #11
0
def test_accounting_no_replacment_raises(random_df):
    control = 200
    with pytest.raises(ValueError):
        sample_rows(control, random_df, accounting_column='some_count', replace=False)
Example #12
0
def test_accounting_no_replacment(random_df):
    control = 10
    rows = sample_rows(control, random_df, accounting_column='some_count', replace=False)
    assert control == rows['some_count'].sum()
Example #13
0
def test_no_accounting_no_replacment_raises(random_df):
    control = 21
    with pytest.raises(ValueError):
        sample_rows(control, random_df, replace=False)
Example #14
0
def test_no_accounting_no_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df, replace=False)
    print random_df
    assert control == len(rows)
Example #15
0
def test_no_accounting_with_replacment(random_df):
    control = 3
    rows = sample_rows(control, random_df)
    assert control == len(rows)
Example #16
0
def test_non_unique_raises(random_df):
    control = 10
    df = pd.concat([random_df, random_df])
    with pytest.raises(ValueError):
        sample_rows(control, df)