Re: [Numpy-discussion] x[None] changes x.shape

2007-01-06 Thread Vincent Nijs
Ah ... I did not make the link between newaxis and None. While the proposed solution works I found an alternative that gave me exactly what I was looking for: def foo(x, sel=()) return x[sel] I.e., passing an empty tuple returns the entire array without changing x.shape or making a copy. Vi

Re: [Numpy-discussion] x[None] changes x.shape

2007-01-05 Thread Robert Kern
Vincent Nijs wrote: > 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

[Numpy-discussion] x[None] changes x.shape

2007-01-05 Thread Vincent Nijs
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 arr