You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
438 B
Python

from numpy import asarray, ndarray, ones, nan #, reshape, repeat, product
def valarray(shape, value=nan, typecode=None):
"""Return an array of all value.
"""
#out = reshape(repeat([value],product(shape,axis=0),axis=0),shape)
out = ones(shape, dtype=bool) * value
if typecode is not None:
out = out.astype(typecode)
if not isinstance(out, ndarray):
out = asarray(out)
return out