From 42d1582f4cf012a76f0d9e4103efc6c862733f3a Mon Sep 17 00:00:00 2001 From: Jesse_Chen Date: Fri, 2 Oct 2026 13:50:24 +0800 Subject: [PATCH] fix(transit): double-transit aspect check counts houses from 1 (upstream 2dd6062a) Saturn's 7th aspect was judged on the 8th house, Jupiter 5/9 on 6/10, Mars 4/8 on 5/9. Ported from yinduzhanxing 2dd6062a with product authorization (TASK-upstream-sync4-20261002 T2). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE --- scripts/jyotish_engine.py | 2 +- tests/test_double_transit_pac_aspect_count.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/test_double_transit_pac_aspect_count.py diff --git a/scripts/jyotish_engine.py b/scripts/jyotish_engine.py index 53e3067d..99943a89 100644 --- a/scripts/jyotish_engine.py +++ b/scripts/jyotish_engine.py @@ -13072,7 +13072,7 @@ def _check_pac(planet_name, planet_lon, target_lon, asc_idx): } aspects = planet_aspects.get(planet_name, [7]) for offset in aspects: - if ((t_house - p_house + 12) % 12) == offset: + if ((t_house - p_house + 12) % 12) + 1 == offset: results.append({'type': 'Aspect', 'offset': offset, 'desc': f'{offset}宫相位'}) return results diff --git a/tests/test_double_transit_pac_aspect_count.py b/tests/test_double_transit_pac_aspect_count.py new file mode 100644 index 00000000..70ccc504 --- /dev/null +++ b/tests/test_double_transit_pac_aspect_count.py @@ -0,0 +1,30 @@ +"""BUG (sync4 T2): _check_pac counted the house distance from 0 but compared it +with 1-based aspect numbers, so Saturn's 7th aspect landed on the 8th house. +Ported from upstream yinduzhanxing 2dd6062a.""" + +from __future__ import annotations + +import pytest + +from scripts.jyotish_engine import _check_pac + + +def _lon(house: int) -> float: + return (house - 1) * 30 + 15.0 + + +def _aspect_offsets(planet: str, target_house: int) -> list[int]: + rows = _check_pac(planet, _lon(1), _lon(target_house), 0) + return [row["offset"] for row in rows if row["type"] == "Aspect"] + + +@pytest.mark.parametrize("planet,hits", [ + ("Saturn", {3, 7, 10}), ("Jupiter", {5, 7, 9}), ("Mars", {4, 7, 8}), ("Venus", {7}), +]) +def test_aspect_lands_on_the_numbered_house(planet: str, hits: set[int]) -> None: + for house in range(2, 13): + offsets = _aspect_offsets(planet, house) + if house in hits: + assert offsets == [house], (planet, house, offsets) + else: + assert offsets == [], (planet, house, offsets)