Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyeZrYn6ryNcSe5Y2Y
128 lines
4.5 KiB
Python
128 lines
4.5 KiB
Python
"""Conditional dasha families in full reading and the time-system table."""
|
||
|
||
from __future__ import annotations
|
||
|
||
from pathlib import Path
|
||
|
||
from scripts.jyotish_engine import cmd_full_reading, render_pl9_markdown, _native_dasha_master_families
|
||
from scripts.professional_report_reference import _export_args
|
||
from tests.test_report_longform_parity import _producer_packet
|
||
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
BASELINE = (ROOT / "tests/golden/upstream_sync2/pl9_time_system_table.baseline.md").read_text(encoding="utf-8")
|
||
|
||
EINSTEIN = {
|
||
"year": 1879,
|
||
"month": 3,
|
||
"day": 14,
|
||
"hour": 11,
|
||
"minute": 30,
|
||
"second": 0,
|
||
"lat": 48.4,
|
||
"lon": 9.98,
|
||
"tz": 0.89,
|
||
"ayanamsa": "raman",
|
||
"node_mode": "mean",
|
||
}
|
||
|
||
CONDITIONAL_KEYS = (
|
||
"tribhagi_dasha",
|
||
"tribhagi_40_dasha",
|
||
"shodashottari_dasha",
|
||
"dwadashottari_dasha",
|
||
"dwisaptatisama_dasha",
|
||
"shattrimshatsama_dasha",
|
||
"panchottari_dasha",
|
||
"satabdika_dasha",
|
||
"chaturshitisama_dasha",
|
||
"shastihayani_dasha",
|
||
)
|
||
|
||
NEW_TABLE_LABELS = (
|
||
"Tribhagi",
|
||
"Tribhagi 40",
|
||
"Shodashottari",
|
||
"Dwadashottari",
|
||
"Dwisaptatisama",
|
||
"Shastihayani",
|
||
"Shattrimshatsama",
|
||
"Panchottari",
|
||
"Satabdika",
|
||
"Chaturshitisama",
|
||
)
|
||
|
||
|
||
def _table_data_rows(markdown: str) -> list[str]:
|
||
lines = markdown.splitlines()
|
||
start = next(i for i, line in enumerate(lines) if line.strip() == "#### 时间系统证据状态")
|
||
rows = []
|
||
for line in lines[start + 3 :]:
|
||
if not line.startswith("|"):
|
||
break
|
||
if line.startswith("|------"):
|
||
continue
|
||
if line.startswith("| 系统 |"):
|
||
continue
|
||
rows.append(line)
|
||
return rows
|
||
|
||
|
||
def test_einstein_full_reading_exposes_ten_conditional_dasha_modules() -> None:
|
||
report = cmd_full_reading(_export_args(EINSTEIN))
|
||
modules = report.get("modules") if isinstance(report.get("modules"), dict) else {}
|
||
for key in CONDITIONAL_KEYS:
|
||
payload = modules.get(key)
|
||
assert isinstance(payload, dict), key
|
||
has_periods = isinstance(payload.get("periods"), list) or isinstance(payload.get("major"), list)
|
||
status = str(payload.get("execution_status") or payload.get("status") or "")
|
||
assert has_periods or status in {"not_applicable", "blocked"} or payload.get("error"), key
|
||
|
||
markdown = render_pl9_markdown(_producer_packet({
|
||
"timing_and_predictive_systems": {
|
||
"dasha": modules.get("dasha"),
|
||
"narayana_dasha": modules.get("narayana_dasha"),
|
||
"yogini_dasha": modules.get("yogini_dasha"),
|
||
"ashtottari_dasha": modules.get("ashtottari_dasha"),
|
||
"kalachakra_dasha": modules.get("kalachakra_dasha"),
|
||
**{key: modules.get(key) for key in CONDITIONAL_KEYS},
|
||
"dasha_master_pack": {
|
||
"schema": "dasha_master_report_pack_v1",
|
||
"families": _native_dasha_master_families(modules),
|
||
},
|
||
"annual_tajika_pack": {"year_lord": {"status": "partial_verified"}},
|
||
},
|
||
}))
|
||
rows = _table_data_rows(markdown)
|
||
original = [
|
||
line for line in BASELINE.splitlines()
|
||
if line.startswith("| ")
|
||
and not line.startswith("| 系统 |")
|
||
and "| Year Lord |" not in line
|
||
]
|
||
# 原值: rows[:5] == original(Ashtottari 行为 executed / 本地候选规则)
|
||
# 新值: 其余四行不变;Ashtottari 行按 BPHS 罗睺条件判为 not_applicable 并写本盘情况
|
||
# 原因: BUG-1676,占星师 2026-11-07 裁定 Ashtottari 生产口径(这张公开盘罗睺在上升主星起算第 11 位)
|
||
assert [row for row in rows[:5] if not row.startswith("| Ashtottari |")] == [
|
||
row for row in original[:5] if not row.startswith("| Ashtottari |")]
|
||
ashtottari_row = next(row for row in rows[:5] if row.startswith("| Ashtottari |"))
|
||
assert ashtottari_row.startswith("| Ashtottari | not_applicable | — | 不满足 BPHS 条件:")
|
||
for label in NEW_TABLE_LABELS:
|
||
assert any(f"| {label} |" in line for line in rows)
|
||
assert any("| Year Lord |" in line for line in rows)
|
||
assert len(rows) >= 15
|
||
|
||
|
||
def test_calc_dasa_convergence_call_is_unchanged() -> None:
|
||
text = (ROOT / "scripts/jyotish_engine.py").read_text(encoding="utf-8")
|
||
needle = """ convergence = _calc_dasa_convergence(
|
||
dasha_data,
|
||
chara_dasha_data,
|
||
yogini_data,
|
||
planet_lons,
|
||
asc_idx,
|
||
ashtottari_result=ashtottari_data,
|
||
kalachakra_result=kalachakra_data,
|
||
)"""
|
||
assert needle in text
|