8000 API: Update lib.index_tricks namespace · numpy/numpy@86c63b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 86c63b3

Browse files
committed
API: Update lib.index_tricks namespace
1 parent 63d9da8 commit 86c63b3

12 files changed

+17
-34
lines changed

numpy/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,7 @@
182182
del ta
183183

184184
from . import lib
185-
from .lib import (
186-
c_, diag_indices, diag_indices_from, emath, index_exp, ix_,
187-
mgrid, ndenumerate, ndindex, ogrid, fill_diagonal,
188-
r_, ravel_multi_index, s_, unravel_index
189-
)
185+
from .lib import emath
190186
from .lib._histograms_impl import (
191187
histogram, histogram_bin_edges, histogramdd
192188
)
@@ -235,6 +231,11 @@
235231
savetxt, loadtxt, genfromtxt, load, save, savez, packbits,
236232
savez_compressed, unpackbits, fromregex
237233
)
234+
from .lib._index_tricks_impl import (
235+
diag_indices_from, diag_indices, fill_diagonal, ndindex, ndenumerate,
236+
ix_, c_, r_, s_, ogrid, mgrid, unravel_index, ravel_multi_index,
237+
index_exp
238+
)
238239
from . import matrixlib as _mat
239240
from .matrixlib import (
240241
asmatrix, bmat, matrix
@@ -308,6 +309,7 @@
308309
set(lib._stride_tricks_impl.__all__) |
309310
set(lib._polynomial_impl.__all__) |
310311
set(lib._npyio_impl.__all__) |
312+
set(lib._index_tricks_impl.__all__) |
311313
{"show_config", "__version__"}
312314
)
313315

numpy/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ from numpy.lib._histograms_impl import (
457457
histogramdd as histogramdd,
458458
)
459459

460-
from numpy.lib.index_tricks import (
460+
from numpy.lib._index_tricks_impl import (
461461
ravel_multi_index as ravel_multi_index,
462462
unravel_index as unravel_index,
463463
mgrid as mgrid,

numpy/core/tests/test_function_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def test_add_doc(self):
460460
tgt = "Current flat index into the array."
461461
assert_equal(np.core.flatiter.index.__doc__[:len(tgt)], tgt)
462462
assert_(len(np.core.ufunc.identity.__doc__) > 300)
463-
assert_(len(np.lib.index_tricks.mgrid.__doc__) > 300)
463+
assert_(len(np.lib._index_tricks_impl.mgrid.__doc__) > 300)
464464

465465
@pytest.mark.skipif(sys.flags.optimize == 2, reason="Python running -OO")
466466
def test_errors_are_ignored(self):

numpy/lib/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Private submodules
2121
# load module names. See https://github.com/networkx/networkx/issues/5838
2222
from . import _type_check_impl
23-
from . import index_tricks
23+
from . import _index_tricks_impl
2424
from . import _nanfunctions_impl
2525
from . import _function_base_impl
2626
from . import _stride_tricks_impl
@@ -38,15 +38,12 @@
3838
from . import _arraypad_impl
3939
from . import _version
4040

41-
from .index_tricks import *
4241
from .arrayterator import Arrayterator
4342
from ._version import *
4443
from numpy.core._multiarray_umath import add_docstring, tracemalloc_domain
4544
from numpy.core.function_base import add_newdoc
4645

47-
4846
__all__ = ['emath']
49-
__all__ += index_tricks.__all__
5047

5148
from numpy._pytesttester import PytestTester
5249
test = PytestTester(__name__)
@@ -66,7 +63,7 @@ def __getattr__(attr):
6663
elif attr in (
6764
"histograms", "type_check", "nanfunctions", "function_base",
6865
"arraypad", "arraysetops", "ufunclike", "utils", "twodim_base",
69-
"shape_base", "polynomial"
66+
"shape_base", "polynomial", "index_tricks",
7067
):
7168
raise AttributeError(
7269
f"`np.lib.{attr}` is now private. If you are using a public "

numpy/lib/__init__.pyi

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ from numpy.lib.arrayterator import (
2626
Arrayterator as Arrayterator,
2727
)
2828

29-
from numpy.lib.index_tricks import (
30-
ravel_multi_index as ravel_multi_index,
31-
unravel_index as unravel_index,
32-
mgrid as mgrid,
33-
ogrid as ogrid,
34-
r_ as r_,
35-
c_ as c_,
36-
s_ as s_,
37-
index_exp as index_exp,
38-
ix_ as ix_,
39-
fill_diagonal as fill_diagonal,
40-
diag_indices as diag_indices,
41-
diag_indices_from as diag_indices_from,
42-
)
43-
4429
from numpy.core.multiarray import (
4530
add_docstring as add_docstring,
4631
tracemalloc_domain as tracemalloc_domain,

numpy/lib/_arraypad_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
import numpy as np
77
from numpy.core.overrides import array_function_dispatch
8-
from numpy.lib.index_tricks import ndindex
8+
from numpy.lib._index_tricks_impl import ndindex
99

1010

1111
__all__ = ['pad']
File renamed without changes.
File renamed without changes.

numpy/lib/_shape_base_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from numpy.core import vstack, atleast_3d
1010
from numpy.core.numeric import normalize_axis_tuple
1111
from numpy.core.shape_base import _arrays_for_stack_dispatcher
12-
from numpy.lib.index_tricks import ndindex
12+
from numpy.lib._index_tricks_impl import ndindex
1313
from numpy.matrixlib.defmatrix import matrix # this raises all the right alarm bells
1414

1515

numpy/lib/tests/test_index_tricks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
assert_, assert_equal, assert_array_equal, assert_almost_equal,
66
assert_array_almost_equal, assert_raises, assert_raises_regex,
77
)
8-
from numpy.lib.index_tricks import (
8+
from numpy.lib._index_tricks_impl import (
99
mgrid, ogrid, ndenumerate, fill_diagonal, diag_indices, diag_indices_from,
10-
index_exp, ndindex, r_, s_, ix_
10+
index_exp, ndindex, c_, r_, s_, ix_
1111
)
1212

1313

@@ -405,7 +405,7 @@ def test_repeated_input(self):
405405

406406

407407
def test_c_():
408-
a = np.c_[np.array([[1, 2, 3]]), 0, 0, np.array([[4, 5, 6]])]
408+
a = c_[np.array([[1, 2, 3]]), 0, 0, np.array([[4, 5, 6]])]
409409
assert_equal(a, [[1, 2, 3, 0, 0, 4, 5, 6]])
410410

411411

numpy/ma/extras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from numpy.core.multiarray import normalize_axis_index
3636
from numpy.core.numeric import normalize_axis_tuple
3737
from numpy.lib._function_base_impl import _ureduce
38-
from numpy.lib.index_tricks import AxisConcatenator
38+
from numpy.lib._index_tricks_impl import AxisConcatenator
3939

4040

4141
def issequence(seq):

numpy/tests/test_public_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def test_NPY_NO_EXPORT():
194194
"f2py.use_rules",
195195
"fft.helper",
196196
"lib.arrayterator",
197-
"lib.index_tricks",
198197
"lib.user_array", # note: not in np.lib, but probably should just be deleted
199198
"linalg.lapack_lite",
200199
"linalg.linalg",

0 commit comments

Comments
 (0)
0