Return x if it is an array or create an array and fill it with x.

def numberarray(x, shape):
    """Return x if it is an array or create an array and fill it with x."""
    try:
        iter(x)
    except TypeError:
        return numpy.ones(shape) * x
    else:
        return x