The full reading's inter-chart linkage appended D12 with a hard-coded None ascendant, so every D12 row had house None even though d12_asc_idx was already computed a few lines above. An unknown sign name also fell back to Aries. Port upstream cf6c316d and f60568a0: pass d12_asc_idx through, and raise on an unknown sign or a non 0-11 ascendant index. The full reading records the error and the consult native layer marks it blocked. Test ported from upstream tests/test_inter_chart_d12_house.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyeZrYn6ryNcSe5Y2Y
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
"""D12 houses in the inter-chart linkage count from the D12 ascendant.
|
|
|
|
Ported from upstream yinduzhanxing cf6c316d and f60568a0 (sync 10). Before
|
|
the fix the D12 row always had house None, and an unknown sign became Aries.
|
|
"""
|
|
import ast
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'scripts'))
|
|
from jyotish_engine import calc_all_inter_chart_linkages # noqa: E402
|
|
|
|
|
|
@pytest.mark.parametrize('ascendant', range(12))
|
|
def test_d12_every_house_from_its_own_ascendant(ascendant):
|
|
frame = {'Sun': {'sign': 'Taurus'}}
|
|
actual = calc_all_inter_chart_linkages(frame, frame, frame, frame, 0, 4, 8, ascendant)['Sun']
|
|
assert actual['D12']['house'] == (1 - ascendant) % 12 + 1
|
|
assert actual['D1']['house'] == 2
|
|
assert actual['D9']['house'] == 10
|
|
assert actual['D10']['house'] == 6
|
|
|
|
|
|
def test_missing_d12_ascendant_is_not_aries():
|
|
assert calc_all_inter_chart_linkages({}, {}, {}, {'Sun': {'sign': 'Taurus'}})['Sun']['D12']['house'] is None
|
|
|
|
|
|
def test_bad_sign_does_not_become_aries():
|
|
with pytest.raises(ValueError):
|
|
calc_all_inter_chart_linkages({'Sun': {'sign': 'unknown'}}, {}, {}, d1_asc_idx=0)
|
|
|
|
|
|
@pytest.mark.parametrize('bad', [True, -1, 12, 1.0])
|
|
def test_bad_ascendant_index_is_rejected(bad):
|
|
with pytest.raises(ValueError):
|
|
calc_all_inter_chart_linkages({'Sun': {'sign': 'Taurus'}}, {}, {}, d1_asc_idx=bad)
|
|
|
|
|
|
def test_full_reading_passes_the_precomputed_d12_index():
|
|
tree = ast.parse((ROOT / 'scripts/jyotish_engine.py').read_text(encoding='utf-8'))
|
|
calls = [n for n in ast.walk(tree) if isinstance(n, ast.Call) and isinstance(n.func, ast.Name)
|
|
and n.func.id == 'calc_all_inter_chart_linkages']
|
|
assert calls
|
|
assert all(isinstance(c.args[-1], ast.Name) and c.args[-1].id == 'd12_asc_idx' for c in calls)
|