fix: sample_from_fva_output crashes with NameError on every call - #138
Open
xovishnukosuri wants to merge 1 commit into
Open
xovishnukosuri wants to merge 1 commit into
xovishnukosuri wants to merge 1 commit into
Conversation
PolytopeSampler.sample_from_fva_output is a @staticmethod but referenced self._parameters["tol"] (lines 294-295), which raises NameError immediately. It also passed the wrong positional arguments to get_matrices_of_low_dim_polytope: the call used opt_percentage and the undefined name tol where min_fluxes and max_fluxes are expected. Replace self._parameters["tol"] with the literal 1e-06 (matching the default set in __init__) and fix the argument order so that min_fluxes and max_fluxes are passed as the lb/ub and fva-bound arguments that get_matrices_of_low_dim_polytope expects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
PolytopeSampler.sample_from_fva_outputis a@staticmethodbut contained two bugs that made it crash withNameErroron every call:self._parameters["tol"](lines 294-295). There is noselfin a static method.get_matrices_of_low_dim_polytope(S, min_fluxes, max_fluxes, opt_percentage, tol)wheretolwas also undefined, and the argument order did not match the function's signature(S, lb, ub, min_fluxes, max_fluxes).Fix
tol = 1e-06locally, matching the default inPolytopeSampler.__init__.min_fluxesandmax_fluxesas thelb/ubarguments toget_matrices_of_low_dim_polytope. When FVA output is the input, the FVA bounds serve as both the flux bounds and the tight bounds for equality detection — the same pattern used inget_polytope().Reproducer
Test plan
python -m pytest tests/fba.py tests/sampling.pyto confirm no regressionsPolytopeSampler.sample_from_fva_outputwithe_coli_coreFVA output and confirm it no longer raisesNameError🤖 Generated with Claude Code