[Numpy-discussion] Documentation for dtypes with named fields

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Mar 16 12:11:44 EDT 2010


On Tue, Mar 16, 2010 at 12:08 PM,  <josef.pktd at gmail.com> wrote:
> On Tue, Mar 16, 2010 at 11:52 AM, Skipper Seabold <jsseabold at gmail.com> wrote:
>> On Tue, Mar 16, 2010 at 11:46 AM,  <josef.pktd at gmail.com> wrote:
>>> On Tue, Mar 16, 2010 at 11:34 AM, Skipper Seabold <jsseabold at gmail.com> wrote:
>>>> On Tue, Mar 16, 2010 at 11:20 AM, Sam Tygier
>>>> <Sam.Tygier at hep.manchester.ac.uk> wrote:
>>>>> Thanks for those responses.
>>>>>
>>>>> could the dtype pages in the numpy reference link to the basics.rec page in the user guide?
>>>>>
>>>>> there seem to be some gotchas in list within a list notation.
>>>>>
>>>>> if i have
>>>>> a = array([0,0.1,0.2,0.3,0.4])
>>>>> b =  array((0,0.1,0.2,0.3,0.4), dtype=[('a','f'), ('b','f'), ('c','f'), ('d','f'),('f','f')])
>>>>>
>>>>> then
>>>>>>>> a[[0,1,4]]
>>>>> array([ 0. ,  0.1,  0.4])
>>>>>>>> a[[4,1,0]]
>>>>> array([ 0.4,  0.1,  0. ])
>>>>>
>>>>> but
>>>>>>>> b[['a','b','f']]
>>>>> (0.0, 0.10000000149011612, 0.40000000596046448)
>>>>>>>> b[['f','b','a']]
>>>>> (0.0, 0.10000000149011612, 0.40000000596046448)
>>>>>
>>>>> so i always get the vales back in the original order. is the by design, or a bug?
>>>>>
>>>>
>>>> I've been bitten by this before too and asked the same question with
>>>> no response.  I think it's just a limitation of the design of
>>>> structured arrays.
>>>
>>> It might be by historical design, structured arrays are not really
>>> designed for slicing but I think more like sets of variables.
>>>
>>> But it means it cannot be used directly for the old pattern
>>>
>>> [arr(name) for name in listofnames]
>>>
>>> Skipper, Is this subset selection documented anywhere? I only know
>>> about it because you showed the example.
>>>
>>
>> Just added it and a link to the cookbook for recarrays.  I don't think
>> it will show up until the doc wiki changes are applied(?).
>>
>> http://docs.scipy.org/numpy/docs/numpy.doc.structured_arrays/
>
> looks good, together with the cookbook on .view() it almost covers the
> FAQs for structured arrays
>
> I changed "OK to apply:" to  Yes  so it will get into the docs soon

I also changed the aka to and, to avoid the confusion between
recarrays and structured arrays (another FAQ)

Structured Arrays (aka Record Arrays)
to
Structured Arrays (and Record Arrays)

Josef

>
> Josef
>>
>> Skipper
>> _______________________________________________
>> 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