-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
MAINT: port _test_fortran.f
to Python functions in test_fortran.py
#23223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
_test_fortran.f
to _test_fortran_py.py
_test_fortran.f
to _test_fortran_py.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @czgdp1807. A few quick comments:
- Why add a new
.py
file for this? These function can simply live intests/test_fortran.py
right? - It'd be good to remove the
.f
and.pyf
files.
@ev-br would you be able to review this PR? I won't have time for the next 2 weeks at least.
I don't have any strong reason to do this. Just did it for following the structure. I am +1 with having these Python functions in the same file.
Sure thing. Removing in a few minutes. |
Indeed same file would be the right place for this. Marked this done in #18566 as well. |
_test_fortran.f
to _test_fortran_py.py
_test_fortran.f
to Python functions in test_fortran.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, tests were checking that a file written by FortranFile.write
roundtrips with both FortranFile.read
and a native Fortran file reading code. This PR removes the Fortran reader and replaces it with pure python code.
So this essentially double-checks FortranFile.read
with an independent python implementation.
The code added here looks sufficiently different from https://github.com/scipy/scipy/blob/v1.16.0/scipy/io/_fortran.py#L33-L354, so it can be regareded as an independent implementation.
The format for Fortran I/O is very unlikely to change, so anything which worked in scipy 1.5 is going to keep working in the future, so removing a native Fortran reader is probably not essential. I suppose we could just remove the reader and rely on roundtripping between FortranFile
reads and writes.
Now that there is an extra implementation, it does not hurt either. If anything, it could serve as simple demo of using np.fromfile
on Fortran-writte files.
@ev-br I have addressed your review. It is ready to go now. |
LGTM, thank you @czgdp1807 |
Reference issue
What does this implement/fix?
In this PR, I am porting the code written in
_test_fortran.f
to_test_fortran_py.py
. Basically, moving to Python from Fortran. AFAICT, this is an effort towards moving away from Fortran at places where Python can be used.If needed I can use C++ instead of pure Python. Let me know.
@rgommers Let me know if this is what's expected.
Additional information