Skip to content

Simplify extracting arguments from test calls - #319

Merged
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:simpler-test-arg-extraction
Aug 17, 2026
Merged

Simplify extracting arguments from test calls#319
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:simpler-test-arg-extraction

Conversation

@eerovaher

Copy link
Copy Markdown
Collaborator

Among other things erfa_generator translates ERFA C tests to Python tests, which requires extracting arguments from C function calls. On current main there is the _get_funcname_and_args() helper for that purpose, but extracting function names is not useful because whenever the helper is called both the C function name and the corresponding pyerfa function name are already known. The new _args_from_func_call() does not bother with function names and allows deduplicating more code than _get_funcname_and_args() ever did. The full difference between the erfa/tests/test_ufunc.py generated by current main this PR is

583c583
<     ri, di = erfa_ufunc.atciqn (rc, dc, pr, pd, px, rv, astrom, b)
---
>     ri, di = erfa_ufunc.atciqn(rc, dc, pr, pd, px, rv, astrom, b)
749c749
<     rc, dc, j = erfa_ufunc.atoc13 ("R", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     rc, dc, j = erfa_ufunc.atoc13("R", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
755c755
<     rc, dc, j = erfa_ufunc.atoc13 ("H", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     rc, dc, j = erfa_ufunc.atoc13("H", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
761c761
<     rc, dc, j = erfa_ufunc.atoc13 ("A", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     rc, dc, j = erfa_ufunc.atoc13("A", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
782c782
<     ri, di, j = erfa_ufunc.atoi13 ("R", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     ri, di, j = erfa_ufunc.atoi13("R", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
788c788
<     ri, di, j = erfa_ufunc.atoi13 ("H", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     ri, di, j = erfa_ufunc.atoi13("H", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
794c794
<     ri, di, j = erfa_ufunc.atoi13 ("A", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
---
>     ri, di, j = erfa_ufunc.atoi13("A", ob1, ob2, utc1, utc2, dut1, elong, phi, hm, xp, yp, phpa, tc, rh, wl)
1619c1619
<     dr, dd = erfa_ufunc.g2icrs (dl, db)
---
>     dr, dd = erfa_ufunc.g2icrs(dl, db)
1792c1792
<     dl, db = erfa_ufunc.icrs2g (dr, dd)
---
>     dl, db = erfa_ufunc.icrs2g(dr, dd)

In all cases the removal of whitespace is an improvement.

Among other things `erfa_generator` translates ERFA C tests to Python
tests, which requires extracting arguments from C function calls.
Previously this was done by the `_get_funcname_and_args()` helper, but
extracting function names was not useful because whenever the helper was
called both the C function name and the corresponding `pyerfa` function
name were already known. The new `_args_from_func_call()` helper is more
useful.
@avalentino
avalentino merged commit 9cd1c4e into liberfa:main Aug 17, 2026
26 checks passed
@eerovaher
eerovaher deleted the simpler-test-arg-extraction branch August 19, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants