Port from yinduzhanxing 5fb8379c (MIT): Naisargika, Kaala, Karaka, Tara, Lagnamsaka, Yogardha, Mandooka, Paryaaya and Padanadhamsa dashas; Sarvatobhadra, Kota and Kalanala chakras; Nakshatra Latta; Pachakadi; Raman Amsayu and Pindayu. Producers and their upstream tests are copied; scripts/upstream_technique_layers.py feeds them our natal and transit positions and attaches chart.consultation_native_layers.upstream_techniques. - dasha_registry: kaala and padanadhamsa keys (35 -> 37); the nine ported dashas are served by compute_dasha or fail closed with upstream's reason. - technique_registry.json: 16 partial entries; README badges follow. - Evidence lookup section `upstream_techniques` in the consultation tool. - Boundaries: Kalanala carries no PyJHora (AGPL) grid coordinates; Padanadhamsa/Lagnamsaka run on our Narayana engine (no Rath Table 12, PVR co-lord variants or second cycle). PyJHora observers and the Amsayu worked-example scaffold live in scripts/research (root .py budget). - PyJHora black-box cross-checks: Naisargika (lords/years) and Kaala (seed segment and fraction within 5e-4) on a public chart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
121 lines
5.9 KiB
Python
121 lines
5.9 KiB
Python
"""Rath's published order; synthetic dates explicitly not a source calendar."""
|
|
from copy import deepcopy
|
|
from datetime import datetime
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
from scripts.tara_dasha import PROFILE, calculate_tara_md, build_tara_native_report
|
|
|
|
|
|
def request():
|
|
return dict(ascendant_sign=5,
|
|
planet_signs=dict(Ketu=8, Rahu=2, Jupiter=11, Mars=5, Sun=3,
|
|
Venus=3, Saturn=9, Mercury=4, Moon=10),
|
|
# Deliberately interleave groups; group priority must beat global rank.
|
|
strength_order=['Sun', 'Ketu', 'Mercury', 'Rahu', 'Venus', 'Jupiter', 'Moon', 'Mars', 'Saturn'],
|
|
strength_basis='Published Rath Example2 within-group order; cross-group ranks are synthetic',
|
|
birth_epoch='2000-01-01T00:00:00+00:00', remaining_fraction=.25,
|
|
balance_basis='Synthetic quarter remaining, not a recovered source birth balance',
|
|
year_days=360, profile=PROFILE)
|
|
|
|
|
|
def test_author_example_group_order_and_years_not_a_strength_selector():
|
|
result = calculate_tara_md(**request())
|
|
assert result['order'] == ['Ketu', 'Rahu', 'Jupiter', 'Mars', 'Sun', 'Venus', 'Saturn', 'Mercury', 'Moon']
|
|
assert [r['nominal_years'] for r in result['full_periods']] == [7,18,16,7,6,20,19,17,10]
|
|
assert result['cycle_years'] == 120
|
|
assert result['child_status'] == 'blocked'
|
|
assert result['status'] == 'parameter_sensitive'
|
|
|
|
|
|
def test_native_query_boundaries_and_birth_clip():
|
|
req=request(); rows=calculate_tara_md(**req)['periods']
|
|
for i,row in enumerate(rows):
|
|
report=build_tara_native_report(**req,query_datetime=row['start_datetime_utc'])
|
|
query=report['evidence_appendix'][0]['query']
|
|
assert query['status']=='executed' and query['active_period']['lord']==row['lord']
|
|
assert query['child_status']=='blocked'
|
|
assert 'Requested-time MD' in report['exports']['markdown']
|
|
if i==0:
|
|
query['active_period'].clear()
|
|
assert report['exports']['ai_evidence_bundle']['query']['active_period']['lord']==row['lord']
|
|
for stamp in ('1999-12-31T23:59:59Z',rows[-1]['end_datetime_utc']):
|
|
q=build_tara_native_report(**req,query_datetime=stamp)['evidence_appendix'][0]['query']
|
|
assert q['status']=='outside_calculated_window' and q['active_period'] is None
|
|
q=build_tara_native_report(**req,query_datetime='2000-01-01T08:00:00+08:00')['evidence_appendix'][0]['query']
|
|
assert q['active_period']['lord']=='Ketu'
|
|
|
|
|
|
@pytest.mark.parametrize('stamp',['2000-01-01',True,0])
|
|
def test_native_query_rejects_ambiguous_time(stamp):
|
|
with pytest.raises(ValueError): build_tara_native_report(**request(),query_datetime=stamp)
|
|
|
|
|
|
def test_query_for_inapplicable_chart_has_no_active_period():
|
|
req=request(); req['planet_signs']={p:6 for p in req['planet_signs']}
|
|
q=build_tara_native_report(**req,query_datetime=req['birth_epoch'])['evidence_appendix'][0]['query']
|
|
assert q['status']=='not_applicable' and q['active_period'] is None
|
|
|
|
|
|
@pytest.mark.parametrize('fraction,visible', [(0,8),(.25,9),(1,9)])
|
|
def test_birth_balance_full_parent_and_contiguous_half_open_periods(fraction, visible):
|
|
data = request(); data['remaining_fraction'] = fraction
|
|
result = calculate_tara_md(**data)
|
|
full, rows = result['full_periods'], result['periods']
|
|
assert len(rows) == visible
|
|
assert rows[0]['start_datetime_utc'] == data['birth_epoch']
|
|
assert rows[0]['lord'] == ('Rahu' if fraction == 0 else 'Ketu')
|
|
for left, right in zip(rows, rows[1:]):
|
|
assert left['end_datetime_utc'] == right['start_datetime_utc']
|
|
assert (datetime.fromisoformat(full[-1]['end_datetime_utc']) - datetime.fromisoformat(full[0]['start_datetime_utc'])).days == 120*360
|
|
if fraction > 0:
|
|
first = rows[0]
|
|
assert (datetime.fromisoformat(first['end_datetime_utc']) - datetime.fromisoformat(first['start_datetime_utc'])).total_seconds()/86400 == 7*fraction*360
|
|
|
|
|
|
def test_less_than_four_quadrant_planets_not_applicable_no_dates():
|
|
data = request(); data['planet_signs']['Mars'] = 6
|
|
result = calculate_tara_md(**data)
|
|
assert result['status'] == 'not_applicable'
|
|
assert result['periods'] == result['full_periods'] == []
|
|
|
|
|
|
def test_nodes_count_and_different_declared_strength_changes_order_only_within_group():
|
|
data = request(); data['strength_order'].reverse()
|
|
result = calculate_tara_md(**data)
|
|
assert len(result['groups']['kendra']) == 4
|
|
assert result['order'][:4] == ['Mars','Jupiter','Rahu','Ketu']
|
|
assert result['order'][4:7] == ['Saturn','Venus','Sun']
|
|
|
|
|
|
@pytest.mark.parametrize('change', [
|
|
{'ascendant_sign':True}, {'ascendant_sign':12}, {'planet_signs':{}},
|
|
{'strength_order':['Sun']*9}, {'strength_order':[{}]*9},
|
|
{'strength_basis':''}, {'balance_basis':''}, {'remaining_fraction':True},
|
|
{'remaining_fraction':float('nan')}, {'remaining_fraction':1.1},
|
|
{'year_days':float('inf')}, {'year_days':0}, {'year_days':True},
|
|
{'birth_epoch':'2000-01-01'}, {'profile':'generic'},
|
|
])
|
|
def test_no_silent_coercion_or_missing_convention(change):
|
|
data = request(); data.update(change)
|
|
with pytest.raises(ValueError):
|
|
calculate_tara_md(**data)
|
|
|
|
|
|
def test_report_engine_route_copy_and_portable_cli(tmp_path):
|
|
data = request(); original = deepcopy(data)
|
|
report = build_tara_native_report(**data)
|
|
assert data == original
|
|
assert report['customer_export_admitted'] is False
|
|
assert all(f'| {p} |' in report['exports']['markdown'] for p in data['planet_signs'])
|
|
report['exports']['ai_evidence_bundle']['periods'].clear()
|
|
assert len(report['evidence_appendix'][0]['periods']) == 9
|
|
path = tmp_path/'request.json'; path.write_text(json.dumps(data))
|
|
script = Path(__file__).resolve().parents[1]/'scripts/tara_dasha.py'
|
|
proc = subprocess.run([sys.executable,str(script),'--request',str(path)],cwd=tmp_path,
|
|
text=True,capture_output=True,check=True)
|
|
assert json.loads(proc.stdout)['status'] == 'parameter_sensitive'
|