[Numpy-tickets] [NumPy] #297: Nested sequences with different lengths issues
NumPy
numpy-tickets at scipy.net
Wed Sep 27 10:59:59 CDT 2006
#297: Nested sequences with different lengths issues
------------------------+---------------------------------------------------
Reporter: faltet | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.0 Release
Component: numpy.core | Version: devel
Severity: minor | Keywords:
------------------------+---------------------------------------------------
!NumPy is not detecting string nested sequence with different lengths:
{{{
>>> numpy.array(['aaa', ['bbb', 'ccc']])
array([aaa, ['b],
dtype='|S3')
}}}
numarray does:
{{{
>>> numarray.strings.array(['aaa', ['bbb', 'ccc']])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/numarray/strings.py", line 1117,
in array
padc=padc, kind=kind)
File "/usr/lib/python2.4/site-packages/numarray/strings.py", line 977,
in fromlist
shape, itemsize = _slistShape(slist, itemsize=itemsize, shape=shape)
File "/usr/lib/python2.4/site-packages/numarray/strings.py", line 912,
in _slistShape
shape_items = _slistShape0(slist)
File "/usr/lib/python2.4/site-packages/numarray/strings.py", line 887,
in _slistShape0
raise ValueError("Nested sequences with different lengths.")
ValueError: Nested sequences with different lengths.
}}}
and I think this last message is quite adequate for the issue.
Furthermore, I'd say that a message like numarray is better for numerical
nested sequences with different lengths.
NumPy:
{{{
>>> numpy.array([1, [2, 3]])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required
}}}
numarray:
{{{
>>> numarray.array([1, [2, 3]])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line
417, in array
return fromlist(sequence,type,shape)
File "/usr/lib/python2.4/site-packages/numarray/numarraycore.py", line
267, in fromlist
arr.fromlist(seq)
ValueError: Nested sequences with different lengths.
}}}
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/297>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list