Land QA fixes and repository hygiene guardrails
This commit is contained in:
@@ -28,13 +28,18 @@ def _weekday_to_vara(py_weekday: int) -> int:
|
||||
def _get_sun_moon_lons(year: int, month: int, day: int,
|
||||
hour: int = 12, ayanamsa_name: str = 'lahiri') -> tuple:
|
||||
"""获取太阳/月亮恒星黄经。优先 swisseph,退化为近似算法。"""
|
||||
def _primary_longitude(value):
|
||||
if isinstance(value, (list, tuple)):
|
||||
return float(value[0])
|
||||
return float(value)
|
||||
|
||||
try:
|
||||
import swisseph as swe
|
||||
jd_ut = swe.julday(year, month, day, hour)
|
||||
flags = sidereal_flags(swe, ayanamsa_name)
|
||||
sun_res = swe.calc_ut(jd_ut, swe.SUN, flags)
|
||||
moon_res = swe.calc_ut(jd_ut, swe.MOON, flags)
|
||||
return sun_res[0], moon_res[0], True
|
||||
return _primary_longitude(sun_res[0]), _primary_longitude(moon_res[0]), True
|
||||
except Exception:
|
||||
pass
|
||||
# 近似算法
|
||||
|
||||
@@ -2962,6 +2962,23 @@ def cmd_varga_full(args):
|
||||
result[pn] = calc.calc_varga_with_variant(lon, divisions[0], variant)
|
||||
return result
|
||||
|
||||
try:
|
||||
sys.path.insert(0, SCRIPT_DIR)
|
||||
from divisional_charts_extended import DivisionalChartsCalculator, VargaType
|
||||
extended_available = {varga.division: varga for varga in VargaType}
|
||||
if any(division not in {2, 3, 4, 7, 9, 10, 12, 16, 20, 24, 27, 30, 40, 45, 60} for division in (divisions or [])):
|
||||
calc = DivisionalChartsCalculator()
|
||||
selected = [extended_available[division] for division in divisions]
|
||||
result = {}
|
||||
for varga in selected:
|
||||
key = f'D{varga.division}_{varga.varga_name}'
|
||||
result[key] = calc._calculate_single_varga(varga, planet_lons, asc_deg)
|
||||
return result
|
||||
except KeyError as e:
|
||||
return {"error": f"不支持的D{e.args[0]}。请使用 --custom N 计算任意D-N分盘。"}
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
return calc_all_vargas(planet_lons, asc_deg, divisions)
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -104,7 +104,12 @@ def recommend_remedies(shadbala_results: Dict, planet_dignities: Dict = None,
|
||||
evidence_chain = []
|
||||
|
||||
for planet, data in shadbala_results.items():
|
||||
rupas = data.get('total_rupas', data.get('rupas', 1.0))
|
||||
if isinstance(data, (int, float)) and not isinstance(data, bool):
|
||||
rupas = float(data)
|
||||
elif isinstance(data, dict):
|
||||
rupas = data.get('total_rupas', data.get('rupas', 1.0))
|
||||
else:
|
||||
rupas = 1.0
|
||||
if rupas < STRENGTH_THRESHOLDS['weak']:
|
||||
weak_planets.append(planet)
|
||||
evidence_chain.append({
|
||||
|
||||
Reference in New Issue
Block a user