Files
Jyotisha/tests/test_upstream_sync9_saham_table74_completion.py
T
jesse-uxandGrok (agent loop) 16bae00615 fix(saham): apply Table 74 before legacy rows (BUG-1474, upstream cb8a1ca7)
Directed-arc sign stays as BUG-1387. formula_traces remains the 36-row report list. Book rows are no longer overwritten by the old house approximation.

Co-Authored-By: Grok (agent loop)
2026-10-28 09:45:06 +08:00

73 lines
3.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""PVR Table74 pp394–395 and printed Example121 p396; synthetic inputs."""
import pytest
from scripts.tajika import _formula_saham_trace
def test_printed_example_121_samartha_and_vanik():
planets={'Saturn':19+10/60,'Mars':354+58/60,
'Moon':345+14/60,'Mercury':311+28/60}
asc=280+50/60
assert _formula_saham_trace('Samartha_Saham',planets,asc,False,{})['longitude']==pytest.approx(335+2/60)
assert _formula_saham_trace('Vanik_Saham',planets,asc,False,{})['longitude']==pytest.approx(247+4/60)
@pytest.mark.parametrize('day,expected',[(True,130),(False,280)])
def test_samartha_mars_lagna_exception(day,expected):
trace=_formula_saham_trace('Samartha_Saham',{'Mars':90,'Jupiter':180},10,day,{})
assert trace['longitude']==expected
assert trace['formula_operands']==(['Jupiter','Mars','Ascendant'] if day else ['Mars','Jupiter','Ascendant'])
def test_karyasiddhi_night_changes_luminary_and_its_sign_lord_not_a_b_reversal():
planets={'Sun':45,'Moon':120,'Saturn':300,'Venus':210}
day=_formula_saham_trace('Karyasiddhi_Saham',planets,10,True,{})
night=_formula_saham_trace('Karyasiddhi_Saham',planets,10,False,{})
assert day['longitude']==105
assert night['longitude']==255
assert night['formula_operands']==['Saturn','Moon','MoonSignLord']
def test_all_36_book_rows_reach_full_producer_without_replacing_legacy_names(monkeypatch):
from datetime import datetime
import saham_daynight
from scripts.tajika import calc_all_sahams
monkeypatch.setattr(saham_daynight,'determine_daytime',lambda *a,**k:{'is_daytime':True})
planets=dict(Sun=45.,Moon=120.,Mars=90.,Mercury=60.,Jupiter=180.,Venus=210.,Saturn=300.,Rahu=0.,Ketu=180.)
result=calc_all_sahams(planets,10.,datetime(2000,1,1),lat=0,lon=0,tz=0)
assert len(result['formula_traces'])==36
assert result['sastra_saham']['formula_status']=='rule_backed_parameter_sensitive'
assert result['shastra_saham']['formula_status']=='legacy_candidate_unverified'
assert result['sastra_saham']['longitude']!=result['shastra_saham']['longitude']
from scripts.pl9_full_data_export import _render_pl9_ai_density_raw_data_markdown_en
text=_render_pl9_ai_density_raw_data_markdown_en({
'advanced_systems':{'sahams':result}})
delivered={c[0]:c for line in text.splitlines() if line.startswith('| ')
for c in [[v.strip() for v in line.strip().strip('|').split('|')]]
if len(c)==4}
for key,row in result.items():
if not isinstance(row,dict) or row.get('formula_status')!='rule_backed_parameter_sensitive':continue
assert delivered[key][1]==row['sign']
assert float(delivered[key][2])==row['degree_in_sign']
assert float(delivered[key][3])==row['longitude']
@pytest.mark.parametrize('day,column',[(True,0),(False,1)])
def test_remaining_table74_day_night_golden_values(monkeypatch,day,column):
# Independent hand arithmetic of Table74 with integer longitudes.
# Includes the actual third operand, the Mars-owned-lagna exception,
# non-reversing Vyapara and the independently calculated Sastra/Punya.
from datetime import datetime
import saham_daynight
from scripts.tajika import calc_all_sahams
monkeypatch.setattr(saham_daynight,'determine_daytime',lambda *a,**k:{'is_daytime':day})
planets=dict(Sun=45.,Moon=120.,Mars=90.,Mercury=60.,Jupiter=180.,Venus=210.,Saturn=300.,Rahu=0.,Ketu=180.)
result=calc_all_sahams(planets,10.,datetime(2000,1,1),lat=0,lon=0,tz=0)
expected={'asha':(250,160),'samartha':(130,280),'jeeva':(160,250),
'kali':(130,280),'sastra':(300,210),'paradara':(205,205),
'vanik':(100,310),'karyasiddhi':(105,255),'santapa':(340,10),
'sraddha':(160,250),'preeti':(225,125),'jadya':(210,300),
'vyapara':(160,160),'jalapatana':(175,235),'bandhana':(185,45),
'apamrityu':(170,240)}
for name,values in expected.items():
assert result[name+'_saham']['longitude']==values[column],name