Reaction kinetics: split setRate into rate/probability/binding_radius properties#161
Open
dilawar wants to merge 2 commits into
Open
Reaction kinetics: split setRate into rate/probability/binding_radius properties#161dilawar wants to merge 2 commits into
setRate into rate/probability/binding_radius properties#161dilawar wants to merge 2 commits into
Conversation
…properties Reaction.setRate was a single method doing three jobs based on a rate<0 sentinel, mirroring libsmoldyn's overloaded smolSetReactionRate(..., isinternal). Replace it with three property setters, one per kinetic quantity, each routing to setReactionRate with the correct isinternal value: - .rate -> isinternal=0 (macroscopic rate) - .reaction_probability -> isinternal=1 (unimol) or 2 (bimol) - .binding_radius -> isinternal=1 (bimolecular only) probability and binding_radius have no C-side getter (libsmoldyn exposes no smolGetReactionProbability or smolGetReactionBindingRadius), so their property getters return last-set values cached on the instance. setRate stays as a deprecated shim with the old sentinel semantics preserved, so back-compat callers still work but get a DeprecationWarning. Reaction.__init__ now uses the properties directly rather than setRate.
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.
Stack
setRateintorate/probability/binding_radiusproperties #161 (this PR) — Reaction kinetics property refactorSummary
The Python wrapper's
Reaction.setRate(rate, reaction_probability, binding_radius)was a single method doing three jobs, dispatched via arate < 0sentinel — mirroring libsmoldyn's overloadedsmolSetReactionRate(..., isinternal). This PR splits the Python surface into three single-purpose property setters:r.ratesmolSetReactionRate(..., isinternal=0)r.reaction_probabilitysmolSetReactionRate(..., isinternal=1)(unimol) or2(bimol)r.binding_radiussmolSetReactionRate(..., isinternal=1)(bimol only, asserted)smolSetReactionRateis unchanged — the C API stays as-is, the wrapper just stops exposing its polymorphic shape.Notes
setRateremains as a back-compat shim that emitsDeprecationWarning. The oldrate < 0sentinel semantics are preserved inside the shim.reaction_probabilityandbinding_radiushave no C-side getter (libsmoldyn exposes nosmolGetReactionProbabilityorsmolGetReactionBindingRadius), so their property getters return last-set values cached on the instance.smolGetReactionRateC function andgetReactionRatepybind11 binding that land in More unit tests and some fixes #160.Test plan
pytest tests/test_reaction.py— 31 tests pass (was 17 in More unit tests and some fixes #160, +14 new for property setters + deprecation shim)make lint(mypy --strict + flake8) cleanmake fix(added in More unit tests and some fixes #160) leaves the file unchanged