[Numpy-discussion] numpy.filled, again

Nathaniel Smith njs at pobox.com
Fri Jun 14 12:28:01 EDT 2013

On Wed, Jun 12, 2013 at 8:00 PM, Phil Hodge <hodge at stsci.edu> wrote:
> I would interpret np.filled as a test, asking whether the array is
> filled.  If the function is supposed to do something related to
> assigning values, the name should be a verb.

That's a plausible convention, but it's not the convention that
actually exists for these sorts of functions. 'sorted' gives you an
object with the property of being sorted, it doesn't test for
sortedness. 'reversed' gives you an object with the property of being
reversed, it doesn't test for reversedness. Tests should be named like

Conceptually, this function doesn't assign values -- for that we have
np.fill(), which is a side-effecting operation that fills an existing
array with some value, and does indeed have a verb as a name. The
function we're talking about is like 'sorted' in that it isn't
side-effecting, but instead gives you an object that has a particular


More information about the NumPy-Discussion mailing list