@@ -1840,7 +1840,6 @@ def test_change_to_dict_return_type() -> None:
1840
1840
# numpy boolean type
1841
1841
(np .bool_ , np .bool_ ),
1842
1842
("bool_" , np .bool_ ),
1843
- ("bool8" , np .bool_ ),
1844
1843
("?" , np .bool_ ),
1845
1844
("b1" , np .bool_ ),
1846
1845
# pyarrow boolean type
@@ -1885,8 +1884,6 @@ def test_change_to_dict_return_type() -> None:
1885
1884
# numpy int64
1886
1885
(np .int_ , np .int_ ),
1887
1886
("int_" , np .int_ ),
1888
- ("long" , np .int_ ),
1889
- ("l" , np .int_ ),
1890
1887
("int64" , np .int64 ),
1891
1888
("i8" , np .int64 ),
1892
1889
# numpy extended int
@@ -1896,7 +1893,6 @@ def test_change_to_dict_return_type() -> None:
1896
1893
# numpy signed pointer (platform dependent one of int[8,16,32,64])
1897
1894
(np .intp , np .intp ),
1898
1895
("intp" , np .intp ),
1899
- ("int0" , np .intp ),
1900
1896
("p" , np .intp ),
1901
1897
# pyarrow integer types
1902
1898
("int8[pyarrow]" , int ),
@@ -1939,8 +1935,6 @@ def test_change_to_dict_return_type() -> None:
1939
1935
# numpy uint64
1940
1936
(np .uint , np .uint ),
1941
1937
("uint" , np .uint ),
1942
- ("ulong" , np .uint ),
1943
- ("L" , np .uint ),
1944
1938
("uint64" , np .uint64 ),
1945
1939
("u8" , np .uint64 ),
1946
1940
# numpy extended uint
@@ -1950,7 +1944,6 @@ def test_change_to_dict_return_type() -> None:
1950
1944
# numpy unsigned pointer (platform dependent one of uint[8,16,32,64])
1951
1945
(np .uintp , np .uintp ),
1952
1946
("uintp" , np .uintp ),
1953
- ("uint0" , np .uintp ),
1954
1947
("P" , np .uintp ),
1955
1948
# pyarrow unsigned integer types
1956
1949
("uint8[pyarrow]" , int ),
@@ -1984,14 +1977,12 @@ def test_change_to_dict_return_type() -> None:
1984
1977
# numpy float64
1985
1978
(np .double , np .double ),
1986
1979
("double" , np .double ),
1987
- ("float_" , np .double ),
1988
1980
("d" , np .double ),
1989
1981
("float64" , np .float64 ),
1990
1982
("f8" , np .float64 ),
1991
1983
# numpy float128
1992
1984
(np .longdouble , np .longdouble ),
1993
1985
("longdouble" , np .longdouble ),
1994
- ("longfloat" , np .longdouble ),
1995
1986
("g" , np .longdouble ),
1996
1987
("f16" , np .longdouble ),
1997
1988
# ("float96", np.longdouble), # NOTE: unsupported
@@ -2011,23 +2002,18 @@ def test_change_to_dict_return_type() -> None:
2011
2002
# numpy complex64
2012
2003
(np .csingle , np .csingle ),
2013
2004
("csingle" , np .csingle ),
2014
- ("singlecomplex" , np .csingle ),
2015
2005
("F" , np .csingle ),
2016
2006
("complex64" , np .complex64 ),
2017
2007
("c8" , np .complex64 ),
2018
2008
# numpy complex128
2019
2009
(np .cdouble , np .cdouble ),
2020
2010
("cdouble" , np .cdouble ),
2021
- ("cfloat" , np .cdouble ),
2022
- ("complex_" , np .cdouble ),
2023
2011
("D" , np .cdouble ),
2024
2012
("complex128" , np .complex128 ),
2025
2013
("c16" , np .complex128 ),
2026
2014
# numpy complex256
2027
2015
(np .clongdouble , np .clongdouble ),
2028
2016
("clongdouble" , np .clongdouble ),
2029
- ("clongfloat" , np .clongdouble ),
2030
- ("longcomplex" , np .clongdouble ),
2031
2017
("G" , np .clongdouble ),
2032
2018
("c32" , np .clongdouble ),
2033
2019
# ("complex192", np.clongdouble), # NOTE: unsupported
@@ -2156,9 +2142,7 @@ def test_change_to_dict_return_type() -> None:
2156
2142
# numpy string
2157
2143
(np .str_ , str ),
2158
2144
("str_" , str ),
2159
- ("str0" , str ),
2160
2145
("unicode" , str ),
2161
- ("unicode_" , str ),
2162
2146
("U" , str ),
2163
2147
# pyarrow string
2164
2148
("string[pyarrow]" , str ),
@@ -2171,10 +2155,7 @@ def test_change_to_dict_return_type() -> None:
2171
2155
# numpy bytes
2172
2156
(np .bytes_ , np .bytes_ ),
2173
2157
("bytes_" , np .bytes_ ),
2174
- ("string_" , np .bytes_ ),
2175
- ("bytes0" , np .bytes_ ),
2176
2158
("S" , np .bytes_ ),
2177
- ("a" , np .bytes_ ),
2178
2159
# pyarrow bytes
2179
2160
("binary[pyarrow]" , bytes ),
2180
2161
]
@@ -2203,7 +2184,6 @@ def test_change_to_dict_return_type() -> None:
2203
2184
(np .void , np .void ),
2204
2185
("void" , np .void ),
2205
2186
("V" , np .void ),
2206
- ("void0" , np .void ),
2207
2187
]
2208
2188
2209
2189
@@ -2222,7 +2202,6 @@ def test_astype_bool(cast_arg: BooleanDtypeArg, target_type: type) -> None:
2222
2202
# numpy boolean type
2223
2203
assert_type (s .astype (np .bool_ ), "pd.Series[bool]" )
2224
2204
assert_type (s .astype ("bool_" ), "pd.Series[bool]" )
2225
- assert_type (s .astype ("bool8" ), "pd.Series[bool]" )
2226
2205
assert_type (s .astype ("?" ), "pd.Series[bool]" )
2227
2206
# pyarrow boolean type
2228
2207
assert_type (s .astype ("bool[pyarrow]" ), "pd.Series[bool]" )
@@ -2278,7 +2257,6 @@ def test_astype_int(cast_arg: IntDtypeArg, target_type: type) -> None:
2278
2257
# numpy int64
2279
2258
assert_type (s .astype (np .int_ ), "pd.Series[int]" )
2280
2259
assert_type (s .astype ("int_" ), "pd.Series[int]" )
2281
- assert_type (s .astype ("int0" ), "pd.Series[int]" )
2282
2260
assert_type (s .astype ("int64" ), "pd.Series[int]" )
2283
2261
assert_type (s .astype ("long" ), "pd.Series[int]" )
2284
2262
assert_type (s .astype ("l" ), "pd.Series[int]" )
@@ -2333,7 +2311,6 @@ def test_astype_uint(cast_arg: IntDtypeArg, target_type: type) -> None:
2333
2311
# numpy uint64
2334
2312
assert_type (s .astype (np .uint ), "pd.Series[int]" )
2335
2313
assert_type (s .astype ("uint" ), "pd.Series[int]" )
2336
- assert_type (s .astype ("uint0" ), "pd.Series[int]" )
2337
2314
assert_type (s .astype ("uint64" ), "pd.Series[int]" )
2338
2315
assert_type (s .astype ("ulong" ), "pd.Series[int]" )
2339
2316
assert_type (s .astype ("L" ), "pd.Series[int]" )
@@ -2385,14 +2362,12 @@ def test_astype_float(cast_arg: FloatDtypeArg, target_type: type) -> None:
2385
2362
# numpy float64
2386
2363
assert_type (s .astype (np .double ), "pd.Series[float]" )
2387
2364
assert_type (s .astype ("double" ), "pd.Series[float]" )
2388
- assert_type (s .astype ("float_" ), "pd.Series[float]" )
2389
2365
assert_type (s .astype ("float64" ), "pd.Series[float]" )
2390
2366
assert_type (s .astype ("d" ), "pd.Series[float]" )
2391
2367
assert_type (s .astype ("f8" ), "pd.Series[float]" )
2392
2368
# numpy float128
2393
2369
assert_type (s .astype (np .longdouble ), "pd.Series[float]" )
2394
2370
assert_type (s .astype ("longdouble" ), "pd.Series[float]" )
2395
- assert_type (s .astype ("longfloat" ), "pd.Series[float]" )
2396
2371
assert_type (s .astype ("float128" ), "pd.Series[float]" )
2397
2372
assert_type (s .astype ("g" ), "pd.Series[float]" )
2398
2373
assert_type (s .astype ("f16" ), "pd.Series[float]" )
@@ -2421,23 +2396,18 @@ def test_astype_complex(cast_arg: ComplexDtypeArg, target_type: type) -> None:
2421
2396
# numpy complex64
2422
2397
assert_type (s .astype (np .csingle ), "pd.Series[complex]" )
2423
2398
assert_type (s .astype ("csingle" ), "pd.Series[complex]" )
2424
- assert_type (s .astype ("singlecomplex" ), "pd.Series[complex]" )
2425
2399
assert_type (s .astype ("complex64" ), "pd.Series[complex]" )
2426
2400
assert_type (s .astype ("F" ), "pd.Series[complex]" )
2427
2401
assert_type (s .astype ("c8" ), "pd.Series[complex]" )
2428
2402
# numpy complex128
2429
2403
assert_type (s .astype (np .cdouble ), "pd.Series[complex]" )
2430
2404
assert_type (s .astype ("cdouble" ), "pd.Series[complex]" )
2431
- assert_type (s .astype ("cfloat" ), "pd.Series[complex]" )
2432
- assert_type (s .astype ("complex_" ), "pd.Series[complex]" )
2433
2405
assert_type (s .astype ("complex128" ), "pd.Series[complex]" )
2434
2406
assert_type (s .astype ("D" ), "pd.Series[complex]" )
2435
2407
assert_type (s .astype ("c16" ), "pd.Series[complex]" )
2436
2408
# numpy complex256
2437
2409
assert_type (s .astype (np .clongdouble ), "pd.Series[complex]" )
2438
2410
assert_type (s .astype ("clongdouble" ), "pd.Series[complex]" )
2439
- assert_type (s .astype ("clongfloat" ), "pd.Series[complex]" )
2440
- assert_type (s .astype ("longcomplex" ), "pd.Series[complex]" )
2441
2411
assert_type (s .astype ("complex256" ), "pd.Series[complex]" )
2442
2412
assert_type (s .astype ("G" ), "pd.Series[complex]" )
2443
2413
assert_type (s .astype ("c32" ), "pd.Series[complex]" )
@@ -2581,9 +2551,7 @@ def test_astype_string(cast_arg: StrDtypeArg, target_type: type) -> None:
2581
2551
# numpy string
2582
2552
assert_type (s .astype (np .str_ ), "pd.Series[str]" )
2583
2553
assert_type (s .astype ("str_" ), "pd.Series[str]" )
2584
- assert_type (s .astype ("str0" ), "pd.Series[str]" )
2585
2554
assert_type (s .astype ("unicode" ), "pd.Series[str]" )
2586
- assert_type (s .astype ("unicode_" ), "pd.Series[str]" )
2587
2555
assert_type (s .astype ("U" ), "pd.Series[str]" )
2588
2556
# pyarrow string
2589
2557
assert_type (s .astype ("string[pyarrow]" ), "pd.Series[str]" )
@@ -2601,8 +2569,6 @@ def test_astype_bytes(cast_arg: BytesDtypeArg, target_type: type) -> None:
2601
2569
# numpy bytes
2602
2570
assert_type (s .astype (np .bytes_ ), "pd.Series[bytes]" )
2603
2571
assert_type (s .astype ("bytes_" ), "pd.Series[bytes]" )
2604
- assert_type (s .astype ("bytes0" ), "pd.Series[bytes]" )
2605
- assert_type (s .astype ("string_" ), "pd.Series[bytes]" )
2606
2572
assert_type (s .astype ("S" ), "pd.Series[bytes]" )
2607
2573
# pyarrow bytes
2608
2574
assert_type (s .astype ("binary[pyarrow]" ), "pd.Series[bytes]" )
@@ -2647,7 +2613,6 @@ def test_astype_void(cast_arg: VoidDtypeArg, target_type: type) -> None:
2647
2613
assert_type (s .astype (np .void ), "pd.Series[Any]" )
2648
2614
assert_type (s .astype ("void" ), "pd.Series[Any]" )
2649
2615
assert_type (s .astype ("V" ), "pd.Series[Any]" )
2650
- assert_type (s .astype ("void0" ), "pd.Series[Any]" )
2651
2616
2652
2617
2653
2618
def test_astype_other () -> None :
@@ -2689,6 +2654,30 @@ def test_all_astype_args_tested() -> None:
2689
2654
"M8" ,
2690
2655
"object_" ,
2691
2656
"object0" ,
2657
+ "a" , # deprecated in numpy 2.0
2658
+ }
2659
+ NON_NUMPY20_ALIASES = {
2660
+ "complex_" ,
2661
+ "unicode_" ,
2662
+ "uint0" ,
2663
+ "longfloat" ,
2664
+ "string_" ,
2665
+ "cfloat" ,
2666
+ "int0" ,
2667
+ "void0" ,
2668
+ "bytes0" ,
2669
+ "singlecomplex" ,
2670
+ "longcomplex" ,
2671
+ "bool8" ,
2672
+ "clongfloat" ,
2673
+ "str0" ,
2674
+ "float_" ,
2675
+ # Next 4 are excluded because results are incompatible between numpy 1.x
2676
+ # and 2.0, and it's not possible to do numpy version specific typing
2677
+ "long" ,
2678
+ "l" ,
2679
+ "ulong" ,
2680
+ "L" ,
2692
2681
}
2693
2682
TESTED_ASTYPE_ARGS : list [tuple [Any , type ]] = (
2694
2683
ASTYPE_BOOL_ARGS
@@ -2708,7 +2697,9 @@ def test_all_astype_args_tested() -> None:
2708
2697
TESTED_ALIASES : set [str ] = {
2709
2698
arg for arg , _ in TESTED_ASTYPE_ARGS if isinstance (arg , str )
2710
2699
}
2711
- UNTESTED_ALIASES = (NUMPY_ALIASES - TESTED_ALIASES ) - EXCLUDED_ALIASES
2700
+ UNTESTED_ALIASES = (
2701
+ NUMPY_ALIASES - TESTED_ALIASES - NON_NUMPY20_ALIASES
2702
+ ) - EXCLUDED_ALIASES
2712
2703
assert not UNTESTED_ALIASES , f"{ UNTESTED_ALIASES } "
2713
2704
2714
2705
NUMPY_TYPES : set [type ] = set (np .sctypeDict .values ())
0 commit comments