diff --git a/scripts/yogini_dasha.py b/scripts/yogini_dasha.py index a34f66cd..c7e2f195 100644 --- a/scripts/yogini_dasha.py +++ b/scripts/yogini_dasha.py @@ -23,16 +23,9 @@ The 8 Yoginis, their year allotments, and associated planets: Total: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36 years. Starting Yogini: - The starting Yogini is determined by the Ascendant (Lagna) Rashi. - Per standard texts: - - Aries / Leo / Sagittarius / Gemini / Libra / Aquarius - → start from Maya (1) - - Taurus / Virgo / Capricorn / Cancer / Scorpio / Pisces - → start from Bhadrika (2) - - Alternative (more common) rule based on Lagna degree modulo 8: - Lagna Nakshatra Pada determines the starting Yogini. - For simplicity, this implementation uses the Ascendant Rashi rule above. + When the Moon's nakshatra index is supplied, use the standard + ``(nakshatra_index + 3) mod 8`` seed. The older Lagna-rashi seed remains + an explicit compatibility fallback when no Moon nakshatra is available. Reference: Various classical and modern Jyotish texts on Yogini Dasha. """ @@ -113,6 +106,7 @@ def calculate_yogini_dasha(birth_info: dict) -> dict: birth_info: dict containing: - "lagna_rashi_index": int (0 = Aries, ..., 11 = Pisces) - "birth_datetime": datetime object or ISO-format string (optional) + - "moon_nakshatra_index": 0-based nakshatra index (optional) Returns: dict with keys: @@ -130,7 +124,14 @@ def calculate_yogini_dasha(birth_info: dict) -> dict: if birth_dt is None: birth_dt = datetime.now() - start_idx = _get_start_yogini_index(lagna_idx) + moon_nakshatra_index = birth_info.get("moon_nakshatra_index") + if moon_nakshatra_index is not None: + moon_nakshatra_index = int(moon_nakshatra_index) % 27 + start_idx = (moon_nakshatra_index + 3) % 8 + seed_method = 'moon_nakshatra_plus_3_mod_8' + else: + start_idx = _get_start_yogini_index(lagna_idx) + seed_method = 'legacy_lagna_rashi_compatibility' starting_yogini = YOGINI_SEQUENCE[start_idx]["name"] starting_planet = YOGINI_SEQUENCE[start_idx]["planet"] @@ -163,6 +164,7 @@ def calculate_yogini_dasha(birth_info: dict) -> dict: "total_cycle": TOTAL_CYCLE, "starting_yogini": starting_yogini, "starting_planet": starting_planet, + "seed_method": seed_method, } diff --git a/tests/test_yogini_seed_profile.py b/tests/test_yogini_seed_profile.py new file mode 100644 index 00000000..6736f756 --- /dev/null +++ b/tests/test_yogini_seed_profile.py @@ -0,0 +1,23 @@ +from datetime import datetime + +from scripts.yogini_dasha import calculate_yogini_dasha + + +def test_yogini_uses_moon_nakshatra_plus_three_seed_when_available() -> None: + result = calculate_yogini_dasha({ + 'lagna_rashi_index': 0, + 'moon_nakshatra_index': 0, + 'birth_datetime': datetime(1990, 1, 1), + }) + assert result['starting_yogini'] == 'Rati' + assert result['starting_planet'] == 'Mercury' + assert result['seed_method'] == 'moon_nakshatra_plus_3_mod_8' + + +def test_yogini_keeps_legacy_seed_only_without_moon_nakshatra() -> None: + result = calculate_yogini_dasha({ + 'lagna_rashi_index': 0, + 'birth_datetime': datetime(1990, 1, 1), + }) + assert result['starting_yogini'] == 'Maya' + assert result['seed_method'] == 'legacy_lagna_rashi_compatibility'