Files
Jyotisha/scripts/report_render/conditional_dasha_pvr_2014.py
T
ClaudeandClaude Opus 5.5 d70866e493 fix(report): no book titles, author citations, pages or chapter numbers in front of the reader (BUG-2129)
Owner 2026-11-21: after BUG-2115 the full-data report still printed source
lines and book references (Goel 出处 line, the PVR 2014 article in the
conditional-dasha note, PVR / Light on Life / BPHS verse in the calculation
notes, Tithi lord table source, rashi-dasha 出处 lines, Narayana p.43 label and
p.50 / Table 13 direction notes, functional profile source row, Ashtakavarga
book calibration). Method names stay; the book, page, chapter and ruling round
go. Engine labels for the consultation card are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2U3BH1SxwAGyhhbe1
2026-11-21 19:36:15 +08:00

110 lines
5.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""PVR 2014 readings of two conditional-dasha conditions, as a separate named profile (BUG-2122).
Astrologer reply 2026-11-20, answer 11: P.V.R. Narasimha Rao, "Unified
Nakshatra Dasa Approach: In Annual & Natal Charts" (2014-01-07, v4), PDF
pp. 2-4, reads two conditions differently from the ones this product uses:
* Panchottari: the Lagna in Cancer dwadasamsa (D12) only; the article's
footnote rejects the extra "Cancer in rasi" requirement.
* Dwisaptati Sama: the Lagna lord in the 7th house, or the 7th lord in the
Lagna (the product tests the Lagna lord in the 1st or 7th).
These rows are an additional named profile. They never replace the
product's rows, never change which dasha is the main timeline and never
create a period table. Houses are counted by sign from the Lagna sign (the
article's worked example counts this way); the seven-planet sign lords are
the ones the product's own gates use. The article's controlling-planet
strength step is not applied. Inputs come only from the packet's D1
longitudes; when one is missing the row is "not determined" (None), never
"does not apply".
"""
from __future__ import annotations
from typing import Any, Dict, List, Optional
try:
from panchottari_dasha import dwadasamsa_sign_index
except ImportError: # pragma: no cover - package import
from scripts.panchottari_dasha import dwadasamsa_sign_index
try:
from scripts.report_render.conditional_dasha_applicability import _SIGN_LORDS, _longitudes
except ImportError: # pragma: no cover
from report_render.conditional_dasha_applicability import _SIGN_LORDS, _longitudes
PROFILE = "pvr_unified_nakshatra_dasa_2014"
# BUG-2129 (负责人 2026-11-21): the reader sees the reading's name, not its author.
PROFILE_NAMES = ("Unified nakshatra-dasa reading (2014)", "统一星宿大运读法(2014)")
CANCER = 3
# Family keys (as in conditional_dasha_applicability.FAMILY_ORDER) that have a PVR 2014 variant.
VARIANT_FAMILIES = ("dwisaptatisama", "panchottari")
def _sign(longitude: float) -> int:
return int(longitude // 30) % 12
def _house(asc_sign: int, sign: int) -> int:
"""Whole-sign house: the Lagna sign is the 1st."""
return (sign - asc_sign) % 12 + 1
def _panchottari(lons: Dict[str, float], fallback_d12: Any = None) -> Dict[str, Any]:
asc = lons.get("Ascendant")
inputs: Dict[str, Any] = {}
if asc is not None:
inputs = {"ascendant_rasi_sign_index": _sign(asc), "ascendant_d12_sign_index": dwadasamsa_sign_index(asc)}
elif isinstance(fallback_d12, int) and not isinstance(fallback_d12, bool):
# The engine's own D12 Lagna, when the packet carries no Lagna longitude.
inputs = {"ascendant_d12_sign_index": int(fallback_d12) % 12}
d12 = inputs.get("ascendant_d12_sign_index")
return {"condition": None if d12 is None else d12 == CANCER, "inputs": inputs}
def _dwisaptati(lons: Dict[str, float]) -> Dict[str, Any]:
asc = lons.get("Ascendant")
if asc is None:
return {"condition": None, "inputs": {}}
asc_sign = _sign(asc)
lagna_lord, seventh_lord = _SIGN_LORDS[asc_sign], _SIGN_LORDS[(asc_sign + 6) % 12]
inputs: Dict[str, Any] = {"ascendant_sign_index": asc_sign, "lagna_lord": lagna_lord, "seventh_lord": seventh_lord}
if lagna_lord in lons:
inputs["lagna_lord_sign_index"] = _sign(lons[lagna_lord])
inputs["lagna_lord_house"] = _house(asc_sign, inputs["lagna_lord_sign_index"])
if seventh_lord in lons:
inputs["seventh_lord_sign_index"] = _sign(lons[seventh_lord])
inputs["seventh_lord_house"] = _house(asc_sign, inputs["seventh_lord_sign_index"])
first = inputs.get("lagna_lord_house") == 7 if "lagna_lord_house" in inputs else None
second = inputs.get("seventh_lord_house") == 1 if "seventh_lord_house" in inputs else None
if first is True or second is True:
condition: Optional[bool] = True
elif first is False and second is False:
condition = False
else:
condition = None # one branch unknown and the other not met: stays unknown.
return {"condition": condition, "inputs": inputs}
def pvr_variant_rows(chart: Any, default_rows: Any = None) -> List[Dict[str, Any]]:
"""One row per family with a PVR 2014 variant.
``chart``: ``core_chart``; ``default_rows``: ``applicability_rows(...)``
(used only for the product row's table state and, for Panchottari, the
engine's D12 Lagna when no longitude is carried).
Row: ``key``, ``profile``, ``condition`` (True / False / None), ``inputs``,
``table`` (the product row's table state, unchanged; no table is built here).
"""
lons = _longitudes(chart if isinstance(chart, dict) else {})
by_key = {row.get("key"): row for row in default_rows or [] if isinstance(row, dict)}
rows = []
for key in VARIANT_FAMILIES:
base = by_key.get(key) or {}
if key == "panchottari":
found = _panchottari(lons, (base.get("inputs") or {}).get("ascendant_d12_sign_index"))
else:
found = _dwisaptati(lons)
rows.append({"key": key, "profile": PROFILE, **found, "table": base.get("table")})
return rows