File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ echo PYTHONHASHSEED=$PYTHONHASHSEED
10
10
11
11
COVERAGE=" -s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml"
12
12
13
- PYTEST_CMD=" MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET "
13
+ # TODO: Support NEP 50 and remove NPY_PROMOTION_STATE
14
+ PYTEST_CMD=" NPY_PROMOTION_STATE=legacy MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fEs -n $PYTEST_WORKERS --dist=loadfile $TEST_ARGS $COVERAGE $PYTEST_TARGET "
14
15
15
16
if [[ " $PATTERN " ]]; then
16
17
PYTEST_CMD=" $PYTEST_CMD -m \" $PATTERN \" "
Original file line number Diff line number Diff line change @@ -699,7 +699,7 @@ def _maybe_promote(dtype: np.dtype, fill_value=np.nan):
699
699
dtype = np .dtype (np .object_ )
700
700
701
701
elif issubclass (dtype .type , np .integer ):
702
- if not np . can_cast (fill_value , dtype ):
702
+ if not np_can_cast_scalar (fill_value , dtype ): # type: ignore[arg-type]
703
703
# upcast to prevent overflow
704
704
mst = np .min_scalar_type (fill_value )
705
705
dtype = np .promote_types (dtype , mst )
@@ -1916,4 +1916,25 @@ def _dtype_can_hold_range(rng: range, dtype: np.dtype) -> bool:
1916
1916
"""
1917
1917
if not len (rng ):
1918
1918
return True
1919
- return np .can_cast (rng [0 ], dtype ) and np .can_cast (rng [- 1 ], dtype )
1919
+ return np_can_cast_scalar (rng .start , dtype ) and np_can_cast_scalar (rng .stop , dtype )
1920
+
1921
+
1922
+ def np_can_cast_scalar (element : Scalar , dtype : np .dtype ) -> bool :
1923
+ """
1924
+ np.can_cast pandas-equivalent for pre 2-0 behavior that allowed scalar
1925
+ inference
1926
+
1927
+ Parameters
1928
+ ----------
1929
+ element : Scalar
1930
+ dtype : np.dtype
1931
+
1932
+ Returns
1933
+ -------
1934
+ bool
1935
+ """
1936
+ try :
1937
+ np_can_hold_element (dtype , element )
1938
+ return True
1939
+ except (LossySetitemError , NotImplementedError ):
1940
+ return False
You can’t perform that action at this time.
0 commit comments