Python bindings: Document the constructor arguments under their bound names - #7444
Open
hakonhagland wants to merge 1 commit into
Open
hakonhagland wants to merge 1 commit into
hakonhagland wants to merge 1 commit into
Conversation
The two constructors in docstrings_simulators.json documented their
arguments as
__init__(deck_filename: str)
__init__(deck: Deck, state: EclipseState, schedule: Schedule,
summary_config: SummaryConfig)
but the bindings in python/simulators/Py*Simulator.cpp name them
filename, and Deck, EclipseState, Schedule, SummaryConfig. Passing the
arguments by keyword as documented raises TypeError; only positional
calls worked. OPM#7439 corrected the same kind of mismatch for four
methods, but did not cover the constructors.
Use the bound names in the signatures and in the :param: entries. The
documentation follows the bindings rather than the other way round,
since renaming the bound arguments would break existing keyword calls
such as BlackOilSimulator(filename=...).
Also document the optional args parameter that both constructors take.
It was not mentioned at all. It holds extra command-line options for
the simulator, which are added after the program and deck names and
applied by step_init().
Contributor
Author
|
jenkins build this please |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Documentation matches the bindings and no unresolved issues remain.
Review effort: Lite
Findings: None
What changed in this PR
Updates simulator constructor documentation to match actual Python binding names and documents the optional args parameter.
Changes:
- Corrects constructor signatures and parameter names.
- Adds
argsdescriptions, types, defaults, and examples.
| File | Summary |
|---|---|
python/docstrings_simulators.json |
Updates shared constructor documentation for all simulator classes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
The generated Python API reference documents the two simulator constructors with keyword names that the bindings do not have, so passing arguments by keyword as documented raises
TypeError. It also does not mention the optionalargsparameter. This follows up #7439, which fixed the same kind of mismatch for four methods but did not cover the constructors.py::arg)deck_filenamefilename,argsdeck, state, schedule, summary_configDeck, EclipseState, Schedule, SummaryConfig,argsPositional calls work, and the existing examples use them, which is probably why this has gone unnoticed.
Document the constructor arguments under their bound names (commit 1)
signature_templatestrings and their:param:/:type:lines inpython/docstrings_simulators.jsonto the names passed topy::arginpython/simulators/Py*Simulator.cpp. Those names are identical for all three simulator classes.args, a list of extra command-line options for the simulator. They are added after the program and deck names and applied bystep_init(), with the option--enable-async-ecl-output=falsefrompython/test/pytest_common.pyas the example. It defaults to an empty list.BlackOilSimulator(filename=...).-> {{name}}return annotation on__init__.Verification
filename=andDeck=, EclipseState=, Schedule=, SummaryConfig=are accepted; the previously documenteddeck_filename=anddeck=, state=, ...raiseTypeError;args=[...]is accepted.generate_docstring_hpp.pyon the new file for BlackOil, GasWater and OnePhase; all three generated headers compile.deck_filenameandsummary_configgo from 9 occurrences to 0, andargsis now documented for both constructors of all three classes.help()on the constructor of each of the three classes shows the new text, and pybind11's own signature line for each overload, which it takes from the binding, now lists the same argument names as the docstring below it. Rerunning the keyword calls against the rebuilt modules gives the same results as above.