Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kozodoi committed Apr 17, 2020
1 parent 9c75700 commit 67e409a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 83 deletions.
5 changes: 3 additions & 2 deletions man/prop_parity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions tests/testthat/test.errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,52 @@ data("compas")
# no preds OR probs defined
test_that("errors in acc_parity", {
expect_error(acc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in dem_parity", {
expect_error(dem_parity(data = compas, group = "ethnicity",
expect_error(dem_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL,
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in equal_odds", {
expect_error(equal_odds(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in fnr_parity", {
expect_error(fnr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in fpr_parity", {
expect_error(fpr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in mcc_parity", {
expect_error(mcc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in npv_parity", {
expect_error(npv_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in pred_rate_parity", {
expect_error(pred_rate_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in prop_parity", {
expect_error(prop_parity(data = compas, group = "ethnicity",
expect_error(prop_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL,
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in spec_parity", {
expect_error(spec_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = NULL, outcome_levels = c("no", "yes"),
probs = NULL, preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})


Expand All @@ -63,41 +63,41 @@ test_that("errors in acc_parity, no outcome", {

test_that("errors in acc_parity, no outcome", {
expect_error(acc_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in equal_odds, no outcome", {
expect_error(equal_odds(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in fnr_parity, no outcome", {
expect_error(fnr_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in fpr_parity, no outcome", {
expect_error(fpr_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in mcc_parity, no outcome", {
expect_error(mcc_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in npv_parity, no outcome", {
expect_error(npv_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in pred_rate_parity, no outcome", {
expect_error(pred_rate_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

test_that("errors in spec_parity, no outcome", {
expect_error(spec_parity(data = compas, group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"))})

42 changes: 21 additions & 21 deletions tests/testthat/test.outputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,107 +6,107 @@ data("compas")
# test for number of output items when probability is specified
test_that("number of outputs in acc_parity", {
expect_equal(length(acc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in dem_parity", {
expect_equal(length(dem_parity(data = compas, group = "ethnicity",
expect_equal(length(dem_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL,
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in equal_odds", {
expect_equal(length(equal_odds(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in fnr_parity", {
expect_equal(length(fnr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in fpr_parity", {
expect_equal(length(fpr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in mcc_parity", {
expect_equal(length(mcc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in npv_parity", {
expect_equal(length(npv_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in pred_rate_parity", {
expect_equal(length(pred_rate_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in prop_parity", {
expect_equal(length(prop_parity(data = compas, group = "ethnicity",
expect_equal(length(prop_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL,
cutoff = 0.5, base = "Caucasian")), 3)})

test_that("number of outputs in roc_parity", {
expect_equal(length(roc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", outcome_levels = c("no", "yes"),
probs = "probability", pred_levels = c("no", "yes"),
base = "Caucasian")), 4)})

test_that("number of outputs in spec_parity", {
expect_equal(length(spec_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = "probability", preds = NULL, outcome_levels = c("no", "yes"),
probs = "probability", preds = NULL, pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 3)})

# test for number of output items when predicted class is specified
test_that("number of outputs in acc_parity", {
expect_equal(length(acc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in dem_parity", {
expect_equal(length(dem_parity(data = compas, group = "ethnicity",
expect_equal(length(dem_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted",
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in equal_odds", {
expect_equal(length(equal_odds(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in fnr_parity", {
expect_equal(length(fnr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in fpr_parity", {
expect_equal(length(fpr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in mcc_parity", {
expect_equal(length(mcc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in npv_parity", {
expect_equal(length(npv_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in pred_rate_parity", {
expect_equal(length(pred_rate_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in prop_parity", {
expect_equal(length(prop_parity(data = compas, group = "ethnicity",
expect_equal(length(prop_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted",
cutoff = 0.5, base = "Caucasian")), 2)})

test_that("number of outputs in spec_parity", {
expect_equal(length(spec_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian")), 2)})

20 changes: 10 additions & 10 deletions tests/testthat/test.preds-col.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ data("compas")

test_that("no errors in acc_parity", {
expect_error(acc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in dem_parity", {
expect_error(dem_parity(data = compas, group = "ethnicity",
expect_error(dem_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted",
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in equal_odds", {
expect_error(equal_odds(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in fnr_parity", {
expect_error(fnr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in fpr_parity", {
expect_error(fpr_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in mcc_parity", {
expect_error(mcc_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in npv_parity", {
expect_error(npv_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in pred_rate_parity", {
expect_error(pred_rate_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in prop_parity", {
expect_error(prop_parity(data = compas, group = "ethnicity",
expect_error(prop_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted",
cutoff = 0.5, base = "Caucasian"), NA)})

test_that("no errors in spec_parity", {
expect_error(spec_parity(data = compas, outcome = "Two_yr_Recidivism", group = "ethnicity",
probs = NULL, preds = "predicted", outcome_levels = c("no", "yes"),
probs = NULL, preds = "predicted", pred_levels = c("no", "yes"),
cutoff = 0.5, base = "Caucasian"), NA)})
Loading

0 comments on commit 67e409a

Please sign in to comment.