@@ -618,6 +618,37 @@ def test_decimals(self):
618618 result = lib .infer_dtype (arr , skipna = True )
619619 assert result == 'decimal'
620620
621+ # complex is compatible with nan, so skipna has no effect
622+ @pytest .mark .parametrize ('skipna' , [True , False ])
623+ def test_complex (self , skipna ):
624+ # gets cast to complex on array construction
625+ arr = np .array ([1.0 , 2.0 , 1 + 1j ])
626+ result = lib .infer_dtype (arr , skipna = skipna )
627+ assert result == 'complex'
628+
629+ arr = np .array ([1.0 , 2.0 , 1 + 1j ], dtype = 'O' )
630+ result = lib .infer_dtype (arr , skipna = skipna )
631+ assert result == 'mixed'
632+
633+ # gets cast to complex on array construction
634+ arr = np .array ([1 , np .nan , 1 + 1j ])
635+ result = lib .infer_dtype (arr , skipna = skipna )
636+ assert result == 'complex'
637+
638+ arr = np .array ([1.0 , np .nan , 1 + 1j ], dtype = 'O' )
639+ result = lib .infer_dtype (arr , skipna = skipna )
640+ assert result == 'mixed'
641+
642+ # complex with nans stays complex
643+ arr = np .array ([1 + 1j , np .nan , 3 + 3j ], dtype = 'O' )
644+ result = lib .infer_dtype (arr , skipna = skipna )
645+ assert result == 'complex'
646+
647+ # test smaller complex dtype; will pass through _try_infer_map fastpath
648+ arr = np .array ([1 + 1j , np .nan , 3 + 3j ], dtype = np .complex64 )
649+ result = lib .infer_dtype (arr , skipna = skipna )
650+ assert result == 'complex'
651+
621652 def test_string (self ):
622653 pass
623654
0 commit comments