import warnings


def duck_require(data, dtype=None, ndmin=0, copy=True, order='K'):
    """
    Return an ndarray-like that satisfies requirements.

    Returns a view if possible.

    Parameters
    ----------
    data : array-like
        Must be an ndarray or ndarray ducktype.
    dtype : numpy datatype
        Datatype to convert to
    ndmin : integer
        Same as 'ndmin' argument of np.array
    copy : bool
        Whether to guarantee a copy is made
    order : one of 'K', 'F', 'C', 'A'
        Same as 'order' argument of np.array
    """

    # we must use only properties that work for ndarray ducktypes.
    # This rules out using np.require

    newdtype = dtype if dtype is not None else data.dtype
    if copy or (newdtype != data.dtype):
        data = data.astype(newdtype, order=order)

    if order != 'K' and order is not None:
        warnings.warn('order parameter of MaskedArray is ignored')

    if ndmin != 0 and data.ndim < ndmin:
        nd = ndmin - data.ndim
        data = data[(None,)*nd + (Ellipsis,)]

    return data