Пример #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]
        }))