feat: migrate precise Shadbala parity
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from scripts.shadbala import (
|
||||
build_shadbala_context,
|
||||
calc_dig_bala_precise,
|
||||
calc_drik_bala_precise,
|
||||
calc_sthana_bala_precise,
|
||||
classify_drik_planets,
|
||||
)
|
||||
|
||||
|
||||
PLANET_LONGITUDES = {
|
||||
"Sun": 312.51819523181405,
|
||||
"Moon": 344.51168181221095,
|
||||
"Mars": 5.862334338243072,
|
||||
"Mercury": 291.12589362817465,
|
||||
"Jupiter": 87.27055150216494,
|
||||
"Venus": 267.94211928370015,
|
||||
"Saturn": 207.92738390514674,
|
||||
}
|
||||
PYJHORA_DIG = {"Sun": 24.81, "Moon": 95.48, "Mars": 77.41, "Mercury": 12.64, "Jupiter": 80.60, "Venus": 69.95, "Saturn": 19.62}
|
||||
PYJHORA_DRIK = {"Sun": 1.74, "Moon": 20.06, "Mars": 13.49, "Mercury": -10.63, "Jupiter": 6.89, "Venus": -2.75, "Saturn": 9.49}
|
||||
PYJHORA_STHANA = {"Sun": 217.09, "Moon": 246.34, "Mars": 198.63, "Mercury": 167.96, "Jupiter": 201.80, "Venus": 154.06, "Saturn": 218.61}
|
||||
|
||||
|
||||
def _planets() -> dict:
|
||||
return {
|
||||
planet: {
|
||||
"degree": longitude,
|
||||
"sign": ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"][int(longitude // 30)],
|
||||
}
|
||||
for planet, longitude in PLANET_LONGITUDES.items()
|
||||
}
|
||||
|
||||
|
||||
def test_precise_dig_bala_matches_pyjhora_same_chart() -> None:
|
||||
context = build_shadbala_context(2435163.6354166665, 37.7749, -122.4194, "lahiri")
|
||||
for planet, longitude in PLANET_LONGITUDES.items():
|
||||
assert calc_dig_bala_precise(planet, longitude, context["house_midpoints"]) == PYJHORA_DIG[planet]
|
||||
|
||||
|
||||
def test_drik_classification_matches_pyjhora_same_chart() -> None:
|
||||
benefics, malefics = classify_drik_planets(_planets())
|
||||
assert benefics == {"Moon", "Mercury", "Jupiter", "Venus"}
|
||||
assert malefics == {"Sun", "Mars", "Saturn"}
|
||||
|
||||
|
||||
def test_precise_drik_bala_matches_pyjhora_same_chart() -> None:
|
||||
planets = _planets()
|
||||
for planet, expected in PYJHORA_DRIK.items():
|
||||
assert abs(calc_drik_bala_precise(planet, planets) - expected) <= 0.02
|
||||
|
||||
|
||||
def test_precise_sthana_bala_matches_pyjhora_same_chart() -> None:
|
||||
planets = _planets()
|
||||
houses = {"Sun": 7, "Moon": 8, "Mars": 9, "Mercury": 6, "Jupiter": 11, "Venus": 5, "Saturn": 3}
|
||||
for planet, expected in PYJHORA_STHANA.items():
|
||||
assert calc_sthana_bala_precise(planet, planets, houses[planet])["total"] == expected
|
||||
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from benchmarks.jyotish.scripts.run_skill_baseline import run_sample
|
||||
from benchmarks.jyotish.scripts.run_pyjhora_compare import build_pyjhora_sample, compare_one
|
||||
from scripts import three_engine_high_rigor_parity as parity
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_runner_imports_from_commercial_root() -> None:
|
||||
env = os.environ.copy()
|
||||
env["PYTHONPATH"] = str(ROOT)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", "import scripts.three_engine_high_rigor_parity"],
|
||||
cwd=ROOT,
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
assert result.returncode == 0, result.stderr
|
||||
|
||||
|
||||
def test_public_sample_exposes_shadbala_components() -> None:
|
||||
result = run_sample(parity.SAMPLE)
|
||||
assert result["ok"] is True
|
||||
components = result["canonical"]["shadbala_components"]
|
||||
assert set(components["Sun"]) == set(parity.VED_COMPONENT_FIELDS)
|
||||
|
||||
|
||||
def test_pyjhora_sample_exposes_shadbala_components() -> None:
|
||||
sample = build_pyjhora_sample(parity.SAMPLE)
|
||||
assert set(sample["shadbala_components"]["Sun"]) == set(parity.VED_COMPONENT_FIELDS)
|
||||
|
||||
|
||||
def test_pyjhora_matrix_includes_shadbala_components() -> None:
|
||||
baseline = {
|
||||
"ascendant": {}, "planets": {}, "varga": {}, "ashtakavarga": {}, "shadbala": {}, "dasha": {},
|
||||
"shadbala_components": {"Sun": {name: 1.0 for name in parity.VED_COMPONENT_FIELDS}},
|
||||
}
|
||||
rows = compare_one("sample", baseline, baseline)
|
||||
assert {row["field"] for row in rows if row["section"] == "Shadbala_Component" and row["body"] == "Sun"} == set(parity.VED_COMPONENT_FIELDS)
|
||||
|
||||
|
||||
def test_jyotishganit_planet_map_reads_divisional_occupants() -> None:
|
||||
chart = {"houses": [{"occupants": [{"celestialBody": "Sun", "sign": "Leo"}]}]}
|
||||
assert parity._jyotish_planet_signs(chart) == {"Sun": "Leo"}
|
||||
|
||||
|
||||
def test_vedastro_components_read_six_raw_fields() -> None:
|
||||
raw = {"Payload": {"AllPlanetData": {field: index for index, field in enumerate(parity.VED_COMPONENT_FIELDS.values(), 1)}}}
|
||||
assert parity._ved_components(raw) == {name: index for index, name in enumerate(parity.VED_COMPONENT_FIELDS, 1)}
|
||||
Reference in New Issue
Block a user