Upstream 3c2dad95, 8643bc9a, and the lon_to_nakshatra part of 9e04f0db. Exact star starts were split across int-division and modulo, so 16 of 27 openings reported a zero balance and skipped the mahadasha. Off-boundary longitudes keep the old modulo. BUG-1381. Co-Authored-By: Grok (agent loop) Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
2.2 KiB
Python
51 lines
2.2 KiB
Python
"""The interpretation helper must consume the real, unclipped MD/AD clock."""
|
|
import math
|
|
from fractions import Fraction
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
from scripts.dasha_analyzer import lon_to_nakshatra
|
|
from scripts.jyotish_engine import cmd_dasha
|
|
from scripts.nakshatra_advanced import nakshatra_index_and_progress
|
|
from scripts.nakshatra_dasha import calc_nakshatra_dasha_breakdown
|
|
|
|
|
|
def test_first_remaining_md_is_not_repartitioned_into_new_ads():
|
|
# Mid-Ashwini: half of Ketu's seven years elapsed. The active AD is Rahu,
|
|
# not Ketu; the helper must not restart the first parent's child clock.
|
|
result = calc_nakshatra_dasha_breakdown(
|
|
20 / 3, {'Ketu': 1., 'Rahu': 181.},
|
|
'2000-01-01T12:34:56', 0.)
|
|
assert result['mahadasha']['lord'] == 'Ketu'
|
|
assert result['antardasha']['lord'] == 'Rahu'
|
|
assert result['antardasha']['start_datetime'] == '2000-01-01T12:34:56'
|
|
assert result['reference_datetime'] == '2000-01-01T12:34:56'
|
|
assert result['antardasha']['progress'] > 0
|
|
# Missing natal positions are never silently fabricated as 0 degrees.
|
|
assert {row['period'] for row in result['pada_windows']} <= {'AD Ketu', 'AD Rahu'}
|
|
|
|
|
|
@pytest.mark.parametrize('index', range(27))
|
|
def test_native_vimshottari_exact_star_birth_balance(index):
|
|
packet = cmd_dasha(SimpleNamespace(
|
|
moon_lon=index * 40 / 3, nakshatra=None, pada=None,
|
|
birthdate='2000-01-01', year=2000, month=1, day=1, hour=12, minute=0, second=0,
|
|
lat=None, lon=None, tz=0, today='2000-01-01', dasha_year_days=365.25))
|
|
first = packet['timeline'][0]
|
|
assert first['years'] == first['full_years']
|
|
assert first['antardasha_timeline'][0]['lord'] == first['lord']
|
|
|
|
|
|
def test_exact_star_neighbors_keep_adjacent_indexes():
|
|
start = float(Fraction(40, 3))
|
|
before = math.nextafter(start, 0.0)
|
|
after = math.nextafter(start, 360.0)
|
|
assert nakshatra_index_and_progress(before)[0] == 0
|
|
assert nakshatra_index_and_progress(start)[0] == 1
|
|
assert nakshatra_index_and_progress(after)[0] == 1
|
|
assert lon_to_nakshatra(before)[0][0] == 'Ashwini'
|
|
assert lon_to_nakshatra(start)[0][0] == 'Bharani'
|
|
assert lon_to_nakshatra(after)[0][0] == 'Bharani'
|
|
assert lon_to_nakshatra(start)[1] == 0.0
|