@@ -141,12 +141,29 @@ def test_infer_dtype_from_scalar_errors():
141
141
142
142
143
143
@pytest .mark .parametrize (
144
- "arr , expected, pandas_dtype" ,
144
+ "value , expected, pandas_dtype" ,
145
145
[
146
146
("foo" , np .object_ , False ),
147
147
(b"foo" , np .object_ , False ),
148
- (1 , np .int_ , False ),
148
+ (1 , np .int64 , False ),
149
149
(1.5 , np .float_ , False ),
150
+ (np .datetime64 ("2016-01-01" ), np .dtype ("M8[ns]" ), False ),
151
+ (Timestamp ("20160101" ), np .dtype ("M8[ns]" ), False ),
152
+ (Timestamp ("20160101" , tz = "UTC" ), np .object_ , False ),
153
+ (Timestamp ("20160101" , tz = "UTC" ), "datetime64[ns, UTC]" , True ),
154
+ ],
155
+ )
156
+ def test_infer_dtype_from_scalar (value , expected , pandas_dtype ):
157
+ dtype , _ = infer_dtype_from_scalar (value , pandas_dtype = pandas_dtype )
158
+ assert is_dtype_equal (dtype , expected )
159
+
160
+ with pytest .raises (TypeError , match = "must be list-like" ):
161
+ infer_dtype_from_array (value , pandas_dtype = pandas_dtype )
162
+
163
+
164
+ @pytest .mark .parametrize (
165
+ "arr, expected, pandas_dtype" ,
166
+ [
150
167
([1 ], np .int_ , False ),
151
168
(np .array ([1 ], dtype = np .int64 ), np .int64 , False ),
152
169
([np .nan , 1 , "" ], np .object_ , False ),
@@ -155,8 +172,6 @@ def test_infer_dtype_from_scalar_errors():
155
172
(Categorical ([1 , 2 , 3 ]), np .int64 , False ),
156
173
(Categorical (list ("aabc" )), "category" , True ),
157
174
(Categorical ([1 , 2 , 3 ]), "category" , True ),
158
- (Timestamp ("20160101" ), np .object_ , False ),
159
- (np .datetime64 ("2016-01-01" ), np .dtype ("=M8[D]" ), False ),
160
175
(date_range ("20160101" , periods = 3 ), np .dtype ("=M8[ns]" ), False ),
161
176
(
162
177
date_range ("20160101" , periods = 3 , tz = "US/Eastern" ),
0 commit comments