Files
Jyotisha/tests/test_shadbala_mean_motion_continuity.py
T
Jesse_ChenandClaude Opus 5.5 08376cf0a8 fix(shadbala): Ayana hemisphere after wrap, civil-weekday hora lord, continuous mean motion, short-arc Chesta midpoint (upstream 0afa2780)
Ported from yinduzhanxing 0afa2780 (algorithm hunks and its four regression
tests; the PyJHora / profile-metadata hunks do not apply to our file). The
archived-PyJHora Kala test follows upstream's rewrite. The V.P. Jain
benchmark expectations still need the three-column update (follow-up in this
branch). TASK-upstream-sync4-20261002 T3.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2026-10-02 13:55:58 +08:00

31 lines
1.4 KiB
Python

import pytest
from scripts.shadbala import _surya_mean_longitude, _SURYA_REVOLUTIONS, _SURYA_CIVIL_DAYS
@pytest.mark.parametrize("planet", list(_SURYA_REVOLUTIONS))
@pytest.mark.parametrize("start", [2451544.49999, 2451544.99999, 2451545.1, 2451546.1,
2451547.1, 2451548.1, 2451549.1, 2451550.1, 2451551.1])
def test_mean_motion_has_no_noon_midnight_or_weekday_jumps(planet, start):
rate = round(_SURYA_REVOLUTIONS[planet] / _SURYA_CIVIL_DAYS * 360, 7)
for interval in (1 / 86400, 1.0, 7.0):
a = _surya_mean_longitude(planet, {"jd_ut": start})
b = _surya_mean_longitude(planet, {"jd_ut": start + interval})
delta = (b - a + 180) % 360 - 180
assert delta == pytest.approx(rate * interval, abs=1e-8)
@pytest.mark.parametrize("planet", list(_SURYA_REVOLUTIONS))
def test_same_instant_has_one_mean_independent_of_clock_and_location(planet):
instant = 2451545.0
expected = _surya_mean_longitude(planet, {"jd_ut": instant})
for timezone, longitude in [(0, 0), (5.5, 77.5), (8, 120), (-8, -122.4)]:
context = {"jd_local": instant + timezone / 24,
"timezone": timezone, "lon": longitude}
assert _surya_mean_longitude(planet, context) == pytest.approx(expected, abs=1e-8)
def test_ambiguous_civil_clock_without_offset_is_rejected():
with pytest.raises(KeyError, match="timezone"):
_surya_mean_longitude("Mercury", {"jd_local": 2451545.0, "lon": 120})