¡@

Home 

python Programming Glossary: np.ascontiguousarray

testing whether a Numpy array contains a given row

http://stackoverflow.com/questions/14766194/testing-whether-a-numpy-array-contains-a-given-row

# Unfortunatly you need to use structured arrays sorted np.ascontiguousarray a .view '' a.dtype a.shape 1 .ravel # Actually at this point.. have many b # then that is even better. sorted.sort b_comp np.ascontiguousarray b .view sorted.dtype ind sorted.searchsorted b_comp result sorted.. after viewing it as a recarray . Important you must do the np.ascontiguousarray for safety. It will typically do nothing but if it does it would..

Fast Way to slice image into overlapping patches and merge patches to image

http://stackoverflow.com/questions/16774148/fast-way-to-slice-image-into-overlapping-patches-and-merge-patches-to-image

patchify as follows def patchify img patch_shape img np.ascontiguousarray img # won't make a copy if not needed X Y img.shape x y patch_shape.. a bit patches patchify img 39 39 contiguous_patches np.ascontiguousarray patches contiguous_patches.shape 1 39 2 This doesn't reproduce..

Find unique rows in numpy.array

http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array

0 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 b np.ascontiguousarray a .view np.dtype np.void a.dtype.itemsize a.shape 1 _ idx np.unique.. array 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 EDIT Added np.ascontiguousarray following @seberg's recommendation. This will slow the method..