Robert Kern wrote:
> Tim Hochberg wrote:
>> Robert Kern wrote:
>
>>> One possibility is to check if the object is an ndarray (or subclass) and
>>> use
>>> .copy() if so; otherwise, use the current implementation and hope that you
>>> didn't pass it a Numeric or numarray array (or some other view-
Christopher Barker wrote:
> Robert Kern wrote:
>> I don't want to assume that the only two sequence types are lists and arrays.
>
> Does numpy.random.shuffle really have to work on any sequence? and
> without making a copy? I'm not so sure -- having num* functions operate
> on any sequence has b
Robert Kern wrote:
> I don't want to assume that the only two sequence types are lists and arrays.
Does numpy.random.shuffle really have to work on any sequence? and
without making a copy? I'm not so sure -- having num* functions operate
on any sequence has been a design goal of Numeric from the
Robert Kern wrote:
> Tim Hochberg wrote:
>
>> Robert Kern wrote:
>>
>
>
>>> One possibility is to check if the object is an ndarray (or subclass) and
>>> use
>>> .copy() if so; otherwise, use the current implementation and hope that you
>>> didn't pass it a Numeric or numarray array (or
Tim Hochberg wrote:
> Robert Kern wrote:
>> One possibility is to check if the object is an ndarray (or subclass) and use
>> .copy() if so; otherwise, use the current implementation and hope that you
>> didn't pass it a Numeric or numarray array (or some other view-based object).
>>
> I think I
Robert Kern wrote:
> Christopher Barker wrote:
>
>> Robert Kern wrote:
>>
[SNIP]
>>> I copied the algorithm from Python's random
>>> module. At the core of it is a set of swaps:
>>>
>>> x[i], x[j] = x[j], x[i]
>>>
>>> With the kind of sequences that the stdlib random module is expecting
Christopher Barker wrote:
> Robert Kern wrote:
>> This is really a thinko on my part.
>
> What, exactly, is a thinko?
Like a typo except that the fault lies with the brain, not the fingers.
>> I copied the algorithm from Python's random
>> module. At the core of it is a set of swaps:
>>
>> x
Robert Kern wrote:
> This is really a thinko on my part.
What, exactly, is a thinko?
> I copied the algorithm from Python's random
> module. At the core of it is a set of swaps:
>
> x[i], x[j] = x[j], x[i]
>
> With the kind of sequences that the stdlib random module is expecting, that
> mak
Alan G Isaac wrote:
rr=N.array(zip(range(20),range(20)))
pid = N.random.permutation(rr.shape[0])
rr=rr[pid]
rr
> array([[ 9, 9],
>[ 2, 2],
>[ 3, 3],
>[15, 15],
>[ 4, 4],
>[11, 11],
>[18, 18],
>[17, 17],
>[ 5,
On Wed, 22 Nov 2006, Robert apparently wrote:
numpy.random.shuffle(rr)
The docstring is incomplete. From the NumPy Book:
shuffle (sequence)
Randomly permute the items of any sequence. If sequence is an array, then it
must be 1-d.
>>> rr=N.array(zip(range(20),range(20)))
>>> N.
is this an error when shuffle doubles&looses items on a 2-d array? :
>>> r=arange(20)
>>> rr=ziparrays(r,r) #numpy.vstack(*args).transpose()
>>> rr
array([[ 0, 0],
[ 1, 1],
[ 2, 2],
[ 3, 3],
[ 4, 4],
[ 5, 5],
[ 6, 6],
[ 7, 7],
[ 8,
11 matches
Mail list logo