Skip to content

Remove TestFunction.pre_process_lines()#253

Merged
avalentino merged 2 commits into
liberfa:mainfrom
eerovaher:TestFunction-pre_process_lines
May 21, 2026
Merged

Remove TestFunction.pre_process_lines()#253
avalentino merged 2 commits into
liberfa:mainfrom
eerovaher:TestFunction-pre_process_lines

Conversation

@eerovaher
Copy link
Copy Markdown
Contributor

Making better use of Python's regex functionality allows eliminating the TestFunction.pre_process_lines() method. There are a few differences between the erfa/tests/test_ufunc.py files generated by current main and this PR, but they are all improvements:

1565,1566c1565,1566
<     r5  = 1.76779433
<     d5  = -0.2917517103
---
>     r5 = 1.76779433
>     d5 = -0.2917517103
1621,1622c1621,1622
<     psi  = -0.9501954178013015092e-3
<     eps  = 0.4091014316587367472
---
>     psi = -0.9501954178013015092e-3
>     eps = 0.4091014316587367472
1638,1639c1638,1639
<     psi  = -0.9501954178013015092e-3
<     eps  = 0.4091014316587367472
---
>     psi = -0.9501954178013015092e-3
>     eps = 0.4091014316587367472
1778,1779c1778,1779
<     rh  = 1.767794352
<     dh  = -0.2917512594
---
>     rh = 1.767794352
>     dh = -0.2917512594
3343c3343
<     ra1 =  0.01686756
---
>     ra1 = 0.01686756
3347c3347
<     px1 =  0.74723
---
>     px1 = 0.74723
3361c3361
<     ra =  0.01686756
---
>     ra = 0.01686756
3365c3365
<     px =  0.74723
---
>     px = 0.74723

eerovaher added 2 commits May 21, 2026 15:56
Among other things `erfa_generator` translates the tests in an ERFA C
file into a `pytest` test suite that checks `pyerfa` ufuncs. The source
code for each test is found with a regex, but so far `erfa_generator`
has simply assumed a match is always found. This assumption is true with
the current version of ERFA, but it might not be true with all future
versions. From now on if the test for an ERFA function cannot be found
the error message will contain the function's name.
The method was meant to adjust the source code of an ERFA test written
in C into a more convenient format, but using Python's regex
functionality allows conversion into an even more convenient format with
much less code.
@avalentino avalentino merged commit 28d83c1 into liberfa:main May 21, 2026
28 checks passed
@eerovaher eerovaher deleted the TestFunction-pre_process_lines branch May 21, 2026 15:19
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