23
23
import functools
24
24
import warnings
25
25
import numpy as np
26
- from numpy .lib import function_base
26
+ from numpy .lib import _function_base_impl as fnb
27
27
from numpy .core import overrides
28
28
29
29
@@ -1213,9 +1213,9 @@ def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValu
1213
1213
if a .size == 0 :
1214
1214
return np .nanmean (a , axis , out = out , keepdims = keepdims )
1215
1215
1216
- return function_base ._ureduce (a , func = _nanmedian , keepdims = keepdims ,
1217
- axis = axis , out = out ,
1218
- overwrite_input = overwrite_input )
1216
+ return fnb ._ureduce (a , func = _nanmedian , keepdims = keepdims ,
1217
+ axis = axis , out = out ,
1218
+ overwrite_input = overwrite_input )
1219
1219
1220
1220
1221
1221
def _nanpercentile_dispatcher (
@@ -1368,7 +1368,7 @@ def nanpercentile(
1368
1368
1369
1369
"""
1370
1370
if interpolation is not None :
1371
- method = function_base ._check_interpolation_as_method (
1371
+ method = fnb ._check_interpolation_as_method (
1372
1372
method , interpolation , "nanpercentile" )
1373
1373
1374
1374
a = np .asanyarray (a )
@@ -1378,7 +1378,7 @@ def nanpercentile(
1378
1378
q = np .true_divide (q , 100.0 )
1379
1379
# undo any decay that the ufunc performed (see gh-13105)
1380
1380
q = np .asanyarray (q )
1381
- if not function_base ._quantile_is_valid (q ):
1381
+ if not fnb ._quantile_is_valid (q ):
1382
1382
raise ValueError ("Percentiles must be in the range [0, 100]" )
1383
1383
return _nanquantile_unchecked (
1384
1384
a , q , axis , out , overwrite_input , method , keepdims )
@@ -1531,15 +1531,15 @@ def nanquantile(
1531
1531
"""
1532
1532
1533
1533
if interpolation is not None :
1534
- method = function_base ._check_interpolation_as_method (
1534
+ method = fnb ._check_interpolation_as_method (
1535
1535
method , interpolation , "nanquantile" )
1536
1536
1537
1537
a = np .asanyarray (a )
1538
1538
if a .dtype .kind == "c" :
1539
1539
raise TypeError ("a must be an array of real numbers" )
1540
1540
1541
1541
q = np .asanyarray (q )
1542
- if not function_base ._quantile_is_valid (q ):
1542
+ if not fnb ._quantile_is_valid (q ):
1543
1543
raise ValueError ("Quantiles must be in the range [0, 1]" )
1544
1544
return _nanquantile_unchecked (
1545
1545
a , q , axis , out , overwrite_input , method , keepdims )
@@ -1559,14 +1559,14 @@ def _nanquantile_unchecked(
1559
1559
# so deal them upfront
1560
1560
if a .size == 0 :
1561
1561
return np .nanmean (a , axis , out = out , keepdims = keepdims )
1562
- return function_base ._ureduce (a ,
1563
- func = _nanquantile_ureduce_func ,
1564
- q = q ,
1565
- keepdims = keepdims ,
1566
- axis = axis ,
1567
- out = out ,
1568
- overwrite_input = overwrite_input ,
1569
- method = method )
1562
+ return fnb ._ureduce (a ,
1563
+ func = _nanquantile_ureduce_func ,
1564
+ q = q ,
1565
+ keepdims = keepdims ,
1566
+ axis = axis ,
1567
+ out = out ,
1568
+ overwrite_input = overwrite_input ,
1569
+ method = method )
1570
1570
1571
1571
1572
1572
def _nanquantile_ureduce_func (a , q , axis = None , out = None , overwrite_input = False ,
@@ -1604,7 +1604,7 @@ def _nanquantile_1d(arr1d, q, overwrite_input=False, method="linear"):
1604
1604
# convert to scalar
1605
1605
return np .full (q .shape , np .nan , dtype = arr1d .dtype )[()]
1606
1606
1607
- return function_base ._quantile_unchecked (
1607
+ return fnb ._quantile_unchecked (
1608
1608
arr1d , q , overwrite_input = overwrite_input , method = method )
1609
1609
1610
1610
0 commit comments