@@ -176,8 +176,9 @@ def get_observed_motions(flatfile: pd.DataFrame, imts: Container[str], log=True)
176176
177177
178178def yield_event_contexts (flatfile : pd .DataFrame ) -> Iterable [EventContext ]:
179- """Group the flatfile by events, and yield `EventContext`s objects, one for each event"""
180-
179+ """
180+ Group the flatfile by events, and yield `EventContext`s objects, one for each event
181+ """
181182 # check event id column or use the event location to group events:
182183 # group flatfile by events. Use ev. id (_EVENT_COLUMNS[0]) or, when
183184 # no ID found, event spatio-temporal coordinates (_EVENT_COLUMNS[1:])
@@ -270,8 +271,11 @@ def get_expected_motions(
270271 columns .extend ((i , Clabel .intra_ev_std , gsim_name ) for i in imt_names )
271272 data .append (intra )
272273
273- return pd .DataFrame (columns = pd .MultiIndex .from_tuples (columns ),
274- data = np .hstack (data ), index = ctx .sids )
274+ return pd .DataFrame (
275+ columns = pd .MultiIndex .from_tuples (columns ),
276+ data = np .hstack (data ),
277+ index = ctx .sids
278+ )
275279
276280
277281def get_residuals_from_expected_and_observed_motions (
@@ -332,8 +336,9 @@ def _get_random_effects_residuals(obs, mean, inter, intra, normalise=True):
332336 # TODO this is the only part where grouping by event is relevant: maybe
333337 # move groupby here?
334338 nvals = float (len (mean ))
335- inter_res = ((inter ** 2. ) * sum (obs - mean )) / \
336- (nvals * (inter ** 2. ) + (intra ** 2. ))
339+ inter_res = (
340+ ((inter ** 2. ) * sum (obs - mean )) / (nvals * (inter ** 2. ) + (intra ** 2. ))
341+ )
337342 intra_res = obs - (mean + inter_res )
338343 if normalise :
339344 return inter_res / inter , intra_res / intra
@@ -370,7 +375,8 @@ def get_residuals_likelihood(residuals: pd.DataFrame, inplace=True) -> pd.DataFr
370375
371376def get_likelihood (values : Union [np .ndarray , pd .Series ]) -> Union [np .ndarray , pd .Series ]:
372377 """
373- Return the likelihood of the given values according to Equation 9 of Scherbaum et al. (2004)
378+ Return the likelihood of the given values according to
379+ Equation 9 of Scherbaum et al. (2004)
374380 """
375381 zvals = np .fabs (values )
376382 return 1.0 - erf (zvals / sqrt (2. ))
@@ -554,7 +560,7 @@ def get_required_ground_motion_properties(
554560 for p in required_props :
555561 try :
556562 # https://stackoverflow.com/a/29706954
557- # `required_props_flatfile` is a dataframe with a specific index (see above) .
563+ # `required_props_flatfile` is a dataframe with a specific index.
558564 # Adding a Series to it might result in NaNs where the Series index
559565 # does not match the DataFrame index. As such, assign the series.values to
560566 # the DataFrame (see test_residuals.test_assign_series to assure this is ok)
0 commit comments