Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- print np.version.version
- N = 10
- # gen ref matrix and permutation
- ref = np.arange(N*N)
- ref.resize(N,N)
- rr = range(N)
- np.random.shuffle(rr)
- arr = ref.copy()
- res = (arr.take(rr,axis=0) == ref[rr,:]).all()
- print "test take, not overwriting:", res
- arr = ref.copy()
- arr.take(rr,axis=0,out=arr,mode="raise")
- print "test not-in-place take:", (arr == ref[rr,:]).all()
- arr = ref.copy()
- arr.take(rr,axis=0,out=arr,mode="clip")
- res = (arr == ref[rr,:]).all()
- print "test in-place take:", res
- if not res:
- print "rr", rr
- print "arr", arr[:,0]
- print "ref", ref[rr,0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement