Use pybind for FortIO#1184
Conversation
4efb195 to
9521987
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates FortIO integration to address FortIO-related failures by switching the Python FortIO wrapper from ResdataPrototype/cwrap-based symbol binding to a new pybind11 extension (resdata.resfile._fortio), and adds additional FortIO tests in both Python and C++.
Changes:
- Add a pybind11 module (
resdata.resfile._fortio) and updatepython/resdata/resfile/fortio.pyto use it for open/seek/close/truncate/filename/ftell operations. - Modify FortIO C++ behavior (notably
fortio_fseek,fortio_data_fseek, andfortio_fread_buffer) and add C++ tests covering these behaviors. - Add Python tests ensuring malformed Fortran records cause
ResdataKW.fread()to returnNone.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rd_tests/test_rd_kw.py | Adds Python regression tests for malformed FortIO record handling. |
| python/resdata/resfile/fortio.py | Switches Python FortIO wrapper to call into the new _fortio pybind module. |
| lib/tests/test_fortio.cpp | Adds Catch2 tests for FortIO open/seek and error cases. |
| lib/resdata/tests/rd_fortio.cpp | Removes instance/safe-cast tests from legacy FortIO tests. |
| lib/resdata/FortIO.cpp | Refactors FortIO C/C++ implementation behavior and error handling. |
| lib/resdata/fortio_pybind.cpp | Introduces pybind11 bridge between Python FortIO and C++ FortIO implementation. |
| lib/include/resdata/FortIO.hpp | Converts header guards to #pragma once and adjusts exported declarations. |
| lib/CMakeLists.txt | Builds/installs the new _fortio pybind11 extension and adds FortIO tests to the suite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a1d1962 to
226f48a
Compare
b368e55 to
d42deda
Compare
67f6357 to
031c8f2
Compare
ajaust
left a comment
There was a problem hiding this comment.
Looks great overall. I have some smaller things that I commented on.
| #include <stdbool.h> | ||
| #include <cstdlib> | ||
| #include <cstdio> | ||
| #include <cstdbool> |
There was a problem hiding this comment.
We can probably remove cstdbool if we compile this as C++ since bool, true, and false are part of the C++ language.
There was a problem hiding this comment.
Ah, didn't notice what I was converting here :D
Note that we keep the somewhat out of place exception in fseek as opposed to returning false to not change to a silent failure on the python side.
No description provided.