[Numpy-discussion] Response to PEP suggestions

Robert Kern rkern at ucsd.edu
Thu Feb 17 14:15:21 EST 2005

Fernando Perez wrote:

> I have quite a bit of code doing things like
> try:
>   b=a.flat
> except:
>   b=ravel(a)
> which feels silly.  It would be nice for .flat to be a guaranteed, 
> indexable, no-copy view of the original (even if it's non-contiguous).  
> Granted, the indexing will be costlier for a non-contiguous object, but 
> for the external users this provides a clean API.

Why not just do

   b = ravel(a)


That should work in both cases just fine.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

More information about the NumPy-Discussion mailing list