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)
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)
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]}))
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)
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]}))
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]))
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] }))
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]))
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]}))
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] }))
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] }))