- 2377 appendix yoga table: kind, formation, also-needs, condition and meaning source (book title only) - 2378 Saham trace: A, B, C, A − B + C, arc test, +30°, final value - 2379 daridra_2 「第二宫主落陷…」 no longer classified as Neecha Bhanga - 2380 Neecha variant names on page titles; Raja add-on line - 2381 Pancha Mahapurusha page agrees with its basis; degree, Moolatrikona, same-fact line - 2382 no book/page "Source:" lines in the body Yoga Expression chapter - 2383 yoga pages state participants' combustion, Shadbala, functional role - 2384 unresolved-rule records stay backstage (packet only) - 2385 Neecha verified state matches the row's own fallen planet - 2386 no hedge line for uncomputed Neecha notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXp3RzgZVEpT1PXxkwHj
138 lines
9.0 KiB
Python
138 lines
9.0 KiB
Python
"""占星师 2026-11-25 对照的显示层补充(负责人 11-25「显示层的也做了吧」):BUG-2377–2384。
|
||
|
||
只用虚构数据和公开盘(Steve Jobs / Barack Obama,AA)。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
|
||
from scripts import pl9_interpretation_packs as packs
|
||
from scripts.annual_native.saham_traces import attach_formula_traces
|
||
from scripts.report_render import yoga_appendix_fields as fields
|
||
from scripts.report_render.neecha_witness import is_neecha_bhanga_row
|
||
from scripts.report_render.parity_chapters import _trace_table
|
||
from tests.public_chart_reports import public_chart_reports
|
||
|
||
PUBLIC = ("steve_jobs_1955_aa", "barack_obama_1961_aa")
|
||
|
||
|
||
def test_appendix_yoga_table_has_kind_formation_missing_and_sources() -> None:
|
||
"""BUG-2377 (M01 / M02 / M05)."""
|
||
for case in PUBLIC:
|
||
_packet, chinese, english = public_chart_reports(case)
|
||
assert "| Name | Category | Planet | Kind | Formation | Also needs | Condition source | Meaning source |" in english
|
||
assert "| 名称 | 类别 | 行星 | 类型 | 形成状态 | 还需要 | 条件出处 | 含义出处 |" in chinese
|
||
assert "The candidate tables in the body list named yogas only" in english
|
||
table = english.split("### Canonical Yoga Rows", 1)[1].split("\n## ", 1)[0]
|
||
# Book titles only: no page, PDF page, line number or software name.
|
||
assert not re.search(r"\bpp?\.\s?\d|PDF|\bL\d{3,}|printed|PyJHora|corpus", table)
|
||
|
||
|
||
def test_source_text_keeps_the_book_only() -> None:
|
||
assert fields.source_text("Light on Life, printed p.295 / corpus PDF p.318, L11018-L11046; x", "en") == "Light on Life"
|
||
assert fields.source_text("B.V. Raman / PyJHora", "en") == "B.V. Raman, Three Hundred Important Combinations"
|
||
assert fields.source_text("BVR-15: L4 and L9 in mutual Kendras", "zh") == "B.V. Raman《三百个重要组合》"
|
||
assert fields.source_text("Local structural predicate; former Yoga name …", "zh") == "本地结构规则,没有具名出处"
|
||
assert fields.source_text("Phaladeepika 6", "zh") == "《Phaladeepika》"
|
||
assert fields.formation_text({"formation_assessment": {"status": "formed_under_source"}}, "zh") == "按具名定义成立"
|
||
assert fields.missing_text({"missing_inputs": ["Venus.source_admitted_composite_strength_profile"]}, "zh") == "金星:综合强弱的判法"
|
||
|
||
|
||
def test_saham_table_shows_the_steps() -> None:
|
||
"""BUG-2378 (M13): A, B, C, A − B + C, the arc test, +30°, final."""
|
||
results = {"punya_saham": {"name": "Punya Saham", "longitude": 328.5349}}
|
||
meta = {"punya_saham": {"formula_operands": ["Sun", "Saturn", "Ascendant"], "zodiacal_order_exception_applied": True,
|
||
"operand_longitudes": {"A": 4.9501, "B": 344.8214, "C": 278.4062},
|
||
"base_longitude": 298.5349, "arc_passes_c": False, "longitude": 328.5349}}
|
||
traces = attach_formula_traces(results, is_day=False, formula_meta=meta)
|
||
assert traces[0]["plus_thirty"] is True and traces[0]["base_longitude"] == 298.5349
|
||
text = _trace_table(traces, "en")
|
||
assert "| Name | Phase | A | B | C | A − B + C | C on arc B→A | +30° | Final longitude |" in text
|
||
assert "| Punya Saham | Night | Sun 4.9501 | Saturn 344.8214 | Ascendant 278.4062 | 298.5349 | No | Yes | 328.5349 |" in text
|
||
for case in PUBLIC:
|
||
_packet, chinese, english = public_chart_reports(case)
|
||
assert "C on arc B→A" in english and "C 在 B→A 弧上" in chinese
|
||
|
||
|
||
def test_second_lord_debilitated_is_not_a_neecha_bhanga() -> None:
|
||
"""BUG-2379: the bare word 「落陷」 does not make a cancellation row."""
|
||
daridra = {"rule_id": "daridra_2", "name": "Second lord debilitated in house 6, 8 or 12 (structural observation)",
|
||
"name_cn": "第二宫主落陷且在第6、8或12宫(结构观察)", "planets": ["Mercury"]}
|
||
assert not is_neecha_bhanga_row(daridra) and not packs._is_neecha_bhanga(daridra)
|
||
assert is_neecha_bhanga_row({"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga"})
|
||
assert is_neecha_bhanga_row({"name": "落陷取消", "name_cn": "落陷取消"})
|
||
|
||
|
||
def test_neecha_variant_names_and_raja_line() -> None:
|
||
"""BUG-2380 (M04)."""
|
||
base = {"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga", "name_cn": "落陷取消", "planets": ["Mercury", "Jupiter"],
|
||
"category": "nicha_bhanga", "combination": "水星落陷于双鱼座", "combination_en": "Mercury debilitated in Pisces",
|
||
"formation_evidence": {"planet": "Mercury", "profile": "light_on_life_p295", "royal_yoga_candidate": False,
|
||
"cancellation_reasons": [{"condition": "dispositor_aspect", "planet": "Jupiter"}]}}
|
||
exchange = {**base, "rule_id": "neechabhanga_parivartana", "name": "Neecha Bhanga (Exchange Variant)",
|
||
"formation_evidence": {**base["formation_evidence"], "profile": "exchange_variant",
|
||
"cancellation_reasons": [{"condition": "dispositor_exchange", "planet": "Jupiter"}]}}
|
||
pages = packs.build_yoga_interpretation_pack({"detected_yogas": [base, exchange]}, {}, set(), language="zh")["pages"]
|
||
names = [page["name"] for page in pages]
|
||
assert names == ["落陷取消(水星;常规化解条件)", "落陷取消(水星;互换星座的变体)"], names
|
||
assert "王者格的附加位置条件不满足" in pages[0]["sections"]["roles"]
|
||
|
||
|
||
def test_mahapurusha_page_agrees_with_its_basis_and_names_the_same_fact() -> None:
|
||
"""BUG-2381 (M03)."""
|
||
sasa = {"rule_id": "main_detector:pancha_mahapurusha:saturn", "name": "Sasa Yoga", "name_cn": "萨萨格局",
|
||
"planets": ["Saturn"], "category": "mahapurusha", "combination": "土星在第7宫水瓶座(入庙)",
|
||
"combination_en": "Saturn in house 7, Aquarius (own sign)", "strength_factors": {}}
|
||
kalatra = {"rule_id": "kalatra_yoga_7_kendra", "name": "Kalatra Yoga (7th Lord in Kendra)", "name_cn": "伴侣格局(七宫主在角宫)",
|
||
"planets": ["Saturn"], "category": "marriage", "combination": "七宫主土星在第7宫"}
|
||
pages = packs.build_yoga_interpretation_pack({"detected_yogas": [sasa, kalatra]}, {}, set(), language="en")["pages"]
|
||
page = next(page for page in pages if page["name"].startswith("Sasa"))
|
||
assert page["sections"]["formation"] == "Configuration: met under the yoga's named definition."
|
||
assert "The same Saturn placement also underlies: Kalatra Yoga (7th Lord in Kendra)" in page["sections"]["same_fact"]
|
||
|
||
|
||
def test_body_has_no_book_source_lines() -> None:
|
||
"""BUG-2382: the Yoga Expression chapter in the body prints no 'Source:' line with book pages."""
|
||
for case in PUBLIC:
|
||
_packet, chinese, english = public_chart_reports(case)
|
||
body_en = english.split("## Structured Data Appendix", 1)[0]
|
||
body_zh = chinese.split("## 结构化数据附录", 1)[0] if "## 结构化数据附录" in chinese else chinese
|
||
assert not re.search(r"^Source: ", body_en, re.M)
|
||
assert not re.search(r"^来源:", body_zh, re.M)
|
||
assert "printed pp." not in body_en
|
||
|
||
|
||
def test_yoga_pages_state_the_participants_own_condition() -> None:
|
||
"""BUG-2383 (M06): combustion, Shadbala and functional role come from the chart, not 'not assessed'."""
|
||
facts = {"Sun": {"combust": False, "rupas": 8.34, "minimum": 6.5, "role": "benefic"}}
|
||
text = packs._yoga_strength_text({"unassessed_layers": ["combustion", "Shadbala", "functional_benefic_malefic", "event_timing"]},
|
||
"en", facts, ["Sun"])
|
||
assert "The planets themselves: Sun: not combust, Shadbala 8.34 Rupas (minimum 6.5), functional benefic." in text
|
||
assert text.endswith("Not assessed for this yoga: event timing.")
|
||
for case in PUBLIC:
|
||
_packet, chinese, english = public_chart_reports(case)
|
||
assert "Not assessed for this yoga: combustion" not in english
|
||
assert "这一条还没有评估:燃烧" not in chinese
|
||
|
||
|
||
def test_unresolved_rules_stay_backstage() -> None:
|
||
"""BUG-2384 (M08): rules evaluated without a conclusion stay in the packet for the model, not in the reader's report."""
|
||
for case in PUBLIC:
|
||
packet, chinese, english = public_chart_reports(case)
|
||
assert "yoga_evaluation" in packet["worksheets"]["advanced_systems"]["yoga"]
|
||
assert "without a conclusion" not in english and "没有得出结论的规则" not in chinese
|
||
for text in fields.FORMATION_WORDS.values():
|
||
assert not re.search(r"待核|未解决|还没核实|未选定", text[0])
|
||
|
||
|
||
def test_a_debilitated_witness_is_not_verified_by_another_planets_row() -> None:
|
||
"""BUG-2385: Jupiter (debilitated) witnessing Mars's cancellation is not itself mitigated by that row."""
|
||
from scripts.report_render.neecha_witness import _row_fallen
|
||
|
||
mars_row = {"rule_id": "neechabhanga_basic", "name": "Neecha Bhanga", "planets": ["Moon", "Mars", "Jupiter"],
|
||
"formation_evidence": {"planet": "Mars"}}
|
||
assert _row_fallen(mars_row) == "Mars"
|
||
assert _row_fallen({"name": "Neecha Bhanga", "planets": ["Moon", "Jupiter"]}) is None
|
||
assert _row_fallen({"name": "Neecha Bhanga", "planets": ["Jupiter"]}) == "Jupiter"
|