File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 17
17
18
18
19
19
def create_vlen_dtype (element_type ):
20
+ if element_type not in (str , bytes ):
21
+ raise TypeError ("Unsupported type for vlen_dtype: `{}`" .format (element_type ))
20
22
# based on h5py.special_dtype
21
23
return np .dtype ("O" , metadata = {"element_type" : element_type })
22
24
@@ -29,11 +31,7 @@ def check_vlen_dtype(dtype):
29
31
30
32
31
33
def is_unicode_dtype (dtype ):
32
- return (
33
- dtype .kind == "U"
34
- or check_vlen_dtype (dtype ) == str
35
- or check_vlen_dtype (dtype ) == np .str_
36
- )
34
+ return dtype .kind == "U" or check_vlen_dtype (dtype ) == str
37
35
38
36
39
37
def is_bytes_dtype (dtype ):
Original file line number Diff line number Diff line change @@ -157,8 +157,10 @@ def _infer_dtype(array, name=None):
157
157
return np .dtype (float )
158
158
159
159
element = array [(0 ,) * array .ndim ]
160
- if isinstance (element , ( bytes , str ) ):
160
+ if isinstance (element , bytes ):
161
161
return strings .create_vlen_dtype (type (element ))
162
+ elif isinstance (element , str ):
163
+ return strings .create_vlen_dtype (str )
162
164
163
165
dtype = np .array (element ).dtype
164
166
if dtype .kind != "O" :
You can’t perform that action at this time.
0 commit comments