If I create a recarray in this way:
In [29]: np.rec.fromrecords([(1,'hello'),(2,'world')],names=['a','b'])
The result looks fine:
Out[29]:
rec.array([(1, 'hello'), (2, 'world')],
dtype=[('a', '<i8'), ('b', '|S5')])
But if I want to specify the data types:
In [32]: np.rec.fromrecords([(1,'hello'),(2,'world')],dtype=[('a',np.int8),('b',np.str)])
The string is set to a length of zero:
Out[32]:
rec.array([(1, ''), (2, '')],
dtype=[('a', '|i1'), ('b', '|S0')])
I need to specify datatypes for all numerical types since I care about int8/16/32, etc, but I would like to benefit from the auto string length detection that works if I don't specify datatypes. I tried replacing np.str by None but no luck. I know I can specify '|S5' for example, but I don't know in advance what the string length should be set to.