Upstream e628118d, 7d545039, f75a6e77, and ac565836. Dignity follows the sign, Deeptadi keeps every condition that applies, and Shayanadi hours come from the previous Hindu sunrise. BUG-1389. Co-Authored-By: Grok (agent loop) Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
import math
|
|
import pytest
|
|
from scripts.avastha_calculator import calculate_pvr_shayanadi, AvasthaCalculator
|
|
|
|
|
|
def test_pvr_footnotes_navamsa_part_and_running_ghati():
|
|
# Printed Mercury 22Ge14 is the seventh *part*, not its D9 sign.
|
|
# Sunrise 06:00, birth 23:00: 42.5 elapsed ghatis, 43rd running.
|
|
row = calculate_pvr_shayanadi('Mercury', 82 + 14 / 60, 0, 0, 17)
|
|
assert row['components'] == dict(
|
|
planet_nakshatra=7, planet_index=4,
|
|
navamsa_part=7, moon_nakshatra=1, running_ghati=43,
|
|
lagna_sign_number=1, formula_sum=241,
|
|
)
|
|
assert row['state'] == 'Shayana'
|
|
|
|
|
|
def test_zero_remainder_is_twelfth_state():
|
|
# 1*1*1 + 1 + 9 + 1 = 12.
|
|
assert calculate_pvr_shayanadi('Sun', 0, 0, 0, 3.2)['state'] == 'Nidra'
|
|
|
|
|
|
def test_exact_navamsa_and_ghati_boundaries():
|
|
edge = 10 / 3
|
|
assert calculate_pvr_shayanadi('Sun', math.nextafter(edge, -math.inf), 0, 0, 0)['components']['navamsa_part'] == 1
|
|
assert calculate_pvr_shayanadi('Sun', edge, 0, 0, 0)['components']['navamsa_part'] == 2
|
|
assert calculate_pvr_shayanadi('Sun', 0, 0, 0, .4)['components']['running_ghati'] == 2
|
|
|
|
|
|
def test_actual_activity_context_replaces_element_heuristic():
|
|
row = AvasthaCalculator().calculate_all_avasthas(
|
|
'Sun', 'Aries', 0, 1,
|
|
activity_context=dict(moon_longitude=0, asc_longitude=0, hours_since_sunrise=3.2),
|
|
)
|
|
assert row['avasthas']['Shayanadi']['state'] == 'Nidra'
|
|
assert row['avasthas']['Shayanadi']['method_status'] == 'pvr_15_4_4_running_ghati'
|
|
assert row['avasthas']['Shayanadi']['activity_intensity_status'] == 'requires_name_first_sound_index'
|
|
|
|
|
|
@pytest.mark.parametrize('elapsed', [-1, float('nan'), float('inf'), True])
|
|
def test_invalid_sunrise_elapsed_is_not_silently_defaulted(elapsed):
|
|
with pytest.raises(ValueError):
|
|
calculate_pvr_shayanadi('Sun', 0, 0, 0, elapsed)
|