analysis: fix getMinNrFluxes crash on all-non-negative scores, drop dead code - #729
Merged
Conversation
…ead code Found while porting getMinNrFluxes to raven-toolbox (SysBioChalmers/raven-gecko-parity#42): passing a scores vector with no negative entry crashed outright. scores(scores>=0)=max(scores(scores<0)) evaluates the right-hand side to an empty array when nothing is negative, and unlike the literal [] MATLAB treats as element deletion, an empty array computed by max() just errors on the size mismatch instead. Clamp to 0 in that case instead, matching the port's own choice for the same edge case. Also removes a fully commented-out Mosek-only exitFlag=-2 branch (guarded by a stale "TODO: modify for cobra/gurobi") that could never execute, and the docstring's matching "-2: optimization time out" case, which was never actually reachable. No change to the MILP formulation itself or to any previously-working input.
edkerk
added a commit
to SysBioChalmers/raven-gecko-parity
that referenced
this pull request
Sep 4, 2026
Empirically verified the failure mode is an outright size-mismatch error, not the silent array-shrinking the note originally guessed at; also notes SysBioChalmers/RAVEN#729, which fixes it upstream.
Function test results306 tests 279 ✅ 1m 7s ⏱️ Results for commit 959b970. |
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.
Summary
Found while porting
getMinNrFluxesto raven-toolbox (SysBioChalmers/raven-gecko-parity#42, SysBioChalmers/raven-toolbox#128): two issues worth fixing independently of the port itself.Crash on an all-non-negative
scoresinput.scores(scores>=0)=max(scores(scores<0))evaluates the right-hand side to an empty array whenever nothing is negative. Unlike the literal[]MATLAB treats as element deletion, an empty array computed bymax()doesn't delete anything — it just errors on the resulting size mismatch (scoreshas 3 elements selected, 0 provided), verified directly:Clamped to 0 in that case instead (every reaction becomes equally, un-weighted) — matching the choice made for the same edge case in the Python port.
Dead code. A fully commented-out Mosek-only branch, guarded by a stale
TODO: modify for cobra/gurobi, could never execute (Mosek support was dropped from RAVEN entirely back in 2.3.0). Removed it along with the docstring's matching-2: optimization time outexit case, which was never actually reachable.No change to the MILP formulation itself, and no change to any input that previously worked.
Test plan
tAnalysistest class: 23/25 passed;getMinNrFluxesReturnsFluxpasses. The 2 failures (getMinimalMediumReturnsMedium,getMinimalMediumExplicitGrowth) are pre-existing and unrelated — a different function entirely, already confirmed unrelated in remove: followFluxes, dead code fully subsumed by printFluxes + followChanged #725/remove: exportToTabDelimited, dead fallback in exportToExcelFormat #727.min_nr_fluxes_toyscenario (getMinNrFluxes.m vs raven-toolbox'sget_min_nr_fluxes, via the scip solver): still MATCH after this change.