[Numpy-discussion] x[None] changes x.shape
Vincent Nijs
v-nijs at kellogg.northwestern.edu
Fri Jan 5 18:54:35 CST 2007
Say I use a function that expects a boolean array called sel to be passed as
an argument:
def foo(x,sel = None):
return x[sel]
If x is a 1-d array and sel is a (1-d) boolean array, x.shape will give (n,)
where n is len(x).
However, if the default value None is used (i.e., when no boolean array is
passed) x.shape will give (1,n).
Is that expected behavior?
If so is there an alternative default to I could use that would return the
entire x array and have x.shape be (n,)?
Vincent
More information about the Numpy-discussion
mailing list