[Numpy-discussion] Failing to understand vectorize behavior
lorenzo bolla
lbolla at gmail.com
Wed Jan 9 09:52:07 EST 2008
I don't think it's expected: mine are cropped to 4 characters!
In [101]: vstrip = vectorize( string.strip)
In [102]: s = [' aaaaaaaaaaaaaa ' , ' bbbbbbbbbbbbbbbbbb ', '
cccccccccccccccccc ']
In [103]:
vstrip(s)
Out[103]:
array(['aaaa', 'bbbb',
'cccc'],
dtype='|S4')
You can obviously use "map", instead.
In [104]: map(string.strip, s)
Out[104]: ['aaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbb', 'cccccccccccccccccc']
hth,
L.
On 1/9/08, David Huard <david.huard at gmail.com> wrote:
>
> Hi all,
>
> I'm having trouble understanding the behavior of vectorize on the
> following example:
>
> >>> import string
> >>> from numpy import vectorize
>
> >>> vstrip = vectorize( string.strip)
> >>> s = [' aaaaaaaaaaaaaa ' , ' bbbbbbbbbbbbbbbbbb ', '
> cccccccccccccccccc ']
> >>> vstrip(s)
> array(['aaaaaaaa', 'bbbbbbbb', 'cccccccc'],
> dtype='|S8')
>
> where all strings are cropped to 8 characters.
> Is this expected ?
>
>
> Thanks,
>
> David
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
--
Lorenzo Bolla
lbolla at gmail.com
http://lorenzobolla.emurse.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080109/d207bf0c/attachment.html>
More information about the NumPy-Discussion
mailing list