| """Device test for astropy 8.0.1 Android wheels (x86_64 + arm64_v8a).
|
|
|
| Generated by RIMI.
|
|
|
| Runs on-device via the PythonSTB app Scripts folder after installing, in order:
|
| numpy 2.5.2, pyerfa 2.0.1.5, astropy-iers-data, packaging, PyYAML,
|
| then astropy-8.0.1-cp312-cp312-android_24_<arch>.whl.
|
|
|
| Contract: prints [PASS]/[FAIL] per check and exits 0 iff ALL checks pass.
|
| """
|
|
|
| import io
|
| import math
|
| import sys
|
|
|
| PASS = 0
|
| FAIL = 0
|
|
|
|
|
| def check(name, fn):
|
| global PASS, FAIL
|
| try:
|
| fn()
|
| except Exception as e:
|
| FAIL += 1
|
| print("[FAIL] %s -- %s: %s" % (name, type(e).__name__, e))
|
| else:
|
| PASS += 1
|
| print("[PASS] %s" % name)
|
|
|
|
|
| def t_import_version():
|
| import astropy
|
|
|
| assert astropy.__version__ == "8.0.1", astropy.__version__
|
|
|
|
|
| def t_native_wcs():
|
| from astropy.wcs import WCS
|
|
|
| w = WCS(naxis=2)
|
| w.wcs.ctype = ["RA---TAN", "DEC--TAN"]
|
| assert w.naxis == 2
|
|
|
|
|
| def t_native_iterparser():
|
| from astropy.utils.xml import _iterparser
|
|
|
|
|
| def t_native_convolve():
|
| import numpy as np
|
| from astropy.convolution import convolve
|
|
|
| out = convolve(np.ones(9), np.ones(3) / 3.0, boundary="extend")
|
| assert abs(float(out[4]) - 1.0) < 1e-12, out[4]
|
|
|
|
|
| def t_native_stats():
|
| import numpy as np
|
| from astropy.stats import sigma_clip
|
|
|
| r = sigma_clip(np.array([1.0, 1.0, 1.0, 50.0]), sigma=2.0)
|
| assert bool(getattr(r, "mask", [False] * 4)[3]) is True
|
|
|
|
|
| def t_native_fits():
|
| import numpy as np
|
| from astropy.io import fits
|
|
|
| buf = io.BytesIO()
|
| fits.PrimaryHDU(data=np.arange(12, dtype=">i2").reshape(3, 4)).writeto(buf)
|
| buf.seek(0)
|
| with fits.open(buf) as hdul:
|
| assert hdul[0].data.shape == (3, 4)
|
| assert int(hdul[0].data.sum()) == 66
|
|
|
|
|
| def t_time_object():
|
| from astropy.time import Time
|
|
|
| t = Time("2026-01-01T00:00:00", scale="utc")
|
| assert t.iso.startswith("2026-01-01"), t.iso
|
| assert abs(float(t.unix) - 1767225600.0) < 1.0, t.unix
|
| assert str(t.tt.scale) == "tt"
|
|
|
|
|
| def t_units():
|
| import astropy.units as u
|
|
|
| assert abs((1.0 * u.m).to_value(u.km) - 0.001) < 1e-15
|
| assert abs((90.0 * u.deg).to_value(u.rad) - math.pi / 2) < 1e-12
|
|
|
| assert abs((1.0 * u.solMass).to_value(u.kg) - 1.988409870698051e30) / 1.988409870698051e30 < 1e-9
|
| assert abs((1.0 * u.imperial.mile).to_value(u.m) - 1609.344) < 1e-9
|
|
|
|
|
| def t_skycoord():
|
| from astropy.coordinates import SkyCoord
|
| import astropy.units as u
|
|
|
| a = SkyCoord(0.0 * u.deg, 0.0 * u.deg, frame="icrs")
|
| b = SkyCoord(0.0 * u.deg, 90.0 * u.deg, frame="icrs")
|
| assert abs(a.separation(b).deg - 90.0) < 1e-9
|
| g = SkyCoord("10h00m00s", "+30d00m00s", frame="icrs").galactic
|
| assert hasattr(g, "l") and hasattr(g, "b")
|
|
|
|
|
| def t_table():
|
| from astropy.table import Table
|
|
|
| tab = Table({"a": [1, 2, 3], "b": [4.0, 5.0, 6.0]})
|
| assert len(tab) == 3
|
| assert tab["a"].sum() == 6
|
|
|
|
|
| def t_votable_ascii():
|
| from astropy.io.votable import parse_single_table
|
| from astropy.io.ascii import cparser
|
|
|
|
|
| CHECKS = [
|
| ("import astropy, version 8.0.1", t_import_version),
|
| ("native wcs._wcs (WCS object)", t_native_wcs),
|
| ("native utils.xml._iterparser import", t_native_iterparser),
|
| ("native convolution._convolve", t_native_convolve),
|
| ("native stats sigma_clip", t_native_stats),
|
| ("native io.fits roundtrip", t_native_fits),
|
| ("Time object + unix + scale", t_time_object),
|
| ("units m/km, deg/rad, solMass, mile", t_units),
|
| ("SkyCoord separation + galactic", t_skycoord),
|
| ("Table basics", t_table),
|
| ("votable/ascii native imports", t_votable_ascii),
|
| ]
|
|
|
|
|
| def main():
|
| for name, fn in CHECKS:
|
| check(name, fn)
|
| print("SUMMARY: %d PASS, %d FAIL" % (PASS, FAIL))
|
| return 0 if FAIL == 0 else 1
|
|
|
|
|
| if __name__ == "__main__":
|
| sys.exit(main())
|
|
|