Module wormutils.format_coeff

Functions

def format_coeff(coeff)
Expand source code
def format_coeff(coeff):
    
    """
    Format a reaction coefficient for Plotly/html display.
    """
    if coeff == 1 or coeff == -1:
        coeff = ""
    elif coeff.is_integer() and coeff < 0:
        coeff = str(-int(coeff))
    elif coeff.is_integer() and coeff > 0:
        coeff = str(int(coeff))
    else:
        if coeff < 0:
            coeff = _float_to_formatted_fraction(-coeff)
        else:
            coeff = _float_to_formatted_fraction(coeff)

    if coeff != "":
        coeff = coeff + " "

    return coeff

Format a reaction coefficient for Plotly/html display.