2
2
import operator
3
3
import sys
4
4
5
+ import numpy as np
5
6
import pytest
6
7
7
8
import pandas as pd
13
14
make_data ,
14
15
)
15
16
17
+ # We intentionally don't run base.BaseSetitemTests because pandas'
18
+ # internals has trouble setting sequences of values into scalar positions.
19
+ unhashable = pytest .mark .xfail (reason = "Unhashable" )
20
+
16
21
17
22
@pytest .fixture
18
23
def dtype ():
@@ -73,24 +78,14 @@ def data_for_grouping():
73
78
)
74
79
75
80
76
- class BaseJSON :
77
- pass
78
-
79
-
80
- class TestDtype (BaseJSON , base .BaseDtypeTests ):
81
- pass
82
-
83
-
84
- class TestInterface (BaseJSON , base .BaseInterfaceTests ):
81
+ class TestJSONArray (base .ExtensionTests ):
85
82
@pytest .mark .xfail (
86
83
reason = "comparison method not implemented for JSONArray (GH-37867)"
87
84
)
88
85
def test_contains (self , data ):
89
86
# GH-37867
90
87
super ().test_contains (data )
91
88
92
-
93
- class TestConstructors (BaseJSON , base .BaseConstructorsTests ):
94
89
@pytest .mark .xfail (reason = "not implemented constructor from dtype" )
95
90
def test_from_dtype (self , data ):
96
91
# construct from our dtype & string dtype
@@ -129,8 +124,6 @@ def test_series_constructor_scalar_with_index(self, data, dtype):
129
124
finally :
130
125
sys .setrecursionlimit (rec_limit )
131
126
132
-
133
- class TestReshaping (BaseJSON , base .BaseReshapingTests ):
134
127
@pytest .mark .xfail (reason = "Different definitions of NA" )
135
128
def test_stack (self ):
136
129
"""
@@ -146,16 +139,6 @@ def test_unstack(self, data, index):
146
139
# this matches otherwise
147
140
return super ().test_unstack (data , index )
148
141
149
-
150
- class TestGetitem (BaseJSON , base .BaseGetitemTests ):
151
- pass
152
-
153
-
154
- class TestIndex (BaseJSON , base .BaseIndexTests ):
155
- pass
156
-
157
-
158
- class TestMissing (BaseJSON , base .BaseMissingTests ):
159
142
@pytest .mark .xfail (reason = "Setting a dict as a scalar" )
160
143
def test_fillna_series (self ):
161
144
"""We treat dictionaries as a mapping in fillna, not a scalar."""
@@ -166,15 +149,6 @@ def test_fillna_frame(self):
166
149
"""We treat dictionaries as a mapping in fillna, not a scalar."""
167
150
super ().test_fillna_frame ()
168
151
169
-
170
- unhashable = pytest .mark .xfail (reason = "Unhashable" )
171
-
172
-
173
- class TestReduce (base .BaseReduceTests ):
174
- pass
175
-
176
-
177
- class TestMethods (BaseJSON , base .BaseMethodsTests ):
178
152
@unhashable
179
153
def test_value_counts (self , all_data , dropna ):
180
154
super ().test_value_counts (all_data , dropna )
@@ -240,8 +214,6 @@ def test_equals_same_data_different_object(
240
214
request .applymarker (mark )
241
215
super ().test_equals_same_data_different_object (data )
242
216
243
-
244
- class TestCasting (BaseJSON , base .BaseCastingTests ):
245
217
@pytest .mark .xfail (reason = "failing on np.array(self, dtype=str)" )
246
218
def test_astype_str (self ):
247
219
"""This currently fails in NumPy on np.array(self, dtype=str) with
@@ -250,12 +222,6 @@ def test_astype_str(self):
250
222
"""
251
223
super ().test_astype_str ()
252
224
253
-
254
- # We intentionally don't run base.BaseSetitemTests because pandas'
255
- # internals has trouble setting sequences of values into scalar positions.
256
-
257
-
258
- class TestGroupby (BaseJSON , base .BaseGroupbyTests ):
259
225
@unhashable
260
226
def test_groupby_extension_transform (self ):
261
227
"""
@@ -295,25 +261,147 @@ def test_groupby_extension_no_sort(self):
295
261
"""
296
262
super ().test_groupby_extension_no_sort ()
297
263
298
-
299
- class TestArithmeticOps (BaseJSON , base .BaseArithmeticOpsTests ):
300
264
def test_arith_frame_with_scalar (self , data , all_arithmetic_operators , request ):
301
265
if len (data [0 ]) != 1 :
302
266
mark = pytest .mark .xfail (reason = "raises in coercing to Series" )
303
267
request .applymarker (mark )
304
268
super ().test_arith_frame_with_scalar (data , all_arithmetic_operators )
305
269
306
-
307
- class TestComparisonOps (BaseJSON , base .BaseComparisonOpsTests ):
308
270
def test_compare_array (self , data , comparison_op , request ):
309
271
if comparison_op .__name__ in ["eq" , "ne" ]:
310
272
mark = pytest .mark .xfail (reason = "Comparison methods not implemented" )
311
273
request .applymarker (mark )
312
274
super ().test_compare_array (data , comparison_op )
313
275
276
+ @pytest .mark .xfail (reason = "ValueError: Must have equal len keys and value" )
277
+ def test_setitem_loc_scalar_mixed (self , data ):
278
+ super ().test_setitem_loc_scalar_mixed (data )
279
+
280
+ @pytest .mark .xfail (reason = "ValueError: Must have equal len keys and value" )
281
+ def test_setitem_loc_scalar_multiple_homogoneous (self , data ):
282
+ super ().test_setitem_loc_scalar_multiple_homogoneous (data )
283
+
284
+ @pytest .mark .xfail (reason = "ValueError: Must have equal len keys and value" )
285
+ def test_setitem_iloc_scalar_mixed (self , data ):
286
+ super ().test_setitem_iloc_scalar_mixed (data )
287
+
288
+ @pytest .mark .xfail (reason = "ValueError: Must have equal len keys and value" )
289
+ def test_setitem_iloc_scalar_multiple_homogoneous (self , data ):
290
+ super ().test_setitem_iloc_scalar_multiple_homogoneous (data )
291
+
292
+ @pytest .mark .parametrize (
293
+ "mask" ,
294
+ [
295
+ np .array ([True , True , True , False , False ]),
296
+ pd .array ([True , True , True , False , False ], dtype = "boolean" ),
297
+ pd .array ([True , True , True , pd .NA , pd .NA ], dtype = "boolean" ),
298
+ ],
299
+ ids = ["numpy-array" , "boolean-array" , "boolean-array-na" ],
300
+ )
301
+ def test_setitem_mask (self , data , mask , box_in_series , request ):
302
+ if box_in_series :
303
+ mark = pytest .mark .xfail (
304
+ reason = "cannot set using a list-like indexer with a different length"
305
+ )
306
+ request .applymarker (mark )
307
+ elif not isinstance (mask , np .ndarray ):
308
+ mark = pytest .mark .xfail (reason = "Issues unwanted DeprecationWarning" )
309
+ request .applymarker (mark )
310
+ super ().test_setitem_mask (data , mask , box_in_series )
311
+
312
+ def test_setitem_mask_raises (self , data , box_in_series , request ):
313
+ if not box_in_series :
314
+ mark = pytest .mark .xfail (reason = "Fails to raise" )
315
+ request .applymarker (mark )
316
+
317
+ super ().test_setitem_mask_raises (data , box_in_series )
318
+
319
+ @pytest .mark .xfail (
320
+ reason = "cannot set using a list-like indexer with a different length"
321
+ )
322
+ def test_setitem_mask_boolean_array_with_na (self , data , box_in_series ):
323
+ super ().test_setitem_mask_boolean_array_with_na (data , box_in_series )
324
+
325
+ @pytest .mark .parametrize (
326
+ "idx" ,
327
+ [[0 , 1 , 2 ], pd .array ([0 , 1 , 2 ], dtype = "Int64" ), np .array ([0 , 1 , 2 ])],
328
+ ids = ["list" , "integer-array" , "numpy-array" ],
329
+ )
330
+ def test_setitem_integer_array (self , data , idx , box_in_series , request ):
331
+ if box_in_series :
332
+ mark = pytest .mark .xfail (
333
+ reason = "cannot set using a list-like indexer with a different length"
334
+ )
335
+ request .applymarker (mark )
336
+ super ().test_setitem_integer_array (data , idx , box_in_series )
337
+
338
+ @pytest .mark .xfail (reason = "list indices must be integers or slices, not NAType" )
339
+ @pytest .mark .parametrize (
340
+ "idx, box_in_series" ,
341
+ [
342
+ ([0 , 1 , 2 , pd .NA ], False ),
343
+ pytest .param (
344
+ [0 , 1 , 2 , pd .NA ], True , marks = pytest .mark .xfail (reason = "GH-31948" )
345
+ ),
346
+ (pd .array ([0 , 1 , 2 , pd .NA ], dtype = "Int64" ), False ),
347
+ (pd .array ([0 , 1 , 2 , pd .NA ], dtype = "Int64" ), False ),
348
+ ],
349
+ ids = ["list-False" , "list-True" , "integer-array-False" , "integer-array-True" ],
350
+ )
351
+ def test_setitem_integer_with_missing_raises (self , data , idx , box_in_series ):
352
+ super ().test_setitem_integer_with_missing_raises (data , idx , box_in_series )
353
+
354
+ @pytest .mark .xfail (reason = "Fails to raise" )
355
+ def test_setitem_scalar_key_sequence_raise (self , data ):
356
+ super ().test_setitem_scalar_key_sequence_raise (data )
357
+
358
+ def test_setitem_with_expansion_dataframe_column (self , data , full_indexer , request ):
359
+ if "full_slice" in request .node .name :
360
+ mark = pytest .mark .xfail (reason = "slice is not iterable" )
361
+ request .applymarker (mark )
362
+ super ().test_setitem_with_expansion_dataframe_column (data , full_indexer )
363
+
364
+ @pytest .mark .xfail (reason = "slice is not iterable" )
365
+ def test_setitem_frame_2d_values (self , data ):
366
+ super ().test_setitem_frame_2d_values (data )
367
+
368
+ @pytest .mark .xfail (
369
+ reason = "cannot set using a list-like indexer with a different length"
370
+ )
371
+ @pytest .mark .parametrize ("setter" , ["loc" , None ])
372
+ def test_setitem_mask_broadcast (self , data , setter ):
373
+ super ().test_setitem_mask_broadcast (data , setter )
374
+
375
+ @pytest .mark .xfail (
376
+ reason = "cannot set using a slice indexer with a different length"
377
+ )
378
+ def test_setitem_slice (self , data , box_in_series ):
379
+ super ().test_setitem_slice (data , box_in_series )
380
+
381
+ @pytest .mark .xfail (reason = "slice object is not iterable" )
382
+ def test_setitem_loc_iloc_slice (self , data ):
383
+ super ().test_setitem_loc_iloc_slice (data )
384
+
385
+ @pytest .mark .xfail (reason = "slice object is not iterable" )
386
+ def test_setitem_slice_mismatch_length_raises (self , data ):
387
+ super ().test_setitem_slice_mismatch_length_raises (data )
388
+
389
+ @pytest .mark .xfail (reason = "slice object is not iterable" )
390
+ def test_setitem_slice_array (self , data ):
391
+ super ().test_setitem_slice_array (data )
392
+
393
+ @pytest .mark .xfail (reason = "Fail to raise" )
394
+ def test_setitem_invalid (self , data , invalid_scalar ):
395
+ super ().test_setitem_invalid (data , invalid_scalar )
396
+
397
+ @pytest .mark .xfail (reason = "only integer scalar arrays can be converted" )
398
+ def test_setitem_2d_values (self , data ):
399
+ super ().test_setitem_2d_values (data )
314
400
315
- class TestPrinting (BaseJSON , base .BasePrintingTests ):
316
- pass
401
+ @pytest .mark .xfail (reason = "data type 'json' not understood" )
402
+ @pytest .mark .parametrize ("engine" , ["c" , "python" ])
403
+ def test_EA_types (self , engine , data , request ):
404
+ super ().test_EA_types (engine , data , request )
317
405
318
406
319
407
def custom_assert_series_equal (left , right , * args , ** kwargs ):
0 commit comments