From: Chris B. <Chr...@no...> - 2002-06-27 22:06:09
|
Norman Davis wrote: > How is a > non-contiguous array created? By slicing an array. Since slicing created a "view" into the same data, it may not represent a contiguous portion of memory. Example: >>> from Numeric import * >>> a = ones((3,4)) >>> a array([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) >>> a.iscontiguous() 1 # a newly created array will always be contiguous >>> b = a[3:3,:] >>> b.iscontiguous() 1 # sliced this way, you get a contiguous array >>> c = a[:,3:3] >>> c.iscontiguous() 0 #but sliced another way you don't -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |