From 09c0efc2a137f3fc0763ef1c6166d1b6e21155c8 Mon Sep 17 00:00:00 2001 From: Jesse_Chen Date: Fri, 2 Oct 2026 14:06:23 +0800 Subject: [PATCH] fix(shadbala): Sun minimum requirement is 6.5 rupas per BPHS ch. 27 sl. 32-33 (BUG-1189, F3) BPHS ch. 27 (Evaluation of Strengths) sl. 32-33 gives 390, 360, 300, 420, 390, 330 and 300 virupas for Sun..Saturn; the Sun was 5.0. MIN_REQUIRED in scripts/shadbala.py is the only requirement table in our code (the 5.0 default in .get() is for unknown bodies; vendored jyotishganit / dashaflow tables already say 6.5). Upstream yinduzhanxing 0a6696c5 still has 5.0 (to notify). Product decision 2026-10-02 (added to TASK-upstream-sync4-20261002). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE --- scripts/shadbala.py | 7 +++++-- tests/test_shadbala_sun_minimum_bphs.py | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/test_shadbala_sun_minimum_bphs.py 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