[Numpy-discussion] New numpy functions: filled, filled_like

Matthew Brett matthew.brett at gmail.com
Fri Jan 18 17:22:36 EST 2013


Hi,

On Fri, Jan 18, 2013 at 1:48 PM, Pierre Haessig
<pierre.haessig at crans.org> wrote:
> Hi,
> Le 17/01/2013 23:31, Matthew Brett a écrit :
>>> Would it be too weird or clumsy to extend the empty and empty_like functions
>>> >to do the filling?
>>> >
>>> >np.empty((10, 10), fill=np.nan)
>>> >np.empty_like(my_arr, fill=np.nan)
>> That sounds like a good idea to me.  Someone wanting a fast way to
>> fill an array will probably check out the 'empty' docstring first.
> Oh, that sounds very good to me. There is indeed a bit of contradictions
> between "empty" and "fill" but maybe not that strong if we think of
> "empty" as a "void of actual information". (Especially true when the
> fill value is nan or inf, which, as Ben just mentionned are probably the
> most commonly used fill value after zero.)
>
> Maybe a keyword named "value" instead of "fill" may help soften the
> semantic opposition with "empty" ?

I personally find 'fill' OK.  I'd read:

a = np.empty((10, 10), fill=np.nan)

as

"make an empty array shape (10, 10) and fill with nans"

Which would indeed be what the code was doing :)  So I doubt that the
semantic clash would cause any long term problems,

Best,

Matthew



More information about the NumPy-Discussion mailing list