Skip to content

Commit 5a91c53

Browse files
h-vetinarijreback
authored andcommitted
TST: fix fixture for numpy dtypes (#23983)
1 parent 87c6433 commit 5a91c53

File tree

2 files changed

+78
-47
lines changed

2 files changed

+78
-47
lines changed

pandas/conftest.py

+73-45
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,17 @@ def tz_aware_fixture(request):
386386
COMPLEX_DTYPES = [complex, "complex64", "complex128"]
387387
STRING_DTYPES = [str, 'str', 'U']
388388

389+
DATETIME_DTYPES = ['datetime64[ns]', 'M8[ns]']
390+
TIMEDELTA_DTYPES = ['timedelta64[ns]', 'm8[ns]']
391+
392+
BOOL_DTYPES = [bool, 'bool']
393+
BYTES_DTYPES = [bytes, 'bytes']
394+
OBJECT_DTYPES = [object, 'object']
395+
389396
ALL_REAL_DTYPES = FLOAT_DTYPES + ALL_INT_DTYPES
390-
ALL_NUMPY_DTYPES = ALL_REAL_DTYPES + COMPLEX_DTYPES + STRING_DTYPES
397+
ALL_NUMPY_DTYPES = (ALL_REAL_DTYPES + COMPLEX_DTYPES + STRING_DTYPES
398+
+ DATETIME_DTYPES + TIMEDELTA_DTYPES + BOOL_DTYPES
399+
+ OBJECT_DTYPES + BYTES_DTYPES * PY3) # bytes only for PY3
391400

392401

393402
@pytest.fixture(params=STRING_DTYPES)
@@ -406,8 +415,9 @@ def float_dtype(request):
406415
"""
407416
Parameterized fixture for float dtypes.
408417
409-
* float32
410-
* float64
418+
* float
419+
* 'float32'
420+
* 'float64'
411421
"""
412422

413423
return request.param
@@ -418,8 +428,9 @@ def complex_dtype(request):
418428
"""
419429
Parameterized fixture for complex dtypes.
420430
421-
* complex64
422-
* complex128
431+
* complex
432+
* 'complex64'
433+
* 'complex128'
423434
"""
424435

425436
return request.param
@@ -430,10 +441,11 @@ def sint_dtype(request):
430441
"""
431442
Parameterized fixture for signed integer dtypes.
432443
433-
* int8
434-
* int16
435-
* int32
436-
* int64
444+
* int
445+
* 'int8'
446+
* 'int16'
447+
* 'int32'
448+
* 'int64'
437449
"""
438450

439451
return request.param
@@ -444,10 +456,10 @@ def uint_dtype(request):
444456
"""
445457
Parameterized fixture for unsigned integer dtypes.
446458
447-
* uint8
448-
* uint16
449-
* uint32
450-
* uint64
459+
* 'uint8'
460+
* 'uint16'
461+
* 'uint32'
462+
* 'uint64'
451463
"""
452464

453465
return request.param
@@ -456,16 +468,17 @@ def uint_dtype(request):
456468
@pytest.fixture(params=ALL_INT_DTYPES)
457469
def any_int_dtype(request):
458470
"""
459-
Parameterized fixture for any integer dtypes.
471+
Parameterized fixture for any integer dtype.
460472
461-
* int8
462-
* uint8
463-
* int16
464-
* uint16
465-
* int32
466-
* uint32
467-
* int64
468-
* uint64
473+
* int
474+
* 'int8'
475+
* 'uint8'
476+
* 'int16'
477+
* 'uint16'
478+
* 'int32'
479+
* 'uint32'
480+
* 'int64'
481+
* 'uint64'
469482
"""
470483

471484
return request.param
@@ -474,18 +487,20 @@ def any_int_dtype(request):
474487
@pytest.fixture(params=ALL_REAL_DTYPES)
475488
def any_real_dtype(request):
476489
"""
477-
Parameterized fixture for any (purely) real numeric dtypes.
490+
Parameterized fixture for any (purely) real numeric dtype.
478491
479-
* int8
480-
* uint8
481-
* int16
482-
* uint16
483-
* int32
484-
* uint32
485-
* int64
486-
* uint64
487-
* float32
488-
* float64
492+
* int
493+
* 'int8'
494+
* 'uint8'
495+
* 'int16'
496+
* 'uint16'
497+
* 'int32'
498+
* 'uint32'
499+
* 'int64'
500+
* 'uint64'
501+
* float
502+
* 'float32'
503+
* 'float64'
489504
"""
490505

491506
return request.param
@@ -496,21 +511,34 @@ def any_numpy_dtype(request):
496511
"""
497512
Parameterized fixture for all numpy dtypes.
498513
499-
* int8
500-
* uint8
501-
* int16
502-
* uint16
503-
* int32
504-
* uint32
505-
* int64
506-
* uint64
507-
* float32
508-
* float64
509-
* complex64
510-
* complex128
514+
* bool
515+
* 'bool'
516+
* int
517+
* 'int8'
518+
* 'uint8'
519+
* 'int16'
520+
* 'uint16'
521+
* 'int32'
522+
* 'uint32'
523+
* 'int64'
524+
* 'uint64'
525+
* float
526+
* 'float32'
527+
* 'float64'
528+
* complex
529+
* 'complex64'
530+
* 'complex128'
511531
* str
512532
* 'str'
513533
* 'U'
534+
* bytes
535+
* 'bytes'
536+
* 'datetime64[ns]'
537+
* 'M8[ns]'
538+
* 'timedelta64[ns]'
539+
* 'm8[ns]'
540+
* object
541+
* 'object'
514542
"""
515543

516544
return request.param

pandas/tests/series/test_duplicates.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ def __ne__(self, other):
9191
('last', Series([False, True, True, False, False, False, False])),
9292
(False, Series([False, True, True, False, True, True, False]))
9393
])
94-
def test_drop_duplicates_non_bool(any_numpy_dtype, keep, expected):
95-
tc = Series([1, 2, 3, 5, 3, 2, 4], dtype=np.dtype(any_numpy_dtype))
94+
def test_drop_duplicates(any_numpy_dtype, keep, expected):
95+
tc = Series([1, 0, 3, 5, 3, 0, 4], dtype=np.dtype(any_numpy_dtype))
96+
97+
if tc.dtype == 'bool':
98+
pytest.skip('tested separately in test_drop_duplicates_bool')
9699

97100
tm.assert_series_equal(tc.duplicated(keep=keep), expected)
98101
tm.assert_series_equal(tc.drop_duplicates(keep=keep), tc[~expected])

0 commit comments

Comments
 (0)