RMI-PACTA / pacta.portfolio.allocate

https://rmi-pacta.github.io/pacta.portfolio.allocate/
Other
1 stars 0 forks source link

`calculate_tdm` and `tdm_conditions_met` seem to not strip out groups missing crucial years #8

Closed jdhoffa closed 1 year ago

jdhoffa commented 1 year ago

Expected behavior: tdm_conditions_met checks if the data contains groups that have relevant years (t0, t0+delta_t1, t0+delta_t2). Note: production values and targets are required for all three of these years to calculate the metric.

calculate_tdm checks if the data contains groups that have relevant years (t0, t0+delta_t1, t0+delta_t2). Note: production values and targets are required for all three of these years to calculate the metric.

Actual behaviour: calculate_tdm tries to calculate TDM for groups that are missing certain years. There must be a flaw in the filtering logic.

Relevant parts of code: https://github.com/RMI-PACTA/pacta.portfolio.allocate/blob/c550190b75d964836227b3ffe1c01b6b88141c20/R/tdm_conditions_met.R#L37C2-L41

https://github.com/RMI-PACTA/pacta.portfolio.allocate/blob/c550190b75d964836227b3ffe1c01b6b88141c20/R/calculate_tdm.R#L100C5-L105