Skip to content

Commit bd4ece5

Browse files
authored
REF: remove copy keyword from ensure_foo (pandas-dev#51213)
* REF: remove copy keywd from ensure_foo * mypy fixup
1 parent 99ebe28 commit bd4ece5

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

pandas/_libs/algos.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ def diff_2d(
127127
) -> None: ...
128128
def ensure_platform_int(arr: object) -> npt.NDArray[np.intp]: ...
129129
def ensure_object(arr: object) -> npt.NDArray[np.object_]: ...
130-
def ensure_float64(arr: object, copy=...) -> npt.NDArray[np.float64]: ...
131-
def ensure_int8(arr: object, copy=...) -> npt.NDArray[np.int8]: ...
132-
def ensure_int16(arr: object, copy=...) -> npt.NDArray[np.int16]: ...
133-
def ensure_int32(arr: object, copy=...) -> npt.NDArray[np.int32]: ...
134-
def ensure_int64(arr: object, copy=...) -> npt.NDArray[np.int64]: ...
135-
def ensure_uint64(arr: object, copy=...) -> npt.NDArray[np.uint64]: ...
130+
def ensure_float64(arr: object) -> npt.NDArray[np.float64]: ...
131+
def ensure_int8(arr: object) -> npt.NDArray[np.int8]: ...
132+
def ensure_int16(arr: object) -> npt.NDArray[np.int16]: ...
133+
def ensure_int32(arr: object) -> npt.NDArray[np.int32]: ...
134+
def ensure_int64(arr: object) -> npt.NDArray[np.int64]: ...
135+
def ensure_uint64(arr: object) -> npt.NDArray[np.uint64]: ...
136136
def take_1d_int8_int8(
137137
values: np.ndarray, indexer: npt.NDArray[np.intp], out: np.ndarray, fill_value=...
138138
) -> None: ...

pandas/_libs/algos_common_helper.pxi.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def get_dispatch(dtypes):
6060
{{for name, c_type, dtype in get_dispatch(dtypes)}}
6161

6262

63-
def ensure_{{name}}(object arr, copy=True):
63+
def ensure_{{name}}(object arr):
6464
if util.is_array(arr):
6565
if (<ndarray>arr).descr.type_num == NPY_{{c_type}}:
6666
return arr
6767
else:
68-
# equiv: arr.astype(np.{{dtype}}, copy=copy)
68+
# equiv: arr.astype(np.{{dtype}})
6969
return cnp.PyArray_Cast(<ndarray>arr, cnp.NPY_{{c_type}})
7070
else:
71-
return np.array(arr, dtype=np.{{dtype}})
71+
return np.asarray(arr, dtype=np.{{dtype}})
7272

7373
{{endfor}}

pandas/core/reshape/merge.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -2149,10 +2149,14 @@ def injection(obj):
21492149
# upcast 'by' parameter because HashTable is limited
21502150
by_type = _get_cython_type_upcast(lbv.dtype)
21512151
by_type_caster = _type_casters[by_type]
2152-
# error: Cannot call function of unknown type
2153-
left_by_values = by_type_caster(lbv) # type: ignore[operator]
2154-
# error: Cannot call function of unknown type
2155-
right_by_values = by_type_caster(rbv) # type: ignore[operator]
2152+
# error: Incompatible types in assignment (expression has type
2153+
# "ndarray[Any, dtype[generic]]", variable has type
2154+
# "List[Union[Union[ExtensionArray, ndarray[Any, Any]], Index, Series]]")
2155+
left_by_values = by_type_caster(lbv) # type: ignore[assignment]
2156+
# error: Incompatible types in assignment (expression has type
2157+
# "ndarray[Any, dtype[generic]]", variable has type
2158+
# "List[Union[Union[ExtensionArray, ndarray[Any, Any]], Index, Series]]")
2159+
right_by_values = by_type_caster(rbv) # type: ignore[assignment]
21562160

21572161
# choose appropriate function by type
21582162
func = _asof_by_function(self.direction)

0 commit comments

Comments
 (0)