def _collect_scalars(values):
    """Given a list containing scalars (float or int) collect scalars
    into a single prefactor. Input list is modified."""

    prefactor = 1.0
    for i in range(len(values)-1, -1, -1):
        if isinstance(values[i], (int, float)):
            prefactor *= values.pop(i)

    return prefactor