File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -898,17 +898,17 @@ def clean_index_list(list obj):
898898
899899@ cython.boundscheck (False )
900900@ cython.wraparound (False )
901- def max_len_string_array (ndarray[ object , ndim = 1 ] arr):
901+ def max_len_string_array (ndarray arr ):
902902 """ return the maximum size of elements in a 1-dim string array """
903903 cdef:
904904 int i, m, l
905- length = arr.shape[0 ]
905+ int length = arr.shape[0 ]
906906 object v
907907
908908 m = 0
909909 for i from 0 <= i < length:
910910 v = arr[i]
911- if PyString_Check(v) or PyBytes_Check(v):
911+ if PyString_Check(v) or PyBytes_Check(v) or PyUnicode_Check(v) :
912912 l = len (v)
913913
914914 if l > m:
Original file line number Diff line number Diff line change 33import numpy as np
44
55import pandas as pd
6- from pandas .lib import isscalar , item_from_zerodim
6+ from pandas .lib import isscalar , item_from_zerodim , max_len_string_array
77import pandas .util .testing as tm
88from pandas .compat import u
99
10+ class TestMisc (tm .TestCase ):
11+
12+ def test_max_len_string_array (self ):
13+
14+ arr = np .array (['foo' ,'b' ,np .nan ],dtype = 'object' )
15+ self .assertTrue (max_len_string_array (arr ),3 )
16+
17+ # unicode
18+ arr = arr .astype ('U' )
19+ self .assertTrue (max_len_string_array (arr ),3 )
20+
1021class TestIsscalar (tm .TestCase ):
1122 def test_isscalar_builtin_scalars (self ):
1223 self .assertTrue (isscalar (None ))
You can’t perform that action at this time.
0 commit comments