Skip to content

Commit

Permalink
pass all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zander-prinsloo committed Feb 16, 2024
1 parent 8bebdee commit b525b23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
15 changes: 2 additions & 13 deletions R/pipgd_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ pipgd_welfare_share_at <- function(
welfare = welfare,
weight = weight,
params = params,
popshare = popshare,
...
)

Expand Down Expand Up @@ -190,7 +189,6 @@ pipgd_quantile_welfare_share <-
welfare = welfare,
weight = weight,
params = params,
popshare = popshare,
...)

if (is.null(lorenz)) {
Expand Down Expand Up @@ -304,9 +302,8 @@ pipgd_quantile <-
welfare = welfare,
weight = weight,
params = params,
times_mean = times_mean,
popshare = popshare,
...)
mean <- params$data$mean

if (is.null(lorenz)) {
lorenz <- params$selected_lorenz$for_dist
Expand Down Expand Up @@ -659,7 +656,7 @@ pipgd_polarization <- function(
params <- vector("list")
}

params$dist_stats$gini <- gini
params$dist_stats$gini <- gini
params$dist_stats$polarization <- polarization
params$dist_stats$lorenz <- lorenz

Expand Down Expand Up @@ -713,11 +710,3 @@ validate_params <- function(











6 changes: 3 additions & 3 deletions tests/testthat/test-get_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ test_that("get_mld works", {
out1_gd <- get_mld(pipster_object = gd_object)
out1_md <- get_mld(pipster_object = md_object)
out2_gd <- pipgd_mld(welfare = welfare_gd,
weight = weight_gd)
weight = weight_gd)
out2_md <- pipmd_mld(welfare = welfare_md,
weight = weight_md,
format = "list")
weight = weight_md,
format = "list")

expect_equal(out1_gd$mld ,
out2_gd$dist_stats$mld)
Expand Down
11 changes: 7 additions & 4 deletions tests/testthat/test-pipgd_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ test_that("pipgd_polarization outputs work as expected", {
expect_equal("dist_stats")

names(res$dist_stats) |>
expect_equal(c("polarization",
expect_equal(c("gini",
"polarization",
"lorenz"))

# Names in output list when complete = TRUE
Expand Down Expand Up @@ -1043,7 +1044,8 @@ test_that("pipgd_polarization outputs work as expected", {

names(res_complete$data) |>
expect_equal(c("welfare",
"weight"))
"weight",
"mean"))

names(res_complete$selected_lorenz) |>
expect_equal(c( "for_dist",
Expand All @@ -1052,8 +1054,9 @@ test_that("pipgd_polarization outputs work as expected", {
"use_lq_for_pov" ))

names(res_complete$dist_stats) |>
expect_equal(c("polarization",
"lorenz"))
expect_equal(c("gini",
"lorenz",
"polarization"))

})

Expand Down

0 comments on commit b525b23

Please sign in to comment.