diff --git a/scripts/jyotishyamitra_adapter_probe.py b/scripts/jyotishyamitra_adapter_probe.py index bc8f7fc8..fe8c611d 100644 --- a/scripts/jyotishyamitra_adapter_probe.py +++ b/scripts/jyotishyamitra_adapter_probe.py @@ -18,6 +18,7 @@ VERSION = "1.4.0" COMMIT = "86f7eb610a66b06b3f0817d2c53355bec8b3bf8d" LICENSE = "MIT" RETURNVAL = "ASTRODATA_DICTIONARY" +SIGN_ALIASES = {"Saggitarius": "Sagittarius"} def _sha256_bytes(data: bytes) -> str: @@ -182,6 +183,20 @@ def extract_fields(raw: dict) -> dict: return out +def extract_varga_signs(raw: dict) -> dict: + out = {} + for chart in ("D1", "D2", "D4", "D9", "D10"): + planets = (raw.get(chart) or {}).get("planets") or {} + signs = { + planet: SIGN_ALIASES.get(str(data["sign"]), str(data["sign"])) + for planet, data in planets.items() + if isinstance(data, dict) and isinstance(data.get("sign"), str) and data["sign"] + } + if signs: + out[chart] = signs + return out + + def compare_with_existing_oracles(jyotishyamitra: dict, local: dict, xalen: dict) -> dict: rows = [] counts = {"local": 0, "xalen": 0} diff --git a/tests/test_jyotishyamitra_adapter_probe.py b/tests/test_jyotishyamitra_adapter_probe.py index ed2250ca..61f321af 100644 --- a/tests/test_jyotishyamitra_adapter_probe.py +++ b/tests/test_jyotishyamitra_adapter_probe.py @@ -4,6 +4,7 @@ from scripts.jyotishyamitra_adapter_probe import ( build_report, canonical_request, compare_with_existing_oracles, + extract_varga_signs, normalize_raw, schema_fingerprint, ) @@ -93,3 +94,16 @@ def test_jyotishyamitra_field_comparison_is_observation_not_promotion() -> None: assert comparison["match_counts"]["local"] == 1 assert comparison["match_counts"]["xalen"] == 2 assert comparison["promotion_allowed"] is False + + +def test_extract_varga_signs_keeps_only_supported_planet_signs() -> None: + raw = { + "D1": {"planets": {"Sun": {"sign": "Aquarius"}, "Rahu": {"sign": "Saggitarius"}}}, + "D9": {"planets": {"Moon": {"sign": "Cancer"}, "Mars": {"sign": None}}}, + "Balas": {"Shadbala": {}}, + } + + assert extract_varga_signs(raw) == { + "D1": {"Sun": "Aquarius", "Rahu": "Sagittarius"}, + "D9": {"Moon": "Cancer"}, + }