def detect_best_flux_limit(model):
flux_limit_count = Counter()<EOL>for reaction in model.reactions:<EOL><INDENT>if reaction.id not in model.limits:<EOL><INDENT>continue<EOL><DEDENT>equation = reaction.properties['<STR_LIT>']<EOL>if equation is None:<EOL><INDENT>continue<EOL><DEDENT>_, lower, upper = model.limits[reaction.id]<EOL>if upper is not None and upper > <NUM_LIT:0> and equation.direction.forward:<EOL><INDENT>flux_limit_count[upper] += <NUM_LIT:1><EOL><DEDENT>if lower is not None and -lower > <NUM_LIT:0> and equation.direction.reverse:<EOL><INDENT>flux_limit_count[-lower] += <NUM_LIT:1><EOL><DEDENT><DEDENT>if len(flux_limit_count) == <NUM_LIT:0>:<EOL><INDENT>return None<EOL><DEDENT>best_flux_limit, _ = flux_limit_count.most_common(<NUM_LIT:1>)[<NUM_LIT:0>]<EOL>return best_flux_limit<EOL>
Detect the best default flux limit to use for model output.

    The default flux limit does not change the model but selecting a good
    value reduced the amount of output produced and reduces clutter in the
    output files.