@@ -55,7 +55,7 @@ def get_legacy(sector, filepath, scale):
5555 coefs = temps .join (coefs ).reset_index ().rename (columns = {"index" : "year" })
5656
5757 # Predict y_hat
58- coefs [f "y_hat" ] = (
58+ coefs ["y_hat" ] = (
5959 coefs .cons + coefs .anomaly * coefs .beta_1 + coefs .anomaly ** 2 * coefs .beta_2
6060 )
6161
@@ -136,7 +136,7 @@ def damage_function(
136136 )
137137
138138 # subset
139- if subset_dict != None :
139+ if subset_dict is not None :
140140 for col , val in subset_dict .items ():
141141 points_file = points_file .loc [points_file [col ].isin (val )]
142142 fit_file = fit_file .sel (subset_dict )
@@ -174,7 +174,7 @@ def damage_function(
174174 )
175175
176176 # grab legacy function if passed
177- if legacy != None :
177+ if legacy is not None :
178178 fit ["legacy" ] = get_legacy (sector , filepath = legacy [0 ], scale = legacy [1 ])
179179 fit ["legacy" ] = fit ["legacy" ].loc [fit ["legacy" ].year == year ]
180180 fit ["legacy" ]["y_hat_scaled" ] = fit ["legacy" ]["y_hat" ].apply (
@@ -195,7 +195,7 @@ def damage_function(
195195
196196 print (f"{ recipe } : # of points is { len (points [recipe ])} " )
197197
198- if scatter == True :
198+ if scatter :
199199
200200 sns .scatterplot (
201201 data = points [recipe ]
@@ -207,7 +207,7 @@ def damage_function(
207207 ]
208208 .sort_values ("hue" ),
209209 x = x_var ,
210- y = f "damages_scaled" ,
210+ y = "damages_scaled" ,
211211 hue = "hue" ,
212212 palette = palette ,
213213 s = 6 ,
@@ -230,7 +230,7 @@ def damage_function(
230230 ax = ax [0 ][i ],
231231 )
232232
233- if legacy != None :
233+ if legacy is not None :
234234
235235 sns .lineplot (
236236 data = fit ["legacy" ],
@@ -243,19 +243,19 @@ def damage_function(
243243
244244 ax [0 ][i ].set_xlabel (x_var )
245245 ax [0 ][i ].set_title (f"Recipe: { recipe } " )
246- if attributes == True :
246+ if attributes :
247247 ax [0 ][i ].annotate (
248248 attrs [recipe ], (0.0 , - 0.1 ), xycoords = "axes fraction" , fontsize = 6
249249 )
250250
251- ltext = "\n paper damage function = grey dotted" if legacy != None else ""
251+ ltext = "\n paper damage function = grey dotted" if legacy is not None else ""
252252 fig .suptitle (
253253 f"{ sector } : { discounting } discounting \n Damage functions in { year } { ltext } "
254254 )
255255
256256 ax [0 ][0 ].set_ylabel (f'Damages in { "{:.0e}" .format (scale )} 2019 USD' )
257257
258- if save_path != None :
258+ if save_path is not None :
259259
260260 os .makedirs (save_path , exist_ok = True )
261261 plt .savefig (f"{ save_path } /{ sector } _{ discounting } _{ year } _damage_function.pdf" )
0 commit comments