Travis Oliphant wrote:
> Sebastian Haase wrote:
>> On Wednesday 09 August 2006 15:45, you wrote:
>>
>>> Sebastian Haase wrote:
>>>
>>>> On Wednesday 09 August 2006 15:18, Travis Oliphant wrote:
>>>>
>>>>> If numarray supported it, then we should get NumPy to support it as
>>>>> well
>>>>> unless there is a compelling reason not to. I can't think of any
>>>>> except
>>>>> that it might be hard to make it work. What is '0i4' supposed to mean
>>>>> exactly? Do you get a zero-sized field or is the field not included?
>>>>> I think the former will be much easier than the latter. Would
>>>>> that be
>>>>> O.K.?
>>>>>
>>>> That's exactly what numarray did. The rest of my code is assuming that
>>>> all fields exist (even if they are empty). Otherwise I get a name
>>>> error which is worse than getting an empty array.
>>>>
>>> Do you have a simple code snippet that I could use as a test?
>>>
>>> -Travis
>>>
>>
>> I think this should do it:
>>
>> a = N.arange(10, dtype=N.float32)
>> a.shape = 5,2
>> type_descr = [("int", "<0i4"),("float", "<2f4")]
>> a.dtype = type_descr
>>
>>
>
> I'm not sure what a.shape = (5,2) is supposed to do. I left it in the
> unit-test out because assigning to the data-type you just defined
> already results in
>
> a['float'].shape being (5,2)
>
> If it is left in, then an extra dimension is pushed in and
>
> a['float'].shape is (5,1,2)
>
>
> This is due to the default behavior of assigning data-types when the new
> data-type has a larger but compatibile itemsize then the old itemsize.
I have to admit that I don't understand that statement. I thought - just
"visually" - that a.shape = 5,2 would make a "table" with 2 columns.
Then I could go on and give those columns names...
Or is the problem that the type "2f4" refers to (some sort of) a "single
column" with 2 floats grouped together !?
Thanks for implementing it so quickly,
Sebastian Haase
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion