-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
profile_emissions()
yields different output than tiltIndicatorAfter::profile_emissions()
#143
Labels
bug
Something isn't working
Comments
10 tasks
maurolepore
changed the title
FIXME: Mar 15, 2024
tiltWorkflows::profile_emissions()
should output the same as tiltIndicatorAfter::profile_emissions()
profile_emissions()
yields different output than tiltIndicatorAfter::profile_emissions()
Most likely the problem was the cache. It must have been contamined with data from previous runs. I deleted the cache and now both functions output the same. library(readr, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(tiltWorkflows)
#> Loading required package: tiltIndicatorAfter
#> Loading required package: tiltToyData
#>
#> Attaching package: 'tiltWorkflows'
#> The following objects are masked from 'package:tiltIndicatorAfter':
#>
#> profile_emissions, profile_emissions_upstream, profile_sector,
#> profile_sector_upstream
# IMPORTANT
cache_delete()
#> Warning: Deleting `cache_dir`:
#> • ~/.cache/tiltWorkflows
withr::local_options(readr.show_col_types = FALSE)
read_input <- function(...) readr::read_csv(here::here("input", ...))
toy_emissions_profile_products_ecoinvent <- read_input("emissions_profile_products_ecoinvent.csv")
toy_emissions_profile_any_companies <- read_input("emissions_profile_any_companies_ecoinvent.csv") |>
filter(companies_id == "-fred-sl_00000005407085-741049001")
toy_europages_companies <- read_input("ep_companies.csv")
toy_ecoinvent_activities <- read_input("ei_activities_overview.csv")
toy_ecoinvent_europages <- read_input("mapper_ep_ei.csv")
toy_isic_name <- read_input("isic_4digit_name.csv")
tilt_indicator_after <- tiltIndicatorAfter::profile_emissions(
companies = toy_emissions_profile_any_companies,
co2 = toy_emissions_profile_products_ecoinvent,
europages_companies = toy_europages_companies,
ecoinvent_activities = toy_ecoinvent_activities,
ecoinvent_europages = toy_ecoinvent_europages,
isic = toy_isic_name
) |>
unnest_product()
#> ℹ Adding 52% and 56% noise to `co2e_lower` and `co2e_upper`, respectively.
tilt_workflows <- tiltWorkflows::profile_emissions(
companies = toy_emissions_profile_any_companies,
co2 = toy_emissions_profile_products_ecoinvent,
europages_companies = toy_europages_companies,
ecoinvent_activities = toy_ecoinvent_activities,
ecoinvent_europages = toy_ecoinvent_europages,
isic = toy_isic_name
) |>
unnest_product()
#> Warning: Splitting `companies` into 12 chunks.
#> ℹ Adding 55% and 102% noise to `co2e_lower` and `co2e_upper`, respectively.
problematic <- c(
"country",
"matched_reference_product",
"main_activity",
"matched_activity_name",
"unit"
)
tilt_indicator_after |> relocate(matches(problematic))
#> # A tibble: 12 × 25
#> country matched_reference_product main_activity matched_activity_name unit
#> <chr> <chr> <chr> <chr> <chr>
#> 1 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 2 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 3 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 4 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 5 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 6 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 7 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 8 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 9 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 10 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 11 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 12 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> # ℹ 20 more variables: companies_id <chr>, company_name <chr>,
#> # emission_profile <chr>, benchmark <chr>, ep_product <chr>,
#> # co2e_lower <dbl>, co2e_upper <dbl>, multi_match <lgl>,
#> # matching_certainty <chr>, matching_certainty_company_average <chr>,
#> # tilt_sector <chr>, tilt_subsector <chr>, isic_4digit <chr>,
#> # isic_4digit_name <chr>, company_city <chr>, postcode <chr>, address <chr>,
#> # activity_uuid_product_uuid <chr>, profile_ranking <dbl>, …
tilt_workflows |> relocate(matches(problematic))
#> # A tibble: 12 × 25
#> country matched_reference_product main_activity matched_activity_name unit
#> <chr> <chr> <chr> <chr> <chr>
#> 1 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 2 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 3 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 4 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 5 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 6 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 7 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 8 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 9 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 10 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 11 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> 12 spain fish freezing, small fish wholesaler market for fish freezi… kg
#> # ℹ 20 more variables: companies_id <chr>, company_name <chr>,
#> # emission_profile <chr>, benchmark <chr>, ep_product <chr>,
#> # co2e_lower <dbl>, co2e_upper <dbl>, multi_match <lgl>,
#> # matching_certainty <chr>, matching_certainty_company_average <chr>,
#> # tilt_sector <chr>, tilt_subsector <chr>, isic_4digit <chr>,
#> # isic_4digit_name <chr>, company_city <chr>, postcode <chr>, address <chr>,
#> # activity_uuid_product_uuid <chr>, profile_ranking <dbl>, …
identical(
tilt_indicator_after |> select(-matches(c("co2"))),
tilt_workflows |> select(-matches(c("co2")))
)
#> [1] TRUE |
maurolepore
changed the title
FIXME:
Mar 15, 2024
profile_emissions()
yields different output than tiltIndicatorAfter::profile_emissions()
profile_emissions()
yields different output than tiltIndicatorAfter::profile_emissions()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I expected both funcitons to output the same but this reprex shows otherwise.
reprex
Thanks @kalashsinghal (2DegreesInvesting/tiltIndicatorAfter#153 (comment))
The text was updated successfully, but these errors were encountered: