fix(yoga): record Jupiter upachaya from the Moon as a configuration (BUG-1266, upstream 1918ffaf)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""Jupiter in the Moon's upachaya houses is a configuration, not Shakata (BUG-1266)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from scripts.yoga_engine import YogaEngine
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
RULES = ROOT / "references" / "yoga_rules.json"
|
||||
|
||||
|
||||
def _rule() -> dict:
|
||||
rules = json.loads(RULES.read_text(encoding="utf-8"))["rules"]
|
||||
return next(rule for rule in rules if rule["id"] == "jupiter_upachaya_from_moon")
|
||||
|
||||
|
||||
def _hits(moon_house: int, jupiter_house: int) -> list[dict]:
|
||||
planets = {
|
||||
"Moon": {"sign": "Aries", "house": moon_house, "degree": 10.0},
|
||||
"Jupiter": {"sign": "Leo", "house": jupiter_house, "degree": 10.0},
|
||||
}
|
||||
return [row for row in YogaEngine(str(RULES)).detect(planets, "Aries") if row.get("rule_id") == "jupiter_upachaya_from_moon"]
|
||||
|
||||
|
||||
def test_rule_names_the_geometry_and_not_shakata() -> None:
|
||||
rule = _rule()
|
||||
assert rule["name_cn"] == "木星位于月亮增长宫"
|
||||
assert rule["category"] == "configuration"
|
||||
assert "bvr_id" not in rule
|
||||
assert "Shakata" not in json.dumps(rule, ensure_ascii=False)
|
||||
assert "瑜伽" not in rule["name_cn"] and "Yoga" not in rule["name"]
|
||||
assert "3,6,10,11" in rule["logic"]["conditions"][0]["expr"]
|
||||
|
||||
|
||||
def test_relative_houses_3_6_10_11_match_and_5_does_not() -> None:
|
||||
# Moon in house 1. House 3 is the 3rd from the Moon. House 5 is not an upachaya.
|
||||
assert _hits(1, 3)
|
||||
assert _hits(1, 6)
|
||||
assert _hits(1, 10)
|
||||
assert _hits(1, 11)
|
||||
assert _hits(1, 5) == []
|
||||
hit = _hits(1, 3)[0]
|
||||
assert hit["category"] == "configuration"
|
||||
assert hit["name_cn"] == "木星位于月亮增长宫"
|
||||
assert hit["bvr_id"] is None
|
||||
Reference in New Issue
Block a user