[Numpy-tickets] [NumPy] #315: Inconsistencies with sequence parameters
NumPy
numpy-tickets at scipy.net
Wed Oct 4 08:39:30 CDT 2006
#315: Inconsistencies with sequence parameters
------------------------+---------------------------------------------------
Reporter: faltet | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0 Release
Component: numpy.core | Version: devel
Severity: normal | Keywords:
------------------------+---------------------------------------------------
Hi,
Is the next behavior intended?
{{{
In [18]:numpy.array([("aaa","x")], dtype="S3,S1")
Out[18]:
array([('aaa', 'x')], # Good
dtype=[('f0', '|S3'), ('f1', '|S1')])
In [19]:numpy.array(["aaa","x"], dtype="S3,S1")
Out[19]:
array([('aaa', '\xb7'), ('x[,', '\x08')], # uh?
dtype=[('f0', '|S3'), ('f1', '|S1')])
In [20]:numpy.array(["aaa","x",24], dtype="S3,S1,i4")
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most
recent call last)
/home/faltet/python.nobackup/numpy/<ipython console>
TypeError: expected a readable buffer object
}}}
i.e. numpy doesn't complain when dtype only contains string types (but,
still, gives bad results).
Furthermore, the above seems to work with rec.array:
{{{
In [22]:numpy.rec.array(["aaa","x"], dtype="S3,S1")
Out[22]:
recarray(('aaa', 'x'),
dtype=[('f0', '|S3'), ('f1', '|S1')])
In [23]:numpy.rec.array(["aaa","x",24], dtype="S3,S1,i4")
Out[23]:
recarray(('aaa', 'x', 24),
dtype=[('f0', '|S3'), ('f1', '|S1'), ('f2', '<i4')])
}}}
Should I understand that rec.array is preferred for getting recarrays from
lists?
Thanks
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/315>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list