Core: coding rules as declarative form.yaml + Python package (atlas.coding) (#9)
Step 1 of moving the repo to Python with declarative rules. - core/spec/form.yaml: every question (how it is found in an export), every answer and what it is coded as, missing answers, email redaction, burn order, first-dragon pools. - core/atlas/coding.py reads it and replaces core/python/clean.py (python -m atlas.coding). - tests/core/test_coding.py: 16 rule tests, one hand-written row per rule, checking the rules are right rather than only that JS and Python agree. - analysis/stats/analyze.py takes the colours and missing answers from the spec instead of its own copy; the daily update job codes rows through the package. - pyproject.toml for the package; pyyaml and pytest added to requirements. The coded runs are byte-identical to before (5,988 runs); all parity checks still match. Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
432e04c2c7
commit
3536007ade
@@ -14,14 +14,8 @@ import pandas as pd
|
||||
|
||||
from stats_core import Z95, bh, logistic_ridge, odds_ratio, p_from_z, wilson
|
||||
|
||||
COLORS = ["Red", "Green", "Orange", "Brown", "Blue", "Black"]
|
||||
# answers with no information about the choice: treated as missing everywhere (mirrors MISSING in engine.js)
|
||||
MISSING = {"Unknown", "Unsure", "Unsure/unknown", "Multiple", "(not recorded)", "(not asked)",
|
||||
"(not asked/blank)", "Unknown/lost count", "Blank/not asked"}
|
||||
|
||||
|
||||
def is_missing(v):
|
||||
return v is None or (isinstance(v, float) and v != v) or v == "" or v in MISSING
|
||||
# colours and the answers that count as missing come from core/spec/form.yaml, like everything else
|
||||
from atlas.coding import COLORS, MISSING, is_missing # noqa: E402
|
||||
FACTORS = ["company", "direction", "first_sighting", "scream", "resolution", "combat_first",
|
||||
"post_path", "hour", "wing", "squad", "attempt_group", "source", "goal", "sighting_action", "combat_second", "malek_intent"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user