Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
488 changes: 15 additions & 473 deletions docs/tutorial/analysis.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/tutorial/plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
" N,\n",
" model_family=\"all\", # Include mechanistic, phenomenological, and non-parametric\n",
" phase_boundary_method=\"tangent\", # tangent or threshold\n",
" spline_s=0.2,\n",
" spline=0.2,\n",
" window_points=7,\n",
")\n",
"\n",
Expand Down Expand Up @@ -245,7 +245,7 @@
" N,\n",
" model_family=\"all\", # Include mechanistic, phenomenological, and non-parametric\n",
" phase_boundary_method=\"tangent\", # tangent or threshold\n",
" spline_s=0.2,\n",
" spline=0.2,\n",
" window_points=7,\n",
")\n",
"\n",
Expand Down Expand Up @@ -325,7 +325,7 @@
"source": [
"# Phase boundary comparison on spline fit\n",
"fit_spline = gc.non_parametric.fit_non_parametric(\n",
" t, N, method=\"spline\", spline_s=0.2, window_points=7\n",
" t, N, method=\"spline\", spline=0.2, window_points=7\n",
")\n",
"\n",
"phase_boundary_rows = []\n",
Expand Down
8 changes: 7 additions & 1 deletion src/growthcurves/non_parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
All methods operate in linear OD space (not log-transformed).
"""

from logging import getLogger

import numpy as np
from scipy.interpolate import make_smoothing_spline
from scipy.stats import theilslopes

from .inference import bad_fit_stats

logger = getLogger(__name__)

# Default settings for the auto-spline (sigma-based smoothing + OD weights).
_SPLINE_SMOOTH_MULT = 5.0
_SPLINE_GCV_WEIGHT_FLOOR_Q = 0.15
Expand All @@ -27,7 +31,7 @@
# -----------------------------------------------------------------------------


def fit_sliding_window(t, N, window_points=15, step=None, n_fits=None):
def fit_sliding_window(t, N, window_points=15, step=None, n_fits=None, **kwargs):
"""
Calculate maximum specific growth rate using the sliding window method.

Expand All @@ -54,6 +58,8 @@ def fit_sliding_window(t, N, window_points=15, step=None, n_fits=None):
Returns None if calculation fails.

"""
if kwargs:
logger.warning("fit_sliding_window received unused kwargs: %s", kwargs)
if len(t) < window_points or np.ptp(t) <= 0:
return None

Expand Down