Skip to content

Commit 400577a

Browse files
author
Sigrid Tofte Thiis
committed
fixed drift
1 parent 2a98db6 commit 400577a

10 files changed

Lines changed: 29 additions & 17 deletions

File tree

.venv/Lib/site-packages/__editable___loop_algorithm_to_python_adaptive_0_0_1_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class _EditableFinder: # MetaPathFinder
1515
@classmethod
16-
def find_spec(cls, fullname: str, path=None, target=None) -> ModuleSpec | None: # type: ignore
16+
def find_spec(cls, fullname: str, _path=None, _target=None) -> ModuleSpec | None:
1717
# Top-level packages and modules (we know these exist in the FS)
1818
if fullname in MAPPING:
1919
pkg_path = MAPPING[fullname]
@@ -59,7 +59,7 @@ def _paths(cls, fullname: str) -> list[str]:
5959
return [*paths, PATH_PLACEHOLDER]
6060

6161
@classmethod
62-
def find_spec(cls, fullname: str, target=None) -> ModuleSpec | None: # type: ignore
62+
def find_spec(cls, fullname: str, _target=None) -> ModuleSpec | None:
6363
if fullname in NAMESPACES:
6464
spec = ModuleSpec(fullname, None, is_package=True)
6565
spec.submodule_search_locations = cls._paths(fullname)
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
Metadata-Version: 2.4
1+
Metadata-Version: 2.1
22
Name: loop-algorithm-to-python-adaptive
33
Version: 0.0.1
44
Summary: Adaptive wrapper around loop_to_python_api; currently backed by Sigridtt/LoopAlgorithmToPython.
55
Requires-Python: >=3.10
6-
Requires-Dist: loop_to_python_api @ git+https://github.com/Sigridtt/LoopAlgorithmToPython.git@main
7-
Dynamic: requires-dist
8-
Dynamic: requires-python
9-
Dynamic: summary
6+
Requires-Dist: loop-to-python-api @ git+https://github.com/Sigridtt/LoopAlgorithmToPython.git@main
7+
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
__editable__.loop_algorithm_to_python_adaptive-0.0.1.pth,sha256=NLHFYcF1BYwgg8E0qHlcpxY3gaBQP5nqM473fvzFzWg,137
2-
__editable___loop_algorithm_to_python_adaptive_0_0_1_finder.py,sha256=PtEbSIGcwcyEC7o4zye2JxgUY5hh5uQBTrH3jOZsxx0,3488
2+
__editable___loop_algorithm_to_python_adaptive_0_0_1_finder.py,sha256=ntv3GaHlThcDfsqj07VCmjvm7_Wq-2bc2401L25LgZ8,3459
33
__pycache__/__editable___loop_algorithm_to_python_adaptive_0_0_1_finder.cpython-310.pyc,,
44
loop_algorithm_to_python_adaptive-0.0.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
5-
loop_algorithm_to_python_adaptive-0.0.1.dist-info/METADATA,sha256=p-K0zbktXM0eL6QpOdidSj_1zLXWe_CeJ75T5_7F5PQ,379
5+
loop_algorithm_to_python_adaptive-0.0.1.dist-info/METADATA,sha256=FJ0Cg-f533SwuqzC-3w8C09eAVJSMiLK_4ONhqkqAaM,313
66
loop_algorithm_to_python_adaptive-0.0.1.dist-info/RECORD,,
77
loop_algorithm_to_python_adaptive-0.0.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8-
loop_algorithm_to_python_adaptive-0.0.1.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
8+
loop_algorithm_to_python_adaptive-0.0.1.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
99
loop_algorithm_to_python_adaptive-0.0.1.dist-info/direct_url.json,sha256=j2jQexxlR_yrauPWl0SLW8l25_1T8b_H4sHDctuVMVI,116
1010
loop_algorithm_to_python_adaptive-0.0.1.dist-info/top_level.txt,sha256=p951YDFEMeriNiVzWVyr4CZDv9BG_ycPUjuk8d-MOmo,24
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Wheel-Version: 1.0
2-
Generator: setuptools (82.0.0)
2+
Generator: setuptools (70.3.0)
33
Root-Is-Purelib: true
44
Tag: py3-none-any
55

