# [SciPy-user] once again about zeros() and ones()

dmitrey openopt@ukr....
Sun Jul 1 06:16:35 CDT 2007

```Hi all,
There already was some discussion about zeros() and ones() usage, but I
still can't understand some things.
1) currently ones(4,5, **kwargs) just yields error. Why it can't be
translated to ones((4,5), **kwargs) ?
See my example of Ones() below.
##############################
from numpy import ones
def Ones(*args, **kwargs):
if type(args[0]) in (type(()), type([])):
return ones(*args, **kwargs)
else: return ones(tuple(args), **kwargs)
#############################
if __name__ == '__main__':
print Ones((2,2))
print 2*Ones([2,2])
print 3*Ones(2,2)
print 4*Ones(2,2,2, dtype=float)
print 5*Ones((2,2,2), dtype='float')
print 6*Ones([2,2,2], dtype='int')
print 7*Ones(3,3, dtype=int, order = 'C')
print 8*Ones((3,3), dtype='int')
print 9*Ones(3, dtype='int')
print 10*Ones((3,), dtype='int')
#############################

As one of the former MATLAB users, I'm very disappointed in using
zeros((...)) instead of zeros(...), because I'm one of big number of
those who should type the zeros() many times per day.
Also, same to ones(), tile(), reshape().
2) what does "order" param means? (in
zeros((d1,...,dn),dtype=float,order='C') )
Currently help(zeros) just says
zeros(...)
zeros((d1,...,dn),dtype=float,order='C')
Return a new array of shape (d1,...,dn) and type typecode with all
it's entries initialized to zero.
So nothing about "order" is known

Maybe you have already answered it somewhere, but I guess it's better to
update ones() and zeros() documentation  than answer the question again
and again in mailing lists.

Regards, D.

```