Astrologer ruling 2026-11-04 on #166; product decision the same day (Moon option C, rulings implemented as given). The default is a named BPHS version; the pre-#166 precise Sthana / Drik is kept byte-for-byte as variant "raman_gbb" (Raman, Graha and Bhava Balas Ex. 13 / 55 still pass on it). - Q3 (BUG-1581): the Moon's own Paksha is P on both sides (Sanskrit 27.11 lists indu), Chesta = Paksha, total 2P. Drik still classifies a waning Moon as a malefic (Q26), classify_drik_planets unchanged for the Moon. - Q2 (BUG-1582): the Sun's Ayana is not doubled; Chesta = base Ayana; A + A. On the VP Jain fixture Kala + Chesta = 46.73 + 35.07 = published 81.80 + 0. - Q18 (BUG-1583, BUG-1575): Moolatrikona Moon Taurus from 3 deg, Mercury Virgo from 15 deg, in shadbala.py and jyotish_engine.MOOLATRIKONA. - Q16 / Q20 (BUG-1584): Saptavargaja 45/30/20/15/10/4/2, compound relation from D1. - Q25 (BUG-1585): Mercury is a natural malefic with any natural malefic in its sign (nodes not counted, recorded as an implementation choice). - Q24 (BUG-1586): BPHS 26.9-12 piecewise special aspects replace the general segment for Saturn, Mars and Jupiter; a single aspect stays within 0-60. - Q21 (BUG-1587): Kendradi Bala by whole sign from the Lagna sign. - Q27 (BUG-1588): jaimini.calc_arudha_pada_for_house takes the 10th from the first-count pada (pada in the 7th -> 4th from the house), as special_lagnas did. - Q30 (BUG-1589): D30 degree inside the sign is proportional within the unequal span in varga.py; divisional_charts_extended uses exact 30/7. - method_variants names every convention. Q22 edges and the Q24 60 cap are locked in tests/test_astrologer_rulings_166.py (42 tests). Raman / PyJHora comparison tests now run on "raman_gbb"; the VP Jain report labels the new convention rows; chart-insight-golden.json's planets-only Shadbala section regenerated from /api/shadbala. Rectification identity, golden and re-freeze follow in separate commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
68 lines
3.2 KiB
Python
68 lines
3.2 KiB
Python
"""BUG-1576: Drik Bala must not depend on PYTHONHASHSEED.
|
||
|
||
Each Sphuta Drishti value is rounded to 0.01, so a quarter of their sum often
|
||
lands on a .xx5 edge. Summing in set order made the float rounding, and so the
|
||
Drik value, flip by 0.01 between processes (rectification reads Drik). The
|
||
engine now sums whole hundredths and rounds the quarter half away from zero.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
import os
|
||
import subprocess
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parents[1]
|
||
|
||
# Chart longitudes exactly as the engine passes them (Lahiri, mean node);
|
||
# benchmark_samples.json fictional smoke charts and the public Monroe chart.
|
||
CHARTS = {
|
||
"smoke_london_1970_evening": {"Sun": 337.2733, "Moon": 142.4564, "Mars": 17.0173, "Mercury": 335.4295, "Jupiter": 191.17, "Venus": 350.8936, "Saturn": 13.4906},
|
||
"smoke_delhi_2000_midnight": {"Sun": 249.4013, "Moon": 238.9378, "Mars": 186.8229, "Mercury": 248.811, "Jupiter": 38.9781, "Venus": 295.0216, "Saturn": 31.078},
|
||
"smoke_tokyo_1964_noon": {"Sun": 173.4785, "Moon": 224.6433, "Mars": 111.6052, "Mercury": 169.3045, "Jupiter": 31.7107, "Venus": 131.6451, "Saturn": 305.4168},
|
||
"smoke_sao_paulo_2004_morning": {"Sun": 316.3356, "Moon": 61.1116, "Mars": 22.7489, "Mercury": 313.2528, "Jupiter": 140.5351, "Venus": 0.2044, "Saturn": 72.4219},
|
||
"marilyn_monroe": {"Sun": 47.6197, "Moon": 296.2737, "Mars": 327.9069, "Mercury": 43.954, "Jupiter": 304.0011, "Venus": 5.9258, "Saturn": 208.617},
|
||
}
|
||
|
||
_PROBE = """
|
||
import json, sys
|
||
sys.path.insert(0, sys.argv[1])
|
||
from shadbala import calc_drik_bala_precise
|
||
charts = json.loads(sys.argv[2])
|
||
variant = sys.argv[3]
|
||
print(json.dumps({
|
||
name: {p: calc_drik_bala_precise(p, {q: {"degree": lon} for q, lon in lons.items()}, variant=variant) for p in lons}
|
||
for name, lons in charts.items()
|
||
}, sort_keys=True))
|
||
"""
|
||
|
||
|
||
def _drik_with_seed(seed: int, variant: str = "raman_gbb") -> str:
|
||
env = {**os.environ, "PYTHONHASHSEED": str(seed)}
|
||
return subprocess.check_output(
|
||
[sys.executable, "-c", _PROBE, str(ROOT / "scripts"), json.dumps(CHARTS), variant],
|
||
env=env, text=True,
|
||
).strip()
|
||
|
||
|
||
def test_default_bphs_drik_is_identical_across_hash_seeds() -> None:
|
||
# #166 (BUG-1585 / BUG-1586): the default is now the BPHS version; it must be
|
||
# deterministic too.
|
||
assert len({_drik_with_seed(seed, "bphs") for seed in range(8)}) == 1
|
||
|
||
|
||
def test_drik_bala_is_identical_across_hash_seeds() -> None:
|
||
# 原值: 默认口径;新值: variant="raman_gbb"(#166 前的写法逐字保留为具名对照口径)
|
||
# 原因: 下面两个 .xx5 边界值是在 Raman 口径上找到的,默认改为 BPHS 后不再落在边上
|
||
# Before the fix seeds 0-7 gave two different results (e.g. London Saturn
|
||
# 21.55 / 21.54, Sao Paulo Jupiter -46.09 / -46.10, Monroe Mercury -18.88 / -18.87).
|
||
outputs = {_drik_with_seed(seed) for seed in range(8)}
|
||
assert len(outputs) == 1
|
||
values = json.loads(outputs.pop())
|
||
# Both sit exactly on a .xx5 edge (86.18 / 4 = 21.545, -184.38 / 4 = -46.095):
|
||
# rounded half away from zero.
|
||
assert values["smoke_london_1970_evening"]["Saturn"] == 21.55
|
||
assert values["smoke_sao_paulo_2004_morning"]["Jupiter"] == -46.10
|