Skip to content

Commit

Permalink
Attempt at fixing float issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JMGilbert committed Aug 23, 2022
1 parent cba401c commit 4adfb60
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/dscim/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def compute_damages(anomaly, betas, formula):
-------
xr.DataArray with damages
"""

anomaly = anomaly.astype(np.float64)
# Parse formula to calculate damages
if (
formula
Expand Down Expand Up @@ -585,16 +585,14 @@ def compute_damages(anomaly, betas, formula):
anomaly.temperature, 2
)
elif (
formula
== "damages ~ -1 + anomaly + np.power(anomaly, 2) + gmsl + np.power(gmsl, 2)"
formula == "damages ~ -1 + anomaly + np.power(anomaly, 2) + gmsl + np.power(gmsl, 2)"
):

damages_fair = (
betas["anomaly"] * anomaly.temperature
+ betas["np.power(anomaly, 2)"] * np.power(anomaly.temperature, 2)
+ betas["gmsl"] * anomaly.gmsl
+ betas["np.power(gmsl, 2)"] * np.power(anomaly.gmsl, 2)
).round(3)
)
elif (
formula == "damages ~ anomaly + np.power(anomaly, 2) + gmsl + np.power(gmsl, 2)"
):
Expand Down

0 comments on commit 4adfb60

Please sign in to comment.