[Numpy-discussion] ndarray.fill and ma.array.filled

Fernando Perez Fernando.Perez at colorado.edu
Thu Mar 23 10:07:04 CST 2006

Tim Hochberg wrote:

> a.ravel() seems to be equivalent to reshape(a, [-1]). That is, it 
> returns a flattened, contiguous copy. ascontiguous(a) would be slightly 
> different in that it would preserves the shape of a. In fact I think it 
> would look a lot like:
> def ascontiguous(a):
>     """ascontiguous(a) -> contiguous representation of a.
>     If 'a' is allready contiguous, it is returned unchanged. Otherwise, 
> a contiguous copy
>     is returned.
>    """
>     a = asarray(a)
>     if not a.flags['CONTIGUOUS']:
>        a = array(a)
>     return a

Yup, sorry: I've been thinking too much in terms of raw C (double*) pointers 
so to me, these days everything is 1-d :)  I forgot about shape issues...

But I think we agree on the basic point.



More information about the Numpy-discussion mailing list