- 2364 KP sub-lord in the Nakshatra Reference: proportional, not equal ninths (upstream calc_sub_lord) - 2365 birth-time sensitivity KP cusps: Placidus + Krishnamurti, same source as the formal KP table - 2366 expression paths: D2/D11/D24/D4 house counted from the varga's own ascendant - 2367 Bhavesh table: PD-only lord labelled, not "Yes", when the PD range is not stable - 2368 KP cusp table: very strong significator is a lead, not a promise - 2369 yoga wording: no blanket "cancellation not checked"; detector match is not "conditions hold" - 2370 Neecha self-reference marked per condition - 2371 reading guide: feedback only in rectification; all applicable systems, two dashas minimum - 2372 audit table: progress/index rows are observation only - 2373 Saptavargaja by chart - 2374 Manahoo interferer never one of the pair (upstream 322e2f30) - 2375 KP monthly table seeded under the KP profile (owner-approved frozen-file edit) + profile line - 2376 annual continuous motion: full event list per year in the appendix (owner-approved) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
119 lines
7.2 KiB
Python
119 lines
7.2 KiB
Python
"""BUG-2317: the annual continuous-motion appendix chapter, Chinese and English editions.
|
||
|
||
Synthetic packets, plus the repository's two public fixture charts.
|
||
"""
|
||
import re
|
||
|
||
import pytest
|
||
|
||
from scripts.report_render.annual_motion_appendix import HEADING, render_annual_motion_chapter
|
||
|
||
HAN = re.compile(r"[一-鿿]")
|
||
UNDERSCORED = re.compile(r"[A-Za-z0-9]+_[A-Za-z]")
|
||
FORBIDDEN_ZH = ("待核", "待核实", "还没核实", "Swiss Ephemeris", "swisseph", "transit_search", "PyJHora")
|
||
|
||
|
||
def _event(kind, planets, stamp, **extra):
|
||
return {"kind": kind, "planets": planets, "timestamp_local": stamp, **extra}
|
||
|
||
|
||
def _year(year, *, executed=True, reason=None):
|
||
events = [
|
||
_event("exact_contact", ["Mars", "Jupiter"], f"{year}-03-01T10:00:00", directed_angle=240),
|
||
_event("exact_contact", ["Moon", "Mars"], f"{year}-03-02T10:00:00", directed_angle=60),
|
||
_event("ingress", ["Venus"], f"{year}-03-03T10:00:00", from_sign_idx=0, to_sign_idx=1),
|
||
_event("ingress", ["Moon"], f"{year}-03-04T10:00:00", from_sign_idx=2, to_sign_idx=3),
|
||
_event("station", ["Saturn"], f"{year}-04-01T10:00:00", direction_after="retrograde"),
|
||
_event("exact_contact", ["Sun", "Saturn"], f"{year}-05-01T10:00:00", directed_angle=180),
|
||
]
|
||
timeline = ({"execution_status": "executed", "events": events,
|
||
"range": {"start": f"{year}-02-01T08:00:00", "end_exclusive": f"{year + 1}-02-01T14:00:00"},
|
||
"profile": {"ayanamsa": "lahiri", "position_mode": "apparent"}}
|
||
if executed else {"execution_status": "blocked", "reason": reason})
|
||
rows = [
|
||
{"yoga": "Ithasala", "presence": "present", "planets": ["Mars", "Jupiter"],
|
||
"motion_evidence": {"execution_status": "executed", "contact_status": "found_in_window", "aspect_filter": 120.0,
|
||
"contact_refs": [0], "contact_count": 1, "motion_change_count": 2,
|
||
"first_contact": events[0], "named_yoga_perfection": "not_adjudicated"}},
|
||
{"yoga": "Manahoo", "presence": "present", "planets": ["Sun", "Jupiter"], "interfering_planet": "Mars",
|
||
"motion_evidence": {"execution_status": "executed", "contact_status": "not_found_in_window",
|
||
"aspect_filter": "all_pair_contacts", "contact_refs": [], "contact_count": 0,
|
||
"motion_change_count": 0, "first_contact": None}},
|
||
{"yoga": "Nakta", "presence": "absent", "planets": []},
|
||
] if executed else []
|
||
return {"profile": {"target_year": year},
|
||
"year_lord": {"data": {"year_lord": "Saturn"}}, "muntha": {"data": {"muntha_lord": "Venus"}},
|
||
"solar_return": {"data": {"annual_location": {"utc_offset": 8.0}}},
|
||
"tajika_condition_status_pack": {"motion_timeline": timeline, "rows": rows}}
|
||
|
||
|
||
def _packet(*packs):
|
||
return {"worksheets": {"timing_and_predictive_systems": {"annual_tajika_series": {
|
||
"years": {str(pack["profile"]["target_year"]): pack for pack in packs}}}}}
|
||
|
||
|
||
def _tables(text):
|
||
lines = text.splitlines()
|
||
return [lines[i] for i in range(len(lines) - 1) if lines[i].startswith("|") and lines[i + 1].startswith("| ---")]
|
||
|
||
|
||
def test_each_year_has_its_own_range_method_events_and_rows():
|
||
text = "\n".join(render_annual_motion_chapter(_packet(_year(2026), _year(2027), _year(2028)), "zh"))
|
||
assert text.startswith(f"## {HEADING['zh']}")
|
||
for year in (2026, 2027, 2028):
|
||
assert f"### {year} 年" in text
|
||
assert f"- 范围:{year}-02-01 16:00 至 {year + 1}-02-01 22:00(年盘所在地当地时间,UTC+08:00" in text
|
||
assert f"| {year}-03-01 18:00 | 精确成相 | 火星、木星 | 120° | Ithasala |" in text
|
||
assert text.count("- 方法:七颗行星从年盘同一时刻起连续计算") == 3
|
||
# Year lord / Muntha lord changes in full; the Moon only counted.
|
||
assert "| 换座 | 金星 | 白羊座 → 金牛座 | Muntha 主星 |" in text
|
||
assert "| 停滞 | 土星 | 转逆行 | 年主星 |" in text
|
||
assert "| 精确成相 | 太阳、土星 | 180° | 年主星 |" not in text # Sun is neither lord
|
||
# 原值:整章不出现月亮事件;新值:精选表不出现,每年末「全部事件」列出全部;原因:BUG-2376(负责人 11-25 同意全表放附录)。
|
||
selected = re.sub(r"#### \d{4} 年全部事件\n\n(?:\|.*\n)+", "", text + "\n")
|
||
assert selected.count("### ") == 3 and "年全部事件" not in selected
|
||
assert "月亮、火星 | 60°" not in selected
|
||
assert "月亮、火星 | 60°" in text
|
||
assert "其余事件:精确成相 2 次、换座 1 次、停滞 0 次。" in text
|
||
# Row evidence, window-bounded wording, the interfering planet named.
|
||
assert "| Ithasala | 火星、木星 | — | 1 次(只计 120°) | 2026-03-01 18:00,120° | 2 次 |" in text
|
||
assert "| Manahoo | 太阳、木星 | 阻碍星 火星 | 本年窗口内没有 | — | 0 次 |" in text
|
||
assert "Nakta" not in text
|
||
assert "不是人生事件的日期" in text and "不表示这条 Yoga 已按传统完成兑现" in text
|
||
|
||
|
||
def test_blocked_year_says_why_and_never_no_change():
|
||
zh = "\n".join(render_annual_motion_chapter(_packet(_year(2026), _year(2027, executed=False, reason="time_budget_exceeded")), "zh"))
|
||
assert "本年连续运动没有算出:这次生成报告的时间内没有算完这一年,下次生成会补上。不能据此认为这一年没有变化。" in zh
|
||
en = "\n".join(render_annual_motion_chapter(_packet(_year(2027, executed=False, reason="anything_else")), "en"))
|
||
assert "This year's continuous motion was not computed: the computation did not complete. This does not mean the year has no changes." in en
|
||
|
||
|
||
def test_reader_wording_in_both_editions():
|
||
packet = _packet(_year(2026), _year(2027))
|
||
zh = "\n".join(render_annual_motion_chapter(packet, "zh"))
|
||
en = "\n".join(render_annual_motion_chapter(packet, "en"))
|
||
assert not HAN.search(en)
|
||
assert "Exact contact" in en and "Interfering planet Mars" in en and "Year lord" in en
|
||
for text in (zh, en):
|
||
assert not UNDERSCORED.search(text)
|
||
assert not any(word in text for word in FORBIDDEN_ZH)
|
||
assert "not_found" not in text and "executed" not in text
|
||
for header in _tables(zh):
|
||
assert not re.search(r"\b[a-z]+\b", header), header
|
||
assert render_annual_motion_chapter({}, "zh") == []
|
||
|
||
|
||
@pytest.mark.parametrize("case", ("steve_jobs_1955_aa", "barack_obama_1961_aa"))
|
||
def test_public_charts_carry_three_distinct_years(case):
|
||
from tests.public_chart_reports import public_chart_reports
|
||
packet, chinese, english = public_chart_reports(case)
|
||
years = packet["worksheets"]["timing_and_predictive_systems"]["annual_tajika_series"]["years"]
|
||
ranges = [pack["tajika_condition_status_pack"]["motion_timeline"]["range"]["start"] for pack in years.values()]
|
||
assert len(ranges) == 3 and len(set(ranges)) == 3
|
||
chapter = chinese.split(f"## {HEADING['zh']}", 1)[1].split("\n## ", 1)[0]
|
||
assert chapter.count("- 范围:") == 3 and len(set(re.findall(r"- 范围:(\S+ \S+)", chapter))) == 3
|
||
assert not any(word in chapter for word in FORBIDDEN_ZH)
|
||
en_chapter = english.split(f"## {HEADING['en']}", 1)[1].split("\n## ", 1)[0]
|
||
assert en_chapter.count("- Range: ") == 3 and not HAN.search(en_chapter)
|