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
14 lines
438 B
Python
14 years ago
|
from numpy import asarray, ndarray, ones, nan #, reshape, repeat, product
|
||
15 years ago
|
|
||
12 years ago
|
def valarray(shape, value=nan, typecode=None):
|
||
15 years ago
|
"""Return an array of all value.
|
||
|
"""
|
||
14 years ago
|
#out = reshape(repeat([value],product(shape,axis=0),axis=0),shape)
|
||
|
out = ones(shape, dtype=bool) * value
|
||
15 years ago
|
if typecode is not None:
|
||
|
out = out.astype(typecode)
|
||
|
if not isinstance(out, ndarray):
|
||
|
out = asarray(out)
|
||
|
return out
|
||
|
|