Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API: Update lib.index_tricks namespace #24581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@
del ta

from . import lib
from .lib import (
c_, diag_indices, diag_indices_from, emath, index_exp, ix_,
mgrid, ndenumerate, ndindex, ogrid, fill_diagonal,
r_, ravel_multi_index, s_, unravel_index
)
from .lib import emath
from .lib._histograms_impl import (
histogram, histogram_bin_edges, histogramdd
)
Expand Down Expand Up @@ -235,6 +231,11 @@
savetxt, loadtxt, genfromtxt, load, save, savez, packbits,
savez_compressed, unpackbits, fromregex
)
from .lib._index_tricks_impl import (
diag_indices_from, diag_indices, fill_diagonal, ndindex, ndenumerate,
ix_, c_, r_, s_, ogrid, mgrid, unravel_index, ravel_multi_index,
index_exp
)
from . import matrixlib as _mat
from .matrixlib import (
asmatrix, bmat, matrix
Expand Down Expand Up @@ -308,6 +309,7 @@
set(lib._stride_tricks_impl.__all__) |
set(lib._polynomial_impl.__all__) |
set(lib._npyio_impl.__all__) |
set(lib._index_tricks_impl.__all__) |
{"show_config", "__version__"}
)

Expand Down
2 changes: 1 addition & 1 deletion numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ from numpy.lib._histograms_impl import (
histogramdd as histogramdd,
)

from numpy.lib.index_tricks import (
from numpy.lib._index_tricks_impl import (
ravel_multi_index as ravel_multi_index,
unravel_index as unravel_index,
mgrid as mgrid,
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def test_add_doc(self):
tgt = "Current flat index into the array."
assert_equal(np.core.flatiter.index.__doc__[:len(tgt)], tgt)
assert_(len(np.core.ufunc.identity.__doc__) > 300)
assert_(len(np.lib.index_tricks.mgrid.__doc__) > 300)
assert_(len(np.lib._index_tricks_impl.mgrid.__doc__) > 300)

@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
def test_errors_are_ignored(self):
Expand Down
7 changes: 2 additions & 5 deletions numpy/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Private submodules
# load module names. See https://github.com/networkx/networkx/issues/5838
from . import _type_check_impl
from . import index_tricks
from . import _index_tricks_impl
from . import _nanfunctions_impl
from . import _function_base_impl
from . import _stride_tricks_impl
Expand All @@ -38,15 +38,12 @@
from . import _arraypad_impl
from . import _version

from .index_tricks import *
from .arrayterator import Arrayterator
from ._version import *
from numpy.core._multiarray_umath import add_docstring, tracemalloc_domain
from numpy.core.function_base import add_newdoc


__all__ = ['emath']
__all__ += index_tricks.__all__

from numpy._pytesttester import PytestTester
test = PytestTester(__name__)
Expand All @@ -66,7 +63,7 @@ def __getattr__(attr):
elif attr in (
"histograms", "type_check", "nanfunctions", "function_base",
"arraypad", "arraysetops", "ufunclike", "utils", "twodim_base",
"shape_base", "polynomial"
"shape_base", "polynomial", "index_tricks",
):
raise AttributeError(
f"`np.lib.{attr}` is now private. If you are using a public "
Expand Down
15 changes: 0 additions & 15 deletions numpy/lib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ from numpy.lib.arrayterator import (
Arrayterator as Arrayterator,
)

from numpy.lib.index_tricks import (
ravel_multi_index as ravel_multi_index,
unravel_index as unravel_index,
mgrid as mgrid,
ogrid as ogrid,
r_ as r_,
c_ as c_,
s_ as s_,
index_exp as index_exp,
ix_ as ix_,
fill_diagonal as fill_diagonal,
diag_indices as diag_indices,
diag_indices_from as diag_indices_from,
)

from numpy.core.multiarray import (
add_docstring as add_docstring,
tracemalloc_domain as tracemalloc_domain,
Expand Down
2 changes: 1 addition & 1 deletion numpy/lib/_arraypad_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import numpy as np
from numpy.core.overrides import array_function_dispatch
from numpy.lib.index_tricks import ndindex
from numpy.lib._index_tricks_impl import ndindex


__all__ = ['pad']
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion numpy/lib/_shape_base_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from numpy.core import vstack, atleast_3d
from numpy.core.numeric import normalize_axis_tuple
from numpy.core.shape_base import _arrays_for_stack_dispatcher
from numpy.lib.index_tricks import ndindex
from numpy.lib._index_tricks_impl import ndindex
from numpy.matrixlib.defmatrix import matrix # this raises all the right alarm bells


Expand Down
6 changes: 3 additions & 3 deletions numpy/lib/tests/test_index_tricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
assert_, assert_equal, assert_array_equal, assert_almost_equal,
assert_array_almost_equal, assert_raises, assert_raises_regex,
)
from numpy.lib.index_tricks import (
from numpy.lib._index_tricks_impl import (
mgrid, ogrid, ndenumerate, fill_diagonal, diag_indices, diag_indices_from,
index_exp, ndindex, r_, s_, ix_
index_exp, ndindex, c_, r_, s_, ix_
)


Expand Down Expand Up @@ -405,7 +405,7 @@ def test_repeated_input(self):


def test_c_():
a = np.c_[np.array([[1, 2, 3]]), 0, 0, np.array([[4, 5, 6]])]
a = c_[np.array([[1, 2, 3]]), 0, 0, np.array([[4, 5, 6]])]
assert_equal(a, [[1, 2, 3, 0, 0, 4, 5, 6]])


Expand Down
2 changes: 1 addition & 1 deletion numpy/ma/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from numpy.core.multiarray import normalize_axis_index
from numpy.core.numeric import normalize_axis_tuple
from numpy.lib._function_base_impl import _ureduce
from numpy.lib.index_tricks import AxisConcatenator
from numpy.lib._index_tricks_impl import AxisConcatenator


def issequence(seq):
Expand Down
1 change: 0 additions & 1 deletion numpy/tests/test_public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def test_NPY_NO_EXPORT():
"f2py.use_rules",
"fft.helper",
"lib.arrayterator",
"lib.index_tricks",
"lib.user_array", # note: not in np.lib, but probably should just be deleted
"linalg.lapack_lite",
"linalg.linalg",
Expand Down