def is_solution_spin(solution, default=False):
    """is_solution_spin.

    Figure out if the ``solution`` is a solution to a boolean or a spin model.
    If it cannot be determined (ie if ``solution`` is all 1s), then return
    ``default``.

    Parameters
    ----------
    solution : dict or iterable.
        Either a dictionary that maps variable names to values, or an iterable
        with values. If ``solution`` is a bin type, then all the values should
        be either a 0 or 1. If ``solution`` is a spin type, then all the values
        should be either a 1 or -1.
    default : bool (optional, defaults to ``False``).
        The default answer to return if the solution type cannot be determined.

    Returns
    -------
    res : bool.
        If it is determined that ``solution`` is the solution to a spin model,
        then ``res`` will be ``True``. If it is determined that ``solution``
        is the solution to a boolean model, then `res`` will be ``False``.
        Otherwise, ``res`` will be ``default``.

    Examples
    --------
    >>> is_solution_spin((0, 1, 1, 0))
    False

    >>> is_solution_spin((1, -1, -1, 1))
    True

    >>> is_solution_spin(dict(enumerate((0, 1, 1, 0))))
    False

    >>> is_solution_spin(dict(enumerate((1, -1, -1, 1))))
    True

    In these cases, the default is invoked.

    >>> is_solution_spin((1, 1, 1, 1))
    False
    >>> is_solution_spin((1, 1, 1, 1), default=False)
    False
    >>> is_solution_spin((1, 1, 1, 1), default=True)
    True

    """
    sol = solution.values() if isinstance(solution, dict) else solution
    for v in sol:
        if v == 0:
            return False
        elif v == -1:
            return True
    return default