Skip to content

Commit 158246b

Browse files
refactor (#323)
1 parent 495e072 commit 158246b

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

tests/testthat/_snaps/exclude_cols_then_pivot_wider.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/testthat/_snaps/toy_result.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$ companies_id : chr [1:456] "antimonarchy_canine" "antimonarchy_canine" "antimonarchy_canine" "antimonarchy_canine" ...
88
$ grouped_by : chr [1:456] "all" "isic_4digit" "tilt_subsector" "unit" ...
99
$ risk_category : chr [1:456] "high" "high" "high" "high" ...
10-
$ profile_ranking : num [1:456] 1 1 1 1 1 1 1 1 1 1 ...
10+
$ profile_ranking : num [1:456] 1 1 1 1 NA 1 1 1 1 1 ...
1111
$ clustered : chr [1:456] "tent" "tent" "tent" "tent" ...
1212
$ activity_uuid_product_uuid: chr [1:456] "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" ...
1313
$ co2_footprint : num [1:456] 303 303 303 303 303 ...
@@ -32,7 +32,7 @@
3232
$ companies_id : chr [1:690] "antimonarchy_canine" "antimonarchy_canine" "antimonarchy_canine" "antimonarchy_canine" ...
3333
$ grouped_by : chr [1:690] "all" "input_isic_4digit" "input_tilt_subsector" "input_unit" ...
3434
$ risk_category : chr [1:690] "high" "high" "high" "high" ...
35-
$ profile_ranking : num [1:690] 0.938 1 1 1 1 ...
35+
$ profile_ranking : num [1:690] 0.938 1 1 1 NA ...
3636
$ clustered : chr [1:690] "tent" "tent" "tent" "tent" ...
3737
$ activity_uuid_product_uuid : chr [1:690] "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" "76269c17-78d6-420b-991a-aa38c51b45b7" ...
3838
$ input_activity_uuid_product_uuid: chr [1:690] "44e5e288-4f81-40d0-88b4-e79eaea6574c" "44e5e288-4f81-40d0-88b4-e79eaea6574c" "44e5e288-4f81-40d0-88b4-e79eaea6574c" "44e5e288-4f81-40d0-88b4-e79eaea6574c" ...

tests/testthat/test-profile_emissions.R

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -404,27 +404,6 @@ test_that("with some match preserves unmatched products (#193)", {
404404
expect_equal(unique(product$activity_uuid_product_uuid), c(uuid, "unmatched"))
405405
})
406406

407-
test_that("with no match errors gracefully", {
408-
companies <- read_csv(toy_emissions_profile_any_companies()) |>
409-
filter(companies_id %in% dplyr::first(companies_id)) |>
410-
mutate(activity_uuid_product_uuid = "unmatched")
411-
co2 <- read_csv(toy_emissions_profile_products_ecoinvent())
412-
413-
europages_companies <- read_csv(toy_europages_companies())
414-
ecoinvent_activities <- read_csv(toy_ecoinvent_activities())
415-
ecoinvent_europages <- read_csv(toy_ecoinvent_europages())
416-
isic_name <- read_csv(toy_isic_name())
417-
418-
expect_error(profile_emissions(
419-
companies,
420-
co2,
421-
europages_companies,
422-
ecoinvent_activities,
423-
ecoinvent_europages,
424-
isic_name
425-
), class = "all_benchmark_is_na")
426-
})
427-
428407
test_that("at product level, preserves missing benchmarks (#153#issuecomment-2010043596)", {
429408
companies <- read_csv(toy_emissions_profile_any_companies())
430409
id <- unique(companies$companies_id)[[1]]
@@ -562,7 +541,9 @@ test_that("if `*profile$` column has NA then `tilt_sector` and `tilt_subsector`
562541
isic_name
563542
)
564543

565-
product <- unnest_product(out)
544+
product <- unnest_product(out) |>
545+
# Due to single product, it qualifies for the uuid exclusion of unit-isic group if unique uuid count is 1. Please change the sample data!
546+
filter(benchmark != "unit_isic_4digit")
566547
where_risk_category_is_na <- product |>
567548
filter(is.na(get_column(product, "profile$")))
568549

0 commit comments

Comments
 (0)