def ensure_compatible(name, value, shape=None, indices=None):
    '\n    Make value compatible with the specified shape or the shape of indices.\n\n    Parameters\n    ----------\n    name : str\n        The name of the value.\n    value : float or list or tuple or ndarray or Iterable\n        The value of a variable.\n    shape : int or tuple or list or None\n        The expected or desired shape of the value.\n    indices : Indexer or None\n        The indices into a source variable.\n\n    Returns\n    -------\n    ndarray\n        The value in a shape compatible with the specified shape and/or indices.\n    tuple\n        The resulting shape of the value.\n\n    Raises\n    ------\n    ValueError\n        If value cannot be made to conform to shape or if shape and indices\n        are incompatible.\n    '
    if isinstance(value, Iterable):
        value = np.asarray(value)
    if (shape is not None):
        if isinstance(shape, numbers.Integral):
            shape = (shape,)
        elif isinstance(shape, list):
            shape = tuple(shape)
    elif (not np.isscalar(value)):
        shape = np.atleast_1d(value).shape
    if (indices is not None):
        if ((not indices._flat_src) and (shape is None)):
            raise RuntimeError(("src_indices for '%s' is not flat, so its input shape must be provided." % name))
        try:
            indshape = indices.indexed_src_shape
        except (RuntimeError, ValueError, TypeError):
            pass
        else:
            if ((shape is not None) and (np.product(indshape) != np.product(shape))):
                raise ValueError(("Shape of indices %s does not match shape of %s for '%s'." % (indshape, shape, name)))
            if (shape is None):
                shape = indshape
    if (shape is None):
        value = np.atleast_1d(value)
        shape = value.shape
    elif (np.isscalar(value) or (value.shape == (1,))):
        value = (np.ones(shape) * value)
    else:
        value = np.atleast_1d(value).astype(np.float64)
        if (value.shape != shape):
            raise ValueError(("Incompatible shape for '%s': Expected %s but got %s." % (name, shape, value.shape)))
    return (value, shape)
Make value compatible with the specified shape or the shape of indices.

Parameters
----------
name : str
    The name of the value.
value : float or list or tuple or ndarray or Iterable
    The value of a variable.
shape : int or tuple or list or None
    The expected or desired shape of the value.
indices : Indexer or None
    The indices into a source variable.

Returns
-------
ndarray
    The value in a shape compatible with the specified shape and/or indices.
tuple
    The resulting shape of the value.

Raises
------
ValueError
    If value cannot be made to conform to shape or if shape and indices
    are incompatible.
def ensure_compatible(name, value, shape=None, indices=None):
    '\n    Make value compatible with the specified shape or the shape of indices.\n\n    Parameters\n    ----------\n    name : str\n        The name of the value.\n    value : float or list or tuple or ndarray or Iterable\n        The value of a variable.\n    shape : int or tuple or list or None\n        The expected or desired shape of the value.\n    indices : Indexer or None\n        The indices into a source variable.\n\n    Returns\n    -------\n    ndarray\n        The value in a shape compatible with the specified shape and/or indices.\n    tuple\n        The resulting shape of the value.\n\n    Raises\n    ------\n    ValueError\n        If value cannot be made to conform to shape or if shape and indices\n        are incompatible.\n    '
    if isinstance(value, Iterable):
        value = np.asarray(value)
    if (shape is not None):
        if isinstance(shape, numbers.Integral):
            shape = (shape,)
        elif isinstance(shape, list):
            shape = tuple(shape)
    elif (not np.isscalar(value)):
        shape = np.atleast_1d(value).shape
    if (indices is not None):
        if ((not indices._flat_src) and (shape is None)):
            raise RuntimeError(("src_indices for '%s' is not flat, so its input shape must be provided." % name))
        try:
            indshape = indices.indexed_src_shape
        except (RuntimeError, ValueError, TypeError):
            pass
        else:
            if ((shape is not None) and (np.product(indshape) != np.product(shape))):
                raise ValueError(("Shape of indices %s does not match shape of %s for '%s'." % (indshape, shape, name)))
            if (shape is None):
                shape = indshape
    if (shape is None):
        value = np.atleast_1d(value)
        shape = value.shape
    elif (np.isscalar(value) or (value.shape == (1,))):
        value = (np.ones(shape) * value)
    else:
        value = np.atleast_1d(value).astype(np.float64)
        if (value.shape != shape):
            raise ValueError(("Incompatible shape for '%s': Expected %s but got %s." % (name, shape, value.shape)))
    return (value, shape)