NumPy and vectorize

Discussion in 'Python' started by Carl Johan Rehn, Apr 28, 2010.

  1. I'm having problem with the return values of NumPy's vectorize
    function. When I pass an array of strings in the following simple
    example, vectorize truncates the strings in the returned list. Any
    clues of what to do?

    Yours, Carl


    import numpy as np

    def __f(x):
    return x

    f = vectorize(__f)

    s = '2010-04-28'
    y1 = f(s)
    y2 = f(np.array([s, s, s, s]))

    In [62]: y1
    Out[62]:
    array('2010-04-28',
    dtype='|S10')

    In [63]: y2
    Out[63]:
    array(['2010-04-', '2010-04-', '2010-04-', '2010-04-'],
    dtype='|S8')
    Carl Johan Rehn, Apr 28, 2010
    #1
    1. Advertising

  2. Carl Johan Rehn

    Robert Kern Guest

    On 4/28/10 1:48 PM, Carl Johan Rehn wrote:
    > I'm having problem with the return values of NumPy's vectorize
    > function. When I pass an array of strings in the following simple
    > example, vectorize truncates the strings in the returned list. Any
    > clues of what to do?


    You will want to report numpy bugs to the numpy mailing list:

    http://www.scipy.org/Mailing_Lists

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
    Robert Kern, Apr 28, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. drife
    Replies:
    1
    Views:
    353
    Travis E. Oliphant
    Mar 1, 2006
  2. Duncan Smith
    Replies:
    3
    Views:
    409
    Duncan Smith
    Apr 25, 2007
  3. Replies:
    2
    Views:
    479
    Robert Kern
    Nov 13, 2007
  4. W. eWatson
    Replies:
    2
    Views:
    914
    W. eWatson
    Nov 23, 2009
  5. Yaþar Arabacý

    How to np.vectorize __call__ method

    Yaþar Arabacý, Nov 14, 2013, in forum: Python
    Replies:
    0
    Views:
    104
    Yaþar Arabacý
    Nov 14, 2013
Loading...

Share This Page