[Numpy-discussion] Automatic string length in recarray

Pierre GM pgmdevlist@gmail....
Wed Nov 4 12:20:19 CST 2009


On Nov 4, 2009, at 11:35 AM, Thomas Robitaille wrote:

>
>
> Pierre GM-2 wrote:
>>
>> As a workwaround, perhaps you could use np.object instead of np.str
>> while defining your array. You can then get the maximum string length
>> by looping, as David suggested, and then use .astype to transform  
>> your
>> array...
>>
>
> I tried this:
>
> np.rec.fromrecords([(1,'hello'),(2,'world')],dtype=[('a',np.int8), 
> ('b',np.object_)])
>
> but I get a TypeError:

Confirmed, it's a bug all right. Would you mind opening a ticket ?  
I'll try to take care of that in the next few days.


More information about the NumPy-Discussion mailing list