def test_project_lambda_smoke_negatives(): dp = DemographicParity() events = ['all'] signs = ['+', '-'] labels = ['a', 'b'] midx = pd.MultiIndex.from_product([signs, events, labels], names=[_SIGN, _EVENT, _GROUP_ID]) df = pd.DataFrame() # Note that the '-' indices (11 and 19) are larger # than the '+' indices (1 and 2) df = 0 + pd.Series([1, 2, 11, 19], index=midx, dtype=np.float64) ls = dp.project_lambda(df) expected = pd.DataFrame() expected = 0 + pd.Series([0, 0, 10, 17], index=midx, dtype=np.float64) assert expected.equals(ls)
def test_project_lambda_smoke_positives(): # This is a repeat of the _negatives method but with # the '+' indices larger dp = DemographicParity() events = ['all'] signs = ['+', '-'] labels = ['a', 'b'] midx = pd.MultiIndex.from_product([signs, events, labels], names=[_SIGN, _EVENT, _GROUP_ID]) df = pd.DataFrame() # Note that the '-' indices are smaller than # the '+' ones df = 0 + pd.Series([23, 19, 5, 7], index=midx, dtype=np.float64) ls = dp.project_lambda(df) expected = pd.DataFrame() expected = 0 + pd.Series([18, 12, 0, 0], index=midx, dtype=np.float64) assert expected.equals(ls)