[Numpy-discussion] ndarray: How to create and initialize with a value other than ones or zeros?

Eric Moore ewm@redtetrahedron....
Thu Jun 6 17:12:10 CDT 2013


James Adams wrote:
> I would like to create an array object and initialize the array's
> values with an arbitrary fill value, like you can do using the ones()
> and zeros() creation routines to create and initialize arrays with
> ones or zeros.  Is there an easy way to do this?  If this isn't
> possible then what is the most efficient way to initialize a numpy
> array with an arbitrary fill value?
>
> In order to provide such an array creation routine I can imagine that
> it'd be as simple as taking the code for ones() and/or zeros() and
> modifying that code so that it provides an additional fill value
> argument and then within the section which does the initialization of
> the array it could use that fill value instead of 1 or 0.  Is this a
> naive assumption?
>
> Thanks in advance for your help with this issue.
>
> --James
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

There's also https://github.com/numpy/numpy/pull/2875 in the queue.

Eric


More information about the NumPy-Discussion mailing list