[Numpy-discussion] ndarray.fill and ma.array.filled
Fernando.Perez at colorado.edu
Thu Mar 23 06:27:07 CST 2006
Tim Hochberg wrote:
> 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.
Well, but is copy/view the /only/ invariant worth guaranteeing? I think there
is a valid need for functions which ensure other invariants, such as
contiguity. There are applications (such as passing pointers to C/Fortran
libraries which don't have striding mechanisms but will not modify their
inputs) which require contiguous inputs, but where one would rather make a
copy only if necessary.
My take on this is that we should /document/ clearly what invariants any given
function satisfies, but I think the 'always view/always copy' view excludes an
important usage case. There may be others beyond contiguity, but that's the
one that pops immediately to mind.
More information about the Numpy-discussion