[SciPy-User] getting started with ndarray
David Goldsmith
d.l.goldsmith at gmail.com
Thu May 6 00:59:06 EDT 2010
BTW Victor: FWIW, the "center" of the ndarray universe is NumPy - though I'm
sure there's a great deal of overlap in the subscribers lists, for your
ndarray-specific questions (indeed, for any object that resides in NumPy, as
opposed to SciPy), it might be more efficient to post to and monitor
numpy-discussion at scipy.org. As a general rule: if it gets imported from
NumPy, ask on the numpy-discussion list, if it gets imported from SciPy, ask
here (scipy-user). But this is just a suggestion - you'll get your numpy
questions answered in either place... (but scipy questions on the numpy
list, that's probably a different story). Again, FWIW
DG
On Wed, May 5, 2010 at 9:48 PM, David Goldsmith <d.l.goldsmith at gmail.com>wrote:
> On Wed, May 5, 2010 at 7:58 PM, Keith Goodman <kwgoodman at gmail.com> wrote:
>
>> On Wed, May 5, 2010 at 7:44 PM, David Goldsmith <d.l.goldsmith at gmail.com>
>> wrote:
>> > On Wed, May 5, 2010 at 7:28 PM, Victor Eijkhout <
>> eijkhout at tacc.utexas.edu>
>> > wrote:
>> >>
>> >> On 2010/05/05, at 9:24 PM, Keith Goodman wrote:
>> >>
>> >> > Here's one way to create arrays:
>> >>
>> >> Thanks. Suppose I don't have the data yet, but I simple want to
>> >> allocate a, oh let's say, 5000x300x20 array?
>> >
>> >>>> import numpy as np
>> >>>> a = np.zeros((5000, 300, 20))
>> >>>> a.shape
>> > (5000L, 300L, 20L)
>> >
>> > IIRC, there's a quicker way if you don't need the array's values
>> > initialized, but I forget what it is.
>>
>> Faster to computer, but slower to grok:
>>
>> >> timeit np.zeros((5000, 300, 20))
>> 10 loops, best of 3: 119 ms per loop
>> >> timeit np.empty((5000, 300, 20))
>> 100000 loops, best of 3: 6.72 us per loop
>> >> timeit x = np.empty((5000, 300, 20)); x.fill(0.0)
>> 10 loops, best of 3: 115 ms per loop
>>
>
> Interesting, thanks guys!
>
> DG
>
>
--
Mathematician: noun, someone who disavows certainty when their uncertainty
set is non-empty, even if that set has measure zero.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100505/30b0d39c/attachment.html>
More information about the SciPy-User
mailing list