3
3
intended for public consumption
4
4
"""
5
5
from textwrap import dedent
6
- from typing import Dict
6
+ from typing import Callable , Dict
7
7
from warnings import catch_warnings , simplefilter , warn
8
8
9
9
import numpy as np
@@ -1474,7 +1474,9 @@ def _take_nd_object(arr, indexer, out, axis, fill_value, mask_info):
1474
1474
}
1475
1475
1476
1476
1477
- def _get_take_nd_function (ndim , arr_dtype , out_dtype , axis = 0 , mask_info = None ):
1477
+ def _get_take_nd_function (
1478
+ ndim : int , arr_dtype , out_dtype , axis : int = 0 , mask_info = None
1479
+ ) -> Callable :
1478
1480
if ndim <= 2 :
1479
1481
tup = (arr_dtype .name , out_dtype .name )
1480
1482
if ndim == 1 :
@@ -1499,13 +1501,13 @@ def _get_take_nd_function(ndim, arr_dtype, out_dtype, axis=0, mask_info=None):
1499
1501
func = _convert_wrapper (func , out_dtype )
1500
1502
return func
1501
1503
1502
- def func (arr , indexer , out , fill_value = np .nan ):
1504
+ def f (arr , indexer , out , fill_value = np .nan ):
1503
1505
indexer = ensure_int64 (indexer )
1504
1506
_take_nd_object (
1505
1507
arr , indexer , out , axis = axis , fill_value = fill_value , mask_info = mask_info
1506
1508
)
1507
1509
1508
- return func
1510
+ return f
1509
1511
1510
1512
1511
1513
def take (arr , indices , axis = 0 , allow_fill = False , fill_value = None ):
@@ -1691,9 +1693,9 @@ def take_nd(
1691
1693
# at this point, it's guaranteed that dtype can hold both the arr values
1692
1694
# and the fill_value
1693
1695
if out is None :
1694
- out_shape = list (arr .shape )
1695
- out_shape [axis ] = len (indexer )
1696
- out_shape = tuple (out_shape )
1696
+ out_shape_ = list (arr .shape )
1697
+ out_shape_ [axis ] = len (indexer )
1698
+ out_shape = tuple (out_shape_ )
1697
1699
if arr .flags .f_contiguous and axis == arr .ndim - 1 :
1698
1700
# minor tweak that can make an order-of-magnitude difference
1699
1701
# for dataframes initialized directly from 2-d ndarrays
@@ -1935,13 +1937,13 @@ def diff(arr, n, axis=0):
1935
1937
f = _diff_special [arr .dtype .name ]
1936
1938
f (arr , out_arr , n , axis )
1937
1939
else :
1938
- res_indexer = [slice (None )] * arr .ndim
1939
- res_indexer [axis ] = slice (n , None ) if n >= 0 else slice (None , n )
1940
- res_indexer = tuple (res_indexer )
1940
+ res_indexer_ = [slice (None )] * arr .ndim
1941
+ res_indexer_ [axis ] = slice (n , None ) if n >= 0 else slice (None , n )
1942
+ res_indexer = tuple (res_indexer_ )
1941
1943
1942
- lag_indexer = [slice (None )] * arr .ndim
1943
- lag_indexer [axis ] = slice (None , - n ) if n > 0 else slice (- n , None )
1944
- lag_indexer = tuple (lag_indexer )
1944
+ lag_indexer_ = [slice (None )] * arr .ndim
1945
+ lag_indexer_ [axis ] = slice (None , - n ) if n > 0 else slice (- n , None )
1946
+ lag_indexer = tuple (lag_indexer_ )
1945
1947
1946
1948
# need to make sure that we account for na for datelike/timedelta
1947
1949
# we don't actually want to subtract these i8 numbers
0 commit comments