Use pybind for FortIO#1184
Open
eivindjahren wants to merge 9 commits into
Open
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
b6d9e28 to
b368e55
Compare
The added logic_error should not be reachable. 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.