[Numpy-discussion] numpy.filled, again
josef.pktd at gmail.com
josef.pktd at gmail.com
Wed Jun 12 08:57:19 EDT 2013
On Wed, Jun 12, 2013 at 8:47 AM, Daniele Nicolodi <daniele at grinta.net> wrote:
> On 12/06/2013 14:29, Robert Kern wrote:
>> On Wed, Jun 12, 2013 at 1:26 PM, Daniele Nicolodi <daniele at grinta.net> wrote:
>>
>>> There where the additional proposal (mostly neglected on the original
>>> thread) to add the 'fill' optional parameter to the array constructor:
>>>
>>> np.ndarray(shape, fill=value)
>>>
>>> has an obvious meaning to me.
>>>
>>> I also don't really see why an np.empty() constructor exists, it seems
>>> to do the same thing that np.ndarray() does.
>>
>> It predates numpy and the numpy.ndarray type.
>
> I see, but I'm surprised by the fact that np.empty() is not an alias for
> np.ndarray() neither is implemented in term of np.ndarray().
>
> Since the constructor exists and it would be the "most pythonic" way of
> constructing an ndarray object I don't see why it's usage should not be
> encouraged.
>
>>> However, I don't know if
>>> adding a np.ndarray_like() constructor would make much sense.
>>
>> Also that.
>
> I don't understand if you are saying that adding the fill parameter to
> np.ndarray() is a good or a bad idea. If it is a bad idea, what are the
> drawbacks compared to the other two proposed solutions?
The documentation for ndarray says
"Arrays should be constructed using array, zeros or empty (refer to
the See Also section below). The parameters given here refer to a
low-level method (ndarray(...)) for instantiating an array."
I never used ``ndarray``. (5 years +)
Sounds like a change in recommendation and pattern if we start to use
``ndarray`` directly.
I've never seen an argument why we shouldn't use it, it's just not in
any examples or code that I have seen. AFAICR
Josef
>
> Cheers,
> Daniele
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list