On Thu, May 20, 2010 at 9:44 AM, Benjamin Root <
ben.root@ou.edu> wrote:
>> I gave two counterexamples of why.
>
> The examples you gave aren't counterexamples. See below...
>
> On Wed, May 19, 2010 at 7:06 PM, Darren Dale <
dsdale24@gmail.com> wrote:
>>
>> On Wed, May 19, 2010 at 4:19 PM, <
josef.pktd@gmail.com> wrote:
>> > On Wed, May 19, 2010 at 4:08 PM, Darren Dale <
dsdale24@gmail.com> wrote:
>> >> I have a question about creation of numpy arrays from a list of
>> >> objects, which bears on the Quantities project and also on masked
>> >> arrays:
>> >>
>> >>>>> import quantities as pq
>> >>>>> import numpy as np
>> >>>>> a, b = 2*pq.m,1*pq.s
>> >>>>> np.array([a, b])
>> >> array([ 12., 1.])
>> >>
>> >> Why doesn't that create an object array? Similarly:
>> >>
>
>
> Consider the use case of a person creating a 1-D numpy array:
> > np.array([12.0, 1.0])
> array([ 12., 1.])
>
> How is python supposed to tell the difference between
> > np.array([a, b])
> and
> > np.array([12.0, 1.0])
> ?
>
> It can't, and there are plenty of times when one wants to explicitly
> initialize a small numpy array with a few discrete variables.
What do you mean it can't? 12.0 and 1.0 are floats, a and b are not.