@@ -8,8 +8,6 @@ from libc.stdlib cimport abs
8
8
cimport numpy as np
9
9
import numpy as np
10
10
11
- from ..externals.six import string_types
12
-
13
11
from sklearn.utils.murmurhash cimport murmurhash3_bytes_s32
14
12
15
13
np.import_array()
@@ -45,7 +43,7 @@ def transform(raw_X, Py_ssize_t n_features, dtype):
45
43
46
44
for x in raw_X:
47
45
for f, v in x:
48
- if isinstance (v, string_types ):
46
+ if isinstance (v, ( str , unicode ) ):
49
47
f = " %s%s%s "
8000
% (f, ' =' , v)
50
48
value = 1
51
49
else :
@@ -55,13 +53,13 @@ def transform(raw_X, Py_ssize_t n_features, dtype):
55
53
continue
56
54
57
55
if isinstance (f, unicode ):
58
- f = f .encode(" utf-8" )
56
+ f = ( < unicode > f) .encode(" utf-8" )
59
57
# Need explicit type check because Murmurhash does not propagate
60
58
# all exceptions. Add "except *" there?
61
59
elif not isinstance (f, bytes):
62
60
raise TypeError (" feature names must be strings" )
63
61
64
- h = murmurhash3_bytes_s32(f, 0 )
62
+ h = murmurhash3_bytes_s32(< bytes > f, 0 )
65
63
66
64
array.resize_smart(indices, len (indices) + 1 )
67
65
indices[len (indices) - 1 ] = abs (h) % n_features
0 commit comments