diff --git a/numpy/__init__.py b/numpy/__init__.py index eb65a6bbdc96..673669d44765 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -202,9 +202,7 @@ iscomplexobj, isin, isneginf, isreal, isrealobj, issubclass_, issubsctype, iterable, ix_, kaiser, kron, load, loadtxt, mask_indices, median, meshgrid, mgrid, mintypecode, nan_to_num, - nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean, - nanmedian, nanmin, nanpercentile, nanprod, nanquantile, nanstd, - nansum, nanvar, ndenumerate, ndindex, ogrid, packbits, pad, + ndenumerate, ndindex, ogrid, packbits, pad, percentile, piecewise, place, poly, poly1d, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub, polyval, put_along_axis, quantile, r_, ravel_multi_index, real, real_if_close, @@ -219,6 +217,11 @@ from .lib._histograms_impl import ( histogram, histogram_bin_edges, histogramdd ) + from .lib._nanfunctions_impl import ( + nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean, + nanmedian, nanmin, nanpercentile, nanprod, nanquantile, nanstd, + nansum, nanvar + ) from . import matrixlib as _mat from .matrixlib import ( asmatrix, bmat, mat, matrix @@ -280,6 +283,7 @@ __all__ = list( __numpy_submodules__ | set(core.__all__) | set(lib.__all__) | set(_mat.__all__) | set(lib._histograms_impl.__all__) | + set(lib._nanfunctions_impl.__all__) | {"show_config", "__version__"} ) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index b3560f772467..562672f0879e 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -490,7 +490,7 @@ from numpy.lib.index_tricks import ( diag_indices_from as diag_indices_from, ) -from numpy.lib.nanfunctions import ( +from numpy.lib._nanfunctions_impl import ( nansum as nansum, nanmax as nanmax, nanmin as nanmin, diff --git a/numpy/lib/__init__.py b/numpy/lib/__init__.py index 14414bb0d9cc..49bfb03b97cb 100644 --- a/numpy/lib/__init__.py +++ b/numpy/lib/__init__.py @@ -22,7 +22,7 @@ from . import type_check from . import index_tricks from . import function_base -from . import nanfunctions +from . import _nanfunctions_impl from . import shape_base from . import stride_tricks from . import twodim_base @@ -39,7 +39,6 @@ from .type_check import * from .index_tricks import * from .function_base import * -from .nanfunctions import * from .shape_base import * from .stride_tricks import * from .twodim_base import * @@ -69,7 +68,6 @@ __all__ += utils.__all__ __all__ += arraysetops.__all__ __all__ += npyio.__all__ -__all__ += nanfunctions.__all__ from numpy._pytesttester import PytestTester test = PytestTester(__name__) diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi index ad2b5e2df24b..d9c9eaee7a5a 100644 --- a/numpy/lib/__init__.pyi +++ b/numpy/lib/__init__.pyi @@ -98,23 +98,6 @@ from numpy.lib.index_tricks import ( diag_indices_from as diag_indices_from, ) -from numpy.lib.nanfunctions import ( - nansum as nansum, - nanmax as nanmax, - nanmin as nanmin, - nanargmax as nanargmax, - nanargmin as nanargmin, - nanmean as nanmean, - nanmedian as nanmedian, - nanpercentile as nanpercentile, - nanvar as nanvar, - nanstd as nanstd, - nanprod as nanprod, - nancumsum as nancumsum, - nancumprod as nancumprod, - nanquantile as nanquantile, -) - from numpy.lib.npyio import ( savetxt as savetxt, loadtxt as loadtxt, diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/_nanfunctions_impl.py similarity index 100% rename from numpy/lib/nanfunctions.py rename to numpy/lib/_nanfunctions_impl.py diff --git a/numpy/lib/nanfunctions.pyi b/numpy/lib/_nanfunctions_impl.pyi similarity index 100% rename from numpy/lib/nanfunctions.pyi rename to numpy/lib/_nanfunctions_impl.pyi diff --git a/numpy/lib/tests/test_nanfunctions.py b/numpy/lib/tests/test_nanfunctions.py index 4932f1ab18cc..ba07c6b704d7 100644 --- a/numpy/lib/tests/test_nanfunctions.py +++ b/numpy/lib/tests/test_nanfunctions.py @@ -5,7 +5,7 @@ import numpy as np from numpy.core.numeric import normalize_axis_tuple from numpy.exceptions import AxisError, ComplexWarning -from numpy.lib.nanfunctions import _nan_mask, _replace_nan +from numpy.lib._nanfunctions_impl import _nan_mask, _replace_nan from numpy.testing import ( assert_, assert_equal, assert_almost_equal, assert_raises, assert_raises_regex, assert_array_equal, suppress_warnings @@ -81,7 +81,7 @@ def test_signature_match(self, nan_func, func): def test_exhaustiveness(self): """Validate that all nan functions are actually tested.""" np.testing.assert_equal( - set(self.IDS), set(np.lib.nanfunctions.__all__) + set(self.IDS), set(np.lib._nanfunctions_impl.__all__) ) diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index 9e802e756d2f..262fab7a9120 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -208,7 +208,6 @@ def test_NPY_NO_EXPORT(): "lib.arrayterator", "lib.function_base", "lib.index_tricks", - "lib.nanfunctions", "lib.npyio", "lib.polynomial", "lib.shape_base",