Files
Jyotisha/tests/test_vivaha_shared_formula.py
T
ClaudeandClaude Opus 5.5 7dcf8112ad fix(saham): natal Vivaha Saham uses the shared day/night rule (BUG-1547, upstream 26d5a52d)
The natal marriage point was hard-coded to Venus - Saturn + Asc with no
zodiacal-order exception, while the annual Tajika point already followed
references/saham_rules.json (PVR Table 74: night reverses the operands, plus
the +30 exception). The same night-born person had two marriage points; 6 of
the 9 public charts move. The full reading, the vivah-saham command and the
consult card now share tajika._formula_saham_trace, with day/night from the
card's own day_night evidence. 0 deg Aries is no longer "missing".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXoyeZrYn6ryNcSe5Y2Y
2026-11-04 12:23:21 +08:00

45 lines
1.8 KiB
Python

"""BUG-1547 (upstream 26d5a52d): the natal Vivaha Saham uses the shared rule.
references/saham_rules.json (PVR, Integrated Approach, Table 74): day
Venus - Saturn + Asc, night Saturn - Venus + Asc, plus the zodiacal-order
exception. The annual Tajika points already used it; the natal one did not.
"""
import pytest
from scripts.jyotish_engine import _calc_vivah_saham
from scripts.tajika import _formula_saham_trace
@pytest.mark.parametrize('day,expected', [(True, 280.), (False, 130.)])
def test_vivaha_uses_daynight_and_directed_arc(day, expected):
actual = _calc_vivah_saham({'Venus': {'degree': 210.}, 'Saturn': {'degree': 300.}},
10., is_daytime=day)
assert actual['saham_lon'] == expected
assert actual['saham_sign'] == ('Capricorn' if day else 'Leo')
assert actual['zodiacal_order_exception_applied'] is (not day)
assert actual['formula_variant'] == ('day' if day else 'night')
def test_natal_and_annual_vivaha_are_the_same_point():
planets = {'Venus': 47.3, 'Saturn': 288.9}
for day in (True, False):
natal = _calc_vivah_saham({name: {'degree': lon} for name, lon in planets.items()}, 133.7, is_daytime=day)
annual = _formula_saham_trace('Vivaha_Saham', planets, 133.7, day, {})
assert natal['saham_lon'] == round(annual['longitude'], 4)
def test_zero_longitude_is_not_missing():
actual = _calc_vivah_saham({'Venus': {'degree': 0.}, 'Saturn': {'degree': 300.}},
10., is_daytime=True)
assert 'error' not in actual
assert actual['saham_lon'] == 100.
def test_missing_longitude_is_not_zero():
assert 'error' in _calc_vivah_saham({'Venus': {'degree': 0.}}, 10., is_daytime=True)
def test_is_daytime_is_required():
with pytest.raises(TypeError):
_calc_vivah_saham({'Venus': {'degree': 1.}, 'Saturn': {'degree': 2.}}, 10.)