[Numpy-discussion] numpy.filled, again
Wed Jun 12 13:43:48 CDT 2013
On 2013/06/12 2:10 AM, Nathaniel Smith wrote:
> Hi all,
> It looks like we've gotten a bit confused and need to untangle
> something. There's a PR to add new functions 'np.filled' and
> And there was a discussion about this on the list back in January:
> I think a reasonable summary of the opinions in the thread are:
> - This functionality is great, ...
> - ...but we can't call it 'np.filled' because there's also
> 'np.ma.filled' which does something else...
> - ...but there really aren't any better names...
How about 'np.initialized'?
> - ...so we should overload np.empty, like: 'np.empty(shape, fill=value)'
> In the mean time the original submitter has continued puttering along
> polishing the original patch, and it's ready to merge... except it's
> still the original interface, somehow the thread discussion and the PR
> discussion never met up.
> So, we have to decide what to do.
> Personally I think that overloading np.empty is horribly ugly, will
> continue confusing newbies and everyone else indefinitely, and I'm
> 100% convinced that we'll regret implementing such a warty interface
> for something that should be so idiomatic. (Unfortunately I got busy
> and didn't actually say this in the previous thread though.) So I
> think we should just merge the PR as is. The only downside is the
> np.ma inconsistency, but, np.ma is already inconsistent (cf.
> masked_array.fill versus masked_array.filled!), somewhat deprecated,
"somewhat deprecated"? Really? Since when? By whom? Replaced by what?
> and AFAICT there are far more people who will benefit from a clean
> np.filled idiom than who actually use np.ma (and in particular its
> fill-value functionality). So there would be two
I think there are more np.ma users than you realize. Everyone who uses
matplotlib is using np.ma at least implicitly, if not explicitly. Many
of the matplotlib examples put np.ma to good use. np.ma.filled is an
essential long-standing part of the np.ma API. I don't see any good
rationale for generating a conflict with it, when an adequate
non-conflicting alternative ('np.initialized', maybe others) exists.
> bad-but-IMHO-acceptable options: either live with an inconsistency
> between np.filled and np.ma.filled, or deprecate np.ma.filled in favor
> of masked_array.filled (which does exactly the same thing) and
> eventually switch np.ma.filled to be consistent with the new
> But, that's just my opinion.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion