Hi!
Thanks a lot for this great library :). I was using the latest github version but noticed that the test suite is broken. Maybe it could be good to add a github workflow running the test suite? Or at least to fix the test/code to show the correct intent :).
One of the cases I have in mind is (It's not the only one that needs fixing if I am not mistaken)
| company_name |
company_id |
isic |
target_type |
intensity_metric |
scope |
emissions_in_scope |
reduction_ambition |
base_year |
start_year |
end_year |
achieved_reduction |
target_status |
time_frame |
industry |
ghg_s1s2 |
ghg_s3 |
company_market_cap |
investment_value |
portfolio_weight |
company_cash_equivalents |
company_enterprise_value |
company_ev_plus_cash |
company_total_assets |
sbti_validated |
| Company T |
CA0000000020 |
A12 |
Absolute |
Revenue |
S1+S2 |
100 |
0.416 |
2009 |
2009 |
2020 |
0.68 |
Underway |
short |
test |
28400000 |
28400000 |
66682 |
18472 |
0.055325267 |
22005.06 |
15403.542 |
62681.08 |
60680.62 |
1 |
One line of the data_test_temperature_score.csv file
Here the end_year is 2020. If we go into
def get_annual_reduction_rate(self, target: pd.Series) -> Optional[float]:
"""
Get the annual reduction rate (or None if not available).
:param target: The target as a row of a dataframe
:return: The annual reduction
"""
# 2022-09-01 Bloomberg pointed out need for additional checks in input
# Here is the original code:
# if pd.isnull(target[self.c.COLS.REDUCTION_AMBITION]):
# return None
# try:
# return target[self.c.COLS.REDUCTION_AMBITION] / float(
# target[self.c.COLS.END_YEAR] - target[self.c.COLS.BASE_YEAR]
# )
# except ZeroDivisionError:
# raise ValueError(
# "Couldn't calculate the annual reduction rate because the start and target year are the "
# "same"
# )
# Bloombergs proposal - changed 2022-09-01
check = pd.isnull(target[self.c.COLS.REDUCTION_AMBITION])
check = check or pd.isnull(target[self.c.COLS.END_YEAR])
check = check or pd.isnull(target[self.c.COLS.BASE_YEAR])
check = check or (target[self.c.COLS.END_YEAR] <= target[self.c.COLS.BASE_YEAR])
# add check that target is not too old
check = check or (target[self.c.COLS.END_YEAR] < datetime.datetime.now().year)
if check:
return None
return target[self.c.COLS.REDUCTION_AMBITION] / float(
target[self.c.COLS.END_YEAR] - target[self.c.COLS.BASE_YEAR]
)
# End of BBGs code
We see that the last check puts NaN into self.c.COLS.ANNUAL_REDUCTION_RATE, thus giving a final temperature of 3.2, whereas in the test we find:
scores = self.temperature_score.calculate(self.data)
self.assertAlmostEqual(
scores[
(scores["company_name"] == "Company T")
& (scores["scope"] == EScope.S1S2)
]["temperature_score"].iloc[0],
1.77,
places=2,
msg="The temp score was incorrect",
)
1.77 :)
Hi!
Thanks a lot for this great library :). I was using the latest github version but noticed that the test suite is broken. Maybe it could be good to add a github workflow running the test suite? Or at least to fix the test/code to show the correct intent :).
One of the cases I have in mind is (It's not the only one that needs fixing if I am not mistaken)
One line of the
data_test_temperature_score.csvfileHere the
end_yearis 2020. If we go intoWe see that the last check puts
NaNintoself.c.COLS.ANNUAL_REDUCTION_RATE, thus giving a final temperature of 3.2, whereas in the test we find:1.77 :)