Skip to content

Commit 74e0ca0

Browse files
committed
lint
1 parent 05655c4 commit 74e0ca0

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

incline/gaussian_process.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,7 @@ def adaptive_gp_trend(
418418
if np.any(valid_mask):
419419
for arr in [smoothed_values, derivatives, ci_lower, ci_upper]:
420420
if np.any(~np.isnan(arr)):
421-
arr[:] = (
422-
pd.Series(arr).interpolate().bfill().ffill().values
423-
)
421+
arr[:] = pd.Series(arr).interpolate().bfill().ffill().values
424422

425423
# Create output dataframe
426424
odf = df.copy()

incline/multiscale.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ def _estimate_derivatives_at_bandwidth(
114114
df_temp["time"] = x
115115
result = loess_trend(df_temp, time_column="time", frac=bandwidth)
116116

117-
derivatives = np.asarray(result["derivative_value"].values, dtype=np.float64)
117+
derivatives = np.asarray(
118+
result["derivative_value"].values, dtype=np.float64
119+
)
118120
# Approximate standard errors from residuals
119-
residuals = y - np.asarray(result["smoothed_value"].values, dtype=np.float64)
121+
residuals = y - np.asarray(
122+
result["smoothed_value"].values, dtype=np.float64
123+
)
120124
residual_std = np.std(residuals)
121125
std_errors = np.full(n, residual_std / np.sqrt(max(1, bandwidth * n)))
122126

@@ -140,11 +144,15 @@ def _estimate_derivatives_at_bandwidth(
140144
df_temp, time_column="time", length_scale=bandwidth * np.ptp(x)
141145
)
142146

143-
derivatives = np.asarray(result["derivative_value"].values, dtype=np.float64)
147+
derivatives = np.asarray(
148+
result["derivative_value"].values, dtype=np.float64
149+
)
144150
# Use GP uncertainty
145151
ci_width = result["derivative_ci_upper"] - result["derivative_ci_lower"]
146152
if HAS_SCIPY_STATS and norm is not None:
147-
std_errors = np.asarray(ci_width / (2 * norm.ppf(0.975)), dtype=np.float64)
153+
std_errors = np.asarray(
154+
ci_width / (2 * norm.ppf(0.975)), dtype=np.float64
155+
)
148156
else:
149157
std_errors = np.asarray(ci_width / 3.92, dtype=np.float64)
150158

@@ -166,9 +174,13 @@ def _estimate_derivatives_at_bandwidth(
166174
df_temp["time"] = x
167175
result = spline_trend(df_temp, time_column="time", s=s)
168176

169-
derivatives = np.asarray(result["derivative_value"].values, dtype=np.float64)
177+
derivatives = np.asarray(
178+
result["derivative_value"].values, dtype=np.float64
179+
)
170180
# Approximate standard errors
171-
residuals = y - np.asarray(result["smoothed_value"].values, dtype=np.float64)
181+
residuals = y - np.asarray(
182+
result["smoothed_value"].values, dtype=np.float64
183+
)
172184
residual_std = np.std(residuals)
173185
std_errors = np.full(n, residual_std * np.sqrt(bandwidth))
174186

@@ -302,7 +314,9 @@ def fit(
302314
def _compute_significance_map(self, bandwidths: npt.NDArray[np.float64]) -> None:
303315
"""Compute significance classification for each (x, bandwidth) pair."""
304316
if self.derivative_estimates is None or self.derivative_se is None:
305-
raise ValueError("derivative_estimates and derivative_se must be set before computing significance map")
317+
raise ValueError(
318+
"derivative_estimates and derivative_se must be set before computing significance map"
319+
)
306320

307321
deriv_est = self.derivative_estimates
308322
deriv_se = self.derivative_se
@@ -394,7 +408,10 @@ def find_significant_features(
394408
raise ValueError("Must fit SiZer before finding features")
395409

396410
x_values = self.x_values
397-
features: dict[str, list[tuple[Any, Any]]] = {"increasing": [], "decreasing": []}
411+
features: dict[str, list[tuple[Any, Any]]] = {
412+
"increasing": [],
413+
"decreasing": [],
414+
}
398415

399416
# For each x location, check if there's persistent significance
400417
for j in range(len(x_values)):

0 commit comments

Comments
 (0)