514 Bytes
Binary file not shown.
66 Bytes
Binary file not shown.
Binary file not shown.

loop_to_python_adaptive/autotune_isf.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from typing import Any, Optional
2121

2222
import numpy as np
23-
23+
from loop_to_python_adaptive.autotune_prep import (AutotunePrepConfig, prepare_for_autotune_isf, )
2424

2525
@dataclass(frozen=True)
2626
class AutotuneISFConfig:
@@ -251,6 +251,8 @@ def run_autotune_isf_iterations(
251251
df_windows: list, # list of pd.DataFrames, one per day
252252
*,
253253
loop_algorithm_inputs: list[dict], # one per window, aligned with df_windows
254+
pump_isf: float | None = None, # original pump ISF, never changes
255+
isf_current: float | None = None, # yesterday's tuned ISF, carries forward
254256
n_iterations: int = 1, # number of passes
255257
cfg: AutotuneISFConfig = AutotuneISFConfig(),
256258
json_history_list: list[list[dict]] | None = None,
@@ -279,14 +281,17 @@ def run_autotune_isf_iterations(
279281
isf_history : List of ISF values after each iteration (length = n_iterations).
280282
last_result : Full result dict from the final tune_isf() call.
281283
"""
282-
from loop_to_python_adaptive.autotune_prep import (
283-
AutotunePrepConfig,
284-
prepare_for_autotune_isf,
285-
)
286-
pump_isf = extract_pump_isf(loop_algorithm_inputs[0])
284+
285+
# pump_isf is the unchanging anchor for safety caps
286+
if pump_isf is None:
287+
pump_isf = extract_pump_isf(loop_algorithm_inputs[0])
287288
pump_basal = extract_pump_basal(loop_algorithm_inputs[0])
288289
pump_cr = extract_pump_cr(loop_algorithm_inputs[0])
289290

291+
# isf_current is what we tune from — starts at pump_isf on day 1
292+
if isf_current is None:
293+
isf_current = pump_isf
294+
290295
isf_current = pump_isf
291296
isf_history: list[float] = []
292297
last_result: dict[str, Any] = {}
@@ -313,6 +318,10 @@ def run_autotune_isf_iterations(
313318
if json_history_list is not None and i < len(json_history_list)
314319
else None
315320
)
321+
carb_entries = loop_input.get("carbEntries", [])
322+
print(f" carb entries in loop_input: {len(carb_entries)}")
323+
if carb_entries:
324+
print(f" first: {carb_entries[0]}")
316325
result = prepare_for_autotune_isf(
317326
df_window,
318327
loop_algorithm_input=loop_input,
@@ -322,6 +331,7 @@ def run_autotune_isf_iterations(
322331
window_isf_points = result["ISFGlucoseData"]
323332
all_isf_points.extend(window_isf_points)
324333
print(f"{len(window_isf_points)} ISF points")
334+
print(f" CSF={len(result['CSFGlucoseData'])} ISF={len(result['ISFGlucoseData'])} basal={len(result['basalGlucoseData'])} UAM={len(result['UAMGlucoseData'])}")
325335

326336
print(f" Total ISF points this iteration: {len(all_isf_points)}")
327337

loop_to_python_adaptive/loop_oref_mapping.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ def generate_bgi_series_from_predictions(
139139
- It is consistent with oref0's intent (BGI = expected BG change per 5min
140140
from insulin alone)
141141
"""
142+
# In generate_bgi_series_from_predictions, add this as the first line after `out = _to_utc_index(df)`:
143+
142144
out = _to_utc_index(df)
145+
if not json_history:
146+
return pd.Series(float("nan"), index=out.index, dtype="float64")
143147

144148
bgi_points: dict[pd.Timestamp, float] = {}
145149

0 commit comments

Comments
 (0)