Skip to content

Simplify generating tests for some arrays - #320

Merged
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:tests-subarray-access
Aug 19, 2026
Merged

Simplify generating tests for some arrays#320
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:tests-subarray-access

Conversation

@eerovaher

Copy link
Copy Markdown
Collaborator

Many pyerfa functions return structured arrays so that subarrays can be accessed both by an index or by a named field. For example:

>>> from erfa import ufunc
>>> arr = ufunc.zpv()
>>> arr[0]
array([0., 0., 0.])
>>> arr["p"]
array([0., 0., 0.])

On current main the tests that erfa_generator creates by translating ERFA C code to Python often replace indices with named fields, but the translation is much simpler if the generated tests use indices instead of named fields like the ERFA C tests do. I am not going to paste the difference between the erfa/tests/test_ufunc.py generated on main and in this PR because it is quite large, but I have checked that all the assert statements are still in place and none of the numerical values have changed.

Many `pyerfa` functions return structured arrays so that subarrays can
be accessed both by an index or by a named field. So far when
`erfa_generator` has translated the ERFA C tests to Python it has in
many cases replaced indexing with accessing fields by name, but that has
added complexity to `erfa_generator` that can be avoided by using
indices like the ERFA C tests do.
@avalentino
avalentino merged commit 3875aa3 into liberfa:main Aug 19, 2026
27 checks passed
@eerovaher
eerovaher deleted the tests-subarray-access 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