diff --git a/scripts/shadbala.py b/scripts/shadbala.py index c71d88ab..c0299073 100644 --- a/scripts/shadbala.py +++ b/scripts/shadbala.py @@ -98,9 +98,12 @@ NAISARGIKA_BALA = { 'Jupiter': 34.29, 'Mercury': 25.71, 'Mars': 17.14, 'Saturn': 8.57 } -# Shadbala 最低要求(Rupas) +# Shadbala 最低要求(Rupas)。BPHS 第 27 章(Evaluation of Strengths)第 32–33 颂: +# 「390, 360, 300, 420, 390, 330 and 300 Virupas are the Shad Bal Pindas, needed for +# Sūrya etc. to be considered strong」,即日月火水木金土 6.5/6/5/7/6.5/5.5/5 Rupa。 +# 太阳原写 5.0(BUG-1189,清单 F3);上游 yinduzhanxing 0a6696c5 仍是 5.0。 MIN_REQUIRED = { - 'Sun': 5.0, 'Moon': 6.0, 'Mars': 5.0, + 'Sun': 6.5, 'Moon': 6.0, 'Mars': 5.0, 'Mercury': 7.0, 'Jupiter': 6.5, 'Venus': 5.5, 'Saturn': 5.0 } diff --git a/tests/test_shadbala_sun_minimum_bphs.py b/tests/test_shadbala_sun_minimum_bphs.py new file mode 100644 index 00000000..04d9128d --- /dev/null +++ b/tests/test_shadbala_sun_minimum_bphs.py @@ -0,0 +1,25 @@ +"""BUG-1189 (清单 F3): Shadbala minimum requirements follow BPHS ch. 27 sl. 32-33. + +"390, 360, 300, 420, 390, 330 and 300 Virupas are the Shad Bal Pindas, needed +for Surya etc. to be considered strong" -> 60 virupas per rupa. +""" + +from __future__ import annotations + +from scripts.shadbala import MIN_REQUIRED, VIRUPAS_PER_RUPA, calc_shadbala +from tests.test_shadbala_precise_context import _planets + +BPHS_VIRUPAS = {"Sun": 390, "Moon": 360, "Mars": 300, "Mercury": 420, "Jupiter": 390, "Venus": 330, "Saturn": 300} + + +def test_minimum_table_matches_bphs() -> None: + # 原值: Sun 5.0;新值: 6.5;其余六星不变 + assert MIN_REQUIRED == {planet: value / VIRUPAS_PER_RUPA for planet, value in BPHS_VIRUPAS.items()} + + +def test_sun_ishta_percentage_uses_six_and_a_half_rupas() -> None: + planets = _planets() + result = calc_shadbala(planets, "Aries", 12.0, planets["Sun"]["degree"], planets["Moon"]["degree"]) + sun = result["planets"]["Sun"] + assert sun["min_required"] == 6.5 + assert abs(sun["ishta_bala_pct"] - round(sun["total_rupas"] / 6.5 * 100, 1)) <= 0.1