test(tradein): estimator pure-helper unit tests + fix None crash in _filter_outliers (#580) #640

Merged
Light1YT merged 1 commit from test/580-estimator-pure-units into main 2026-05-29 08:24:19 +00:00
Owner

Summary

Closes #580 (estimator IQR/confidence/fallback coverage).

1. Latent crash fix in _filter_outliers (Tukey IQR filter, estimate path). lot.get("price_per_m2", 0) returns its 0 default only when the key is ABSENT; for a present-but-None value (listings.price_per_m2 is nullable) it returns None -> low <= None <= high raises TypeError, crashing the estimate. Now None-safe: unpriced lots kept, priced lots still filtered. Behavior byte-identical for all real prices (incl. 0) — verified by code-reviewer re-running old vs new. Latent (prod has 0 NULL price_per_m2 now, but column nullable -> future-reachable).

2. 23 pure unit tests (test_estimator_pure_units.py) for _percentile, _filter_outliers (incl. None regression that fails on old code), _compute_confidence (thresholds, concentration downgrade, fallback notes, listings=None).

code-reviewer: approve, no blockers.

Test plan

  • 48 tests pass (23 new + cohort + repair_coef regression), ruff clean, py_compile clean

Closes #580

## Summary Closes #580 (estimator IQR/confidence/fallback coverage). **1. Latent crash fix** in `_filter_outliers` (Tukey IQR filter, estimate path). `lot.get("price_per_m2", 0)` returns its 0 default only when the key is ABSENT; for a present-but-None value (listings.price_per_m2 is nullable) it returns None -> `low <= None <= high` raises TypeError, crashing the estimate. Now None-safe: unpriced lots kept, priced lots still filtered. Behavior byte-identical for all real prices (incl. 0) — verified by code-reviewer re-running old vs new. Latent (prod has 0 NULL price_per_m2 now, but column nullable -> future-reachable). **2. 23 pure unit tests** (test_estimator_pure_units.py) for _percentile, _filter_outliers (incl. None regression that fails on old code), _compute_confidence (thresholds, concentration downgrade, fallback notes, listings=None). code-reviewer: approve, no blockers. ## Test plan - [x] 48 tests pass (23 new + cohort + repair_coef regression), ruff clean, py_compile clean Closes #580
Light1YT added 1 commit 2026-05-29 08:23:40 +00:00
_filter_outliers used lot.get("price_per_m2", 0), whose default only applies
when the key is absent; a present-but-None value (listings.price_per_m2 is
nullable) leaked into `low <= None <= high` → TypeError, crashing the estimate.
Make the bounds check None-safe: keep unpriced lots, still drop genuine priced
outliers. Behavior byte-identical for all real prices (incl. 0).

Add tests/test_estimator_pure_units.py (23 tests) covering _percentile,
_filter_outliers (incl. the None regression) and _compute_confidence
(thresholds, concentration downgrade, fallback notes).

Closes #580
Light1YT merged commit e4b5f14939 into main 2026-05-29 08:24:19 +00:00
Light1YT deleted branch test/580-estimator-pure-units 2026-05-29 08:24:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#640
No description provided.