overreact/_cli.py
def _prepare_simulation(scheme, k, concentrations):
    """
    Help prepare some data before the simulation.

    Raises
    ------
    ValueError
        If concentrations are invalid or inconsistent with the scheme.
    """
    free_y0 = {}
    fixed_y0 = {}
    for spec in concentrations:
        fields = spec.split(":", 1)
        name, quantity = fields[0].strip(), fields[1].strip()

        if quantity.startswith("!"):
            d = fixed_y0
            quantity = quantity[1:]
        else:
            d = free_y0

        try:
            quantity = float(quantity)
        except (IndexError, ValueError):
            raise ValueError(
                "badly formatted concentrations: " f"'{' '.join(concentrations)}'"
            )

        d[name] = quantity

    # TODO(schneiderfelipe): log stuff related to get_fixed_scheme
    scheme, k = rx.get_fixed_scheme(scheme, k, fixed_y0)

    y0 = np.zeros(len(scheme.compounds))
    for compound in free_y0:
        y0[scheme.compounds.index(compound)] = free_y0[compound]

    return scheme, k, y0

    Help prepare some data before the simulation.

    Raises
    ------
    ValueError
        If concentrations are invalid or inconsistent with the scheme.
    
Help prepare some data before the simulation.
Raises

ValueError
If concentrations are invalid or inconsistent with the scheme.
Help prepare some data before the simulation . Raises ValueError If concentrations are invalid or inconsistent with the scheme .
def _prepare_simulation(scheme, k, concentrations):
    free_y0 = {}
    fixed_y0 = {}
    for spec in concentrations:
        fields = spec.split(":", 1)
        name, quantity = fields[0].strip(), fields[1].strip()
        if quantity.startswith("!"):
            d = fixed_y0
            quantity = quantity[1:]
        else:
            d = free_y0
        try:
            quantity = float(quantity)
        except (IndexError, ValueError):
            raise ValueError(
                "badly formatted concentrations: " f"'{' '.join(concentrations)}'"
            )
        d[name] = quantity
    scheme, k = rx.get_fixed_scheme(scheme, k, fixed_y0)
    y0 = np.zeros(len(scheme.compounds))
    for compound in free_y0:
        y0[scheme.compounds.index(compound)] = free_y0[compound]
    return scheme, k, y0
def _prepare_simulation ( scheme , k , concentrations ) : free_y0 = { } fixed_y0 = { } for spec in concentrations : fields = spec . split ( ":" , 1 ) name , quantity = fields [ 0 ] . strip ( ) , fields [ 1 ] . strip ( ) if quantity . startswith ( "!" ) : d = fixed_y0 quantity = quantity [ 1 : ] else : d = free_y0 try : quantity = float ( quantity ) except ( IndexError , ValueError ) : raise ValueError ( "badly formatted concentrations: " f"'{' '.join(concentrations)}'" ) d [ name ] = quantity scheme , k = rx . get_fixed_scheme ( scheme , k , fixed_y0 ) y0 = np . zeros ( len ( scheme . compounds ) ) for compound in free_y0 : y0 [ scheme . compounds . index ( compound ) ] = free_y0 [ compound ] return scheme , k , y0
Help prepare some data before the simulation.
Help prepare some data before the simulation .
"""
    Help prepare some data before the simulation.

    Raises
    ------
    ValueError
        If concentrations are invalid or inconsistent with the scheme.
    """ # TODO(schneiderfelipe): log stuff related to get_fixed_scheme
scheme
k
concentrations