示例#1
0
def test_add_or_remove_rows_noop(seed, df, alloc_id, count, constraint):
    target = len(df)

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(result, df)
示例#2
0
def test_add_or_remove_rows_noop(seed, df, alloc_id, count, constraint):
    target = len(df)

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(result, df)
示例#3
0
def test_add_or_remove_rows_count_noop(seed, df, alloc_id, count, constraint):
    target = df[count].sum()

    result = syn._add_or_remove_rows(
        df, target, alloc_id, constraint, count=count)

    assert result[count].sum() == target
    pdt.assert_frame_equal(result, df)
示例#4
0
def test_add_or_remove_rows_add(seed, df, alloc_id, count, constraint):
    target = 8

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame(
            {alloc_id: ['a', 'b', 'c', 'b', 'c', 'b', 'c', 'c'],
             count: [1, 2, 3, 4, 5, 5, 1, 4]}))
示例#5
0
def test_add_or_remove_rows_count_noop(seed, df, alloc_id, count, constraint):
    target = df[count].sum()

    result = syn._add_or_remove_rows(df,
                                     target,
                                     alloc_id,
                                     constraint,
                                     count=count)

    assert result[count].sum() == target
    pdt.assert_frame_equal(result, df)
示例#6
0
def test_add_or_remove_rows_count_add(seed, df, alloc_id, count, constraint):
    target = 18

    result = syn._add_or_remove_rows(
        df, target, alloc_id, constraint, count=count)

    assert result[count].sum() == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame(
            {alloc_id: ['a', 'b', 'c', 'b', 'c', 'b'],
             count: [1, 2, 3, 4, 5, 3]}))
示例#7
0
def test_add_or_remove_rows_remove(seed, df, alloc_id, count, constraint):
    target = 3

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame(
            {alloc_id: ['b', 'c', 'b'],
             count: [2, 3, 4]},
            index=[1, 2, 3]))
示例#8
0
def test_add_or_remove_rows_add(seed, df, alloc_id, count, constraint):
    target = 8

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame({
            alloc_id: ['a', 'b', 'c', 'b', 'c', 'b', 'c', 'c'],
            count: [1, 2, 3, 4, 5, 5, 1, 4]
        }))
示例#9
0
def test_add_or_remove_rows_remove(seed, df, alloc_id, count, constraint):
    target = 3

    result = syn._add_or_remove_rows(df, target, alloc_id, constraint)

    assert len(result) == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame({
            alloc_id: ['b', 'c', 'b'],
            count: [2, 3, 4]
        },
                     index=[1, 2, 3]))
示例#10
0
def test_add_or_remove_rows_count_add_no_stuff(
        seed, df, alloc_id, count, constraint):
    target = 30
    stuff = False

    result = syn._add_or_remove_rows(
        df, target, alloc_id, constraint, count=count, stuff=stuff)

    assert result[count].sum() == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame(
            {alloc_id: ['a', 'b', 'c', 'b', 'c', 'b', 'c', 'c', 'c', None],
             count: [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]}))
示例#11
0
def test_add_or_remove_rows_count_add(seed, df, alloc_id, count, constraint):
    target = 18

    result = syn._add_or_remove_rows(df,
                                     target,
                                     alloc_id,
                                     constraint,
                                     count=count)

    assert result[count].sum() == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame({
            alloc_id: ['a', 'b', 'c', 'b', 'c', 'b'],
            count: [1, 2, 3, 4, 5, 3]
        }))
示例#12
0
def test_add_or_remove_rows_count_add_no_stuff(seed, df, alloc_id, count,
                                               constraint):
    target = 30
    stuff = False

    result = syn._add_or_remove_rows(df,
                                     target,
                                     alloc_id,
                                     constraint,
                                     count=count,
                                     stuff=stuff)

    assert result[count].sum() == target
    pdt.assert_frame_equal(
        result,
        pd.DataFrame({
            alloc_id: ['a', 'b', 'c', 'b', 'c', 'b', 'c', 'c', 'c', None],
            count: [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]
        }))