Rahu uses the circular unique start. Output keys are unchanged. Upstream arc and clock tests passed. Co-Authored-By: Grok (agent loop)
65 lines
2.9 KiB
Python
65 lines
2.9 KiB
Python
"""PVR Integrated Approach Table 39 and Example 59 (file pages 239–240)."""
|
||
import pytest
|
||
from scripts.ashtottari_dasha import _calc_candidate_balance_and_birth_chain
|
||
|
||
|
||
@pytest.mark.parametrize('lord,start,end,years', [
|
||
('Sun',200/3,120.,6.), ('Moon',120.,160.,15.),
|
||
('Mars',160.,640/3,8.), ('Mercury',640/3,760/3,17.),
|
||
('Saturn',760/3,880/3,10.), ('Jupiter',880/3,1000/3,19.),
|
||
('Rahu',1000/3,1160/3,12.), ('Venus',80/3,200/3,21.),
|
||
])
|
||
def test_all_eight_published_arcs(lord,start,end,years):
|
||
at_start,_=_calc_candidate_balance_and_birth_chain(start,lord)
|
||
at_middle,_=_calc_candidate_balance_and_birth_chain((start+end)/2,lord)
|
||
assert at_start['years']==pytest.approx(years)
|
||
assert at_middle['years']==pytest.approx(years/2)
|
||
|
||
|
||
@pytest.mark.parametrize('longitude,lord,years', [
|
||
(144.,'Moon',6.), (0.,'Rahu',6.), (360.,'Rahu',6.),
|
||
(1000/3,'Rahu',12.), (20.,'Rahu',1.5), (350.,'Rahu',8.25),
|
||
])
|
||
def test_published_arc_balance_including_zero_wrap(longitude,lord,years):
|
||
balance,_=_calc_candidate_balance_and_birth_chain(longitude,lord)
|
||
assert balance is not None
|
||
assert balance['years']==pytest.approx(years)
|
||
if lord=='Rahu':
|
||
assert balance['segment_start_nakshatra']=='Uttara Bhadrapada'
|
||
assert balance['segment_end_nakshatra']=='Bharani'
|
||
assert balance['segment_span_nakshatras']==4
|
||
|
||
|
||
def test_arc_end_belongs_to_next_lord():
|
||
assert _calc_candidate_balance_and_birth_chain(80/3,'Rahu')==(None,None)
|
||
|
||
|
||
def test_auxiliary_entrypoint_uses_pvr_example_not_vimshottari_lords():
|
||
from scripts.nakshatra_dasha import calc_ashtottari_dasha
|
||
result=calc_ashtottari_dasha(144.,'2000-01-01',2)
|
||
assert result['starting_lord']=='Moon'
|
||
assert result['first_remaining_years']==6.
|
||
assert [row['lord'] for row in result['sequence'][:4]]==['Moon','Mars','Mercury','Saturn']
|
||
assert result['balance_method']=='PVR Table 39 arc fraction'
|
||
assert result['applicability_rule_family']=='rahu_not_in_kendra'
|
||
|
||
|
||
def test_auxiliary_entrypoint_rejects_invalid_birth_date():
|
||
from scripts.nakshatra_dasha import calc_ashtottari_dasha
|
||
with pytest.raises(ValueError):
|
||
calc_ashtottari_dasha(144.,'not-a-date',2)
|
||
|
||
|
||
def test_auxiliary_birth_balance_keeps_original_child_clock():
|
||
from scripts.nakshatra_dasha import calc_ashtottari_dasha,calc_current_ashtottari
|
||
data=calc_ashtottari_dasha(144.,'2000-01-01',2)
|
||
current=calc_current_ashtottari(data,0.)
|
||
assert current['years_elapsed_in_md']==9.
|
||
assert current['mahadasha_progress']==0.6
|
||
assert current['current_antardasha']['lord']=='Rahu'
|
||
assert current['current_antardasha']['remaining_years']==pytest.approx(1/6)
|
||
assert [r['lord'] for r in current['antardasha_sequence']]==[
|
||
'Mars','Mercury','Saturn','Jupiter','Rahu','Venus','Sun','Moon']
|
||
assert sum(r['years'] for r in current['antardasha_sequence'])==pytest.approx(15.)
|
||
assert calc_current_ashtottari(data,6.)['current_mahadasha']=='Mars'
|