Fix pre-existing test failures in test_writer and test_metrics
test_writer: _dummy_metrics() and test_build_summary_required_fields were missing np_power_w=None after the field was added to ComputedMetrics. test_metrics: the leading-zero elevation heuristic fired on a single 0.0 start value, incorrectly skipping the first legitimate elevation step. Guard now requires at least 2 consecutive near-zero leading values before activating the Apple Watch lock-acquisition workaround.
This commit is contained in:
@@ -377,16 +377,21 @@ def _elevation(
|
|||||||
|
|
||||||
# Some devices (e.g. Apple Watch) record exactly 0.0 for the initial samples
|
# Some devices (e.g. Apple Watch) record exactly 0.0 for the initial samples
|
||||||
# while waiting for barometric/GPS lock, then jump to the real altitude.
|
# while waiting for barometric/GPS lock, then jump to the real altitude.
|
||||||
# Detect this by checking for a leading near-zero run followed by a large
|
# Only activate when there are at least 2 consecutive near-zero leading
|
||||||
# jump: skip those zeros and seed the accumulator from the first real value.
|
# values — a single 0.0 is a legitimate sea-level starting point.
|
||||||
# Safety: if the activity genuinely stays near sea level, no value in the
|
|
||||||
# series will exceed `threshold`, so `start` stays 0 — unchanged behaviour.
|
|
||||||
start = 0
|
start = 0
|
||||||
if abs(elevations[0]) < 0.5:
|
if abs(elevations[0]) < 0.5:
|
||||||
for i, e in enumerate(elevations):
|
n_leading = 0
|
||||||
if abs(e) > threshold:
|
for e in elevations:
|
||||||
start = i
|
if abs(e) < 0.5:
|
||||||
|
n_leading += 1
|
||||||
|
else:
|
||||||
break
|
break
|
||||||
|
if n_leading > 1:
|
||||||
|
for i, e in enumerate(elevations):
|
||||||
|
if abs(e) > threshold:
|
||||||
|
start = i
|
||||||
|
break
|
||||||
|
|
||||||
gain = loss = 0.0
|
gain = loss = 0.0
|
||||||
committed = elevations[start]
|
committed = elevations[start]
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ def _dummy_metrics(**overrides):
|
|||||||
elevation_gain_m=100.0, elevation_loss_m=95.0,
|
elevation_gain_m=100.0, elevation_loss_m=95.0,
|
||||||
avg_speed_kmh=10.0, max_speed_kmh=20.0,
|
avg_speed_kmh=10.0, max_speed_kmh=20.0,
|
||||||
avg_hr_bpm=None, max_hr_bpm=None,
|
avg_hr_bpm=None, max_hr_bpm=None,
|
||||||
avg_cadence_rpm=None, avg_power_w=None, max_power_w=None,
|
avg_cadence_rpm=None, avg_power_w=None, np_power_w=None, max_power_w=None,
|
||||||
bbox=None, start_latlng=None, end_latlng=None,
|
bbox=None, start_latlng=None, end_latlng=None,
|
||||||
mmp=None, best_efforts=None, best_climb_m=None,
|
mmp=None, best_efforts=None, best_climb_m=None,
|
||||||
)
|
)
|
||||||
@@ -208,6 +208,7 @@ def test_build_summary_required_fields():
|
|||||||
max_hr_bpm=None,
|
max_hr_bpm=None,
|
||||||
avg_cadence_rpm=None,
|
avg_cadence_rpm=None,
|
||||||
avg_power_w=None,
|
avg_power_w=None,
|
||||||
|
np_power_w=None,
|
||||||
max_power_w=None,
|
max_power_w=None,
|
||||||
bbox=None,
|
bbox=None,
|
||||||
start_latlng=None,
|
start_latlng=None,
|
||||||
|
|||||||
Reference in New Issue
Block a user