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

Tim Hochberg tim.hochberg at cox.net
Wed Mar 22 17:57:09 CST 2006

Travis Oliphant wrote:

> Tim Hochberg wrote:
>>> It seems to me that any function or method that returns an array 
>>> from an array should be perfectly consistent and explicit about 
>>> whether it makes a copy or not.  Sometimes the filled method *needs* 
>>> to return a copy; therefore it should *always* return a copy, 
>>> regardless of the presence or state of masking. Hence I think the 
>>> filled method of ma needs to be changed in this way also.
>> +1
>> (mumble mumble reshape mumble)
> Tim makes a good point here.  

And so articulately stated too ;)

> Should the reshape method be fixed to always return a copy?  The 
> semantics a.shape = (...) could still be used to re-shape contiguous 
> arrays where possible. 
> However, whether or not reshape returns a copy is consistent (but 
> perhaps not explicitly explained).
> We will still have .ravel() which sometimes copies and sometimes doesn't.

My opinion is that all methods and functions should either:

    1. Always return a copy.
    2. Always return a view
    3. Return a view if possible otherwise raise an exception.

So, like Sasha, I'd like to see ravel changed as well. I don't really 
care if it's to 1 or 3 though.


More information about the Numpy-discussion mailing list