graykode

(add) test.source for unittest

Showing 1 changed file with 707 additions and 0 deletions
1 +commit b5a5268dabb2a4dea1c3c543a1ddff501b87a447
2 +Author: jbrockmendel <jbrockmendel@gmail.com>
3 +Date: Tue Sep 8 18:33:41 2020 -0700
4 +
5 + STY: De-privatize imported names (#36235)
6 +
7 +diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx
8 +index 931ad8326..f8bcbcfb1 100644
9 +--- a/pandas/_libs/interval.pyx
10 ++++ b/pandas/_libs/interval.pyx
11 +@@ -46,7 +46,7 @@ from pandas._libs.tslibs.util cimport (
12 + is_timedelta64_object,
13 + )
14 +
15 +-_VALID_CLOSED = frozenset(['left', 'right', 'both', 'neither'])
16 ++VALID_CLOSED = frozenset(['left', 'right', 'both', 'neither'])
17 +
18 +
19 + cdef class IntervalMixin:
20 +@@ -318,7 +318,7 @@ cdef class Interval(IntervalMixin):
21 + self._validate_endpoint(left)
22 + self._validate_endpoint(right)
23 +
24 +- if closed not in _VALID_CLOSED:
25 ++ if closed not in VALID_CLOSED:
26 + raise ValueError(f"invalid option for 'closed': {closed}")
27 + if not left <= right:
28 + raise ValueError("left side of interval must be <= right side")
29 +diff --git a/pandas/core/arrays/_arrow_utils.py b/pandas/core/arrays/_arrow_utils.py
30 +index 4a33e0e84..c89f5554d 100644
31 +--- a/pandas/core/arrays/_arrow_utils.py
32 ++++ b/pandas/core/arrays/_arrow_utils.py
33 +@@ -4,7 +4,7 @@ import json
34 + import numpy as np
35 + import pyarrow
36 +
37 +-from pandas.core.arrays.interval import _VALID_CLOSED
38 ++from pandas.core.arrays.interval import VALID_CLOSED
39 +
40 + _pyarrow_version_ge_015 = LooseVersion(pyarrow.__version__) >= LooseVersion("0.15")
41 +
42 +@@ -83,7 +83,7 @@ if _pyarrow_version_ge_015:
43 + def __init__(self, subtype, closed):
44 + # attributes need to be set first before calling
45 + # super init (as that calls serialize)
46 +- assert closed in _VALID_CLOSED
47 ++ assert closed in VALID_CLOSED
48 + self._closed = closed
49 + if not isinstance(subtype, pyarrow.DataType):
50 + subtype = pyarrow.type_for_alias(str(subtype))
51 +diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py
52 +index d76e0fd62..1dbd3cfc6 100644
53 +--- a/pandas/core/arrays/interval.py
54 ++++ b/pandas/core/arrays/interval.py
55 +@@ -5,7 +5,12 @@ import numpy as np
56 +
57 + from pandas._config import get_option
58 +
59 +-from pandas._libs.interval import Interval, IntervalMixin, intervals_to_interval_bounds
60 ++from pandas._libs.interval import (
61 ++ VALID_CLOSED,
62 ++ Interval,
63 ++ IntervalMixin,
64 ++ intervals_to_interval_bounds,
65 ++)
66 + from pandas.compat.numpy import function as nv
67 + from pandas.util._decorators import Appender
68 +
69 +@@ -42,7 +47,6 @@ from pandas.core.construction import array
70 + from pandas.core.indexers import check_array_indexer
71 + from pandas.core.indexes.base import ensure_index
72 +
73 +-_VALID_CLOSED = {"left", "right", "both", "neither"}
74 + _interval_shared_docs = {}
75 +
76 + _shared_docs_kwargs = dict(
77 +@@ -475,7 +479,7 @@ class IntervalArray(IntervalMixin, ExtensionArray):
78 + * left and right have the same missing values
79 + * left is always below right
80 + """
81 +- if self.closed not in _VALID_CLOSED:
82 ++ if self.closed not in VALID_CLOSED:
83 + msg = f"invalid option for 'closed': {self.closed}"
84 + raise ValueError(msg)
85 + if len(self.left) != len(self.right):
86 +@@ -1012,7 +1016,7 @@ class IntervalArray(IntervalMixin, ExtensionArray):
87 + )
88 + )
89 + def set_closed(self, closed):
90 +- if closed not in _VALID_CLOSED:
91 ++ if closed not in VALID_CLOSED:
92 + msg = f"invalid option for 'closed': {closed}"
93 + raise ValueError(msg)
94 +
95 +diff --git a/pandas/core/arrays/sparse/__init__.py b/pandas/core/arrays/sparse/__init__.py
96 +index e928db499..e9ff4b7d4 100644
97 +--- a/pandas/core/arrays/sparse/__init__.py
98 ++++ b/pandas/core/arrays/sparse/__init__.py
99 +@@ -5,6 +5,6 @@ from pandas.core.arrays.sparse.array import (
100 + BlockIndex,
101 + IntIndex,
102 + SparseArray,
103 +- _make_index,
104 ++ make_sparse_index,
105 + )
106 + from pandas.core.arrays.sparse.dtype import SparseDtype
107 +diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py
108 +index 47c960dc9..853f7bb0b 100644
109 +--- a/pandas/core/arrays/sparse/array.py
110 ++++ b/pandas/core/arrays/sparse/array.py
111 +@@ -1556,7 +1556,7 @@ def make_sparse(arr: np.ndarray, kind="block", fill_value=None, dtype=None, copy
112 + else:
113 + indices = mask.nonzero()[0].astype(np.int32)
114 +
115 +- index = _make_index(length, indices, kind)
116 ++ index = make_sparse_index(length, indices, kind)
117 + sparsified_values = arr[mask]
118 + if dtype is not None:
119 + sparsified_values = astype_nansafe(sparsified_values, dtype=dtype)
120 +@@ -1564,7 +1564,7 @@ def make_sparse(arr: np.ndarray, kind="block", fill_value=None, dtype=None, copy
121 + return sparsified_values, index, fill_value
122 +
123 +
124 +-def _make_index(length, indices, kind):
125 ++def make_sparse_index(length, indices, kind):
126 +
127 + if kind == "block" or isinstance(kind, BlockIndex):
128 + locs, lens = splib.get_blocks(indices)
129 +diff --git a/pandas/core/computation/engines.py b/pandas/core/computation/engines.py
130 +index 0cdc0f530..77a378369 100644
131 +--- a/pandas/core/computation/engines.py
132 ++++ b/pandas/core/computation/engines.py
133 +@@ -130,7 +130,7 @@ class PythonEngine(AbstractEngine):
134 + pass
135 +
136 +
137 +-_engines: Dict[str, Type[AbstractEngine]] = {
138 ++ENGINES: Dict[str, Type[AbstractEngine]] = {
139 + "numexpr": NumExprEngine,
140 + "python": PythonEngine,
141 + }
142 +diff --git a/pandas/core/computation/eval.py b/pandas/core/computation/eval.py
143 +index f6a793514..630606b4d 100644
144 +--- a/pandas/core/computation/eval.py
145 ++++ b/pandas/core/computation/eval.py
146 +@@ -9,8 +9,8 @@ import warnings
147 + from pandas._libs.lib import no_default
148 + from pandas.util._validators import validate_bool_kwarg
149 +
150 +-from pandas.core.computation.engines import _engines
151 +-from pandas.core.computation.expr import Expr, _parsers
152 ++from pandas.core.computation.engines import ENGINES
153 ++from pandas.core.computation.expr import PARSERS, Expr
154 + from pandas.core.computation.parsing import tokenize_string
155 + from pandas.core.computation.scope import ensure_scope
156 +
157 +@@ -43,8 +43,8 @@ def _check_engine(engine: Optional[str]) -> str:
158 + if engine is None:
159 + engine = "numexpr" if NUMEXPR_INSTALLED else "python"
160 +
161 +- if engine not in _engines:
162 +- valid_engines = list(_engines.keys())
163 ++ if engine not in ENGINES:
164 ++ valid_engines = list(ENGINES.keys())
165 + raise KeyError(
166 + f"Invalid engine '{engine}' passed, valid engines are {valid_engines}"
167 + )
168 +@@ -75,9 +75,9 @@ def _check_parser(parser: str):
169 + KeyError
170 + * If an invalid parser is passed
171 + """
172 +- if parser not in _parsers:
173 ++ if parser not in PARSERS:
174 + raise KeyError(
175 +- f"Invalid parser '{parser}' passed, valid parsers are {_parsers.keys()}"
176 ++ f"Invalid parser '{parser}' passed, valid parsers are {PARSERS.keys()}"
177 + )
178 +
179 +
180 +@@ -341,7 +341,7 @@ def eval(
181 + parsed_expr = Expr(expr, engine=engine, parser=parser, env=env)
182 +
183 + # construct the engine and evaluate the parsed expression
184 +- eng = _engines[engine]
185 ++ eng = ENGINES[engine]
186 + eng_inst = eng(parsed_expr)
187 + ret = eng_inst.evaluate()
188 +
189 +diff --git a/pandas/core/computation/expr.py b/pandas/core/computation/expr.py
190 +index 8cff6abc0..f5897277d 100644
191 +--- a/pandas/core/computation/expr.py
192 ++++ b/pandas/core/computation/expr.py
193 +@@ -782,7 +782,7 @@ class Expr:
194 + self.env = env or Scope(level=level + 1)
195 + self.engine = engine
196 + self.parser = parser
197 +- self._visitor = _parsers[parser](self.env, self.engine, self.parser)
198 ++ self._visitor = PARSERS[parser](self.env, self.engine, self.parser)
199 + self.terms = self.parse()
200 +
201 + @property
202 +@@ -814,4 +814,4 @@ class Expr:
203 + return frozenset(term.name for term in com.flatten(self.terms))
204 +
205 +
206 +-_parsers = {"python": PythonExprVisitor, "pandas": PandasExprVisitor}
207 ++PARSERS = {"python": PythonExprVisitor, "pandas": PandasExprVisitor}
208 +diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py
209 +index 0c23f1b4b..bfe20551c 100644
210 +--- a/pandas/core/config_init.py
211 ++++ b/pandas/core/config_init.py
212 +@@ -314,9 +314,9 @@ pc_latex_multirow = """
213 +
214 +
215 + def table_schema_cb(key):
216 +- from pandas.io.formats.printing import _enable_data_resource_formatter
217 ++ from pandas.io.formats.printing import enable_data_resource_formatter
218 +
219 +- _enable_data_resource_formatter(cf.get_option(key))
220 ++ enable_data_resource_formatter(cf.get_option(key))
221 +
222 +
223 + def is_terminal() -> bool:
224 +diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py
225 +index 72003eab2..e870187fc 100644
226 +--- a/pandas/core/groupby/generic.py
227 ++++ b/pandas/core/groupby/generic.py
228 +@@ -70,9 +70,9 @@ from pandas.core.groupby.groupby import (
229 + GroupBy,
230 + _agg_template,
231 + _apply_docs,
232 +- _group_selection_context,
233 + _transform_template,
234 + get_groupby,
235 ++ group_selection_context,
236 + )
237 + from pandas.core.groupby.numba_ import generate_numba_func, split_for_numba
238 + from pandas.core.indexes.api import Index, MultiIndex, all_indexes_same
239 +@@ -230,7 +230,7 @@ class SeriesGroupBy(GroupBy[Series]):
240 + raise NotImplementedError(
241 + "Numba engine can only be used with a single function."
242 + )
243 +- with _group_selection_context(self):
244 ++ with group_selection_context(self):
245 + data = self._selected_obj
246 + result, index = self._aggregate_with_numba(
247 + data.to_frame(), func, *args, engine_kwargs=engine_kwargs, **kwargs
248 +@@ -685,7 +685,7 @@ class SeriesGroupBy(GroupBy[Series]):
249 + self, normalize=False, sort=True, ascending=False, bins=None, dropna=True
250 + ):
251 +
252 +- from pandas.core.reshape.merge import _get_join_indexers
253 ++ from pandas.core.reshape.merge import get_join_indexers
254 + from pandas.core.reshape.tile import cut
255 +
256 + if bins is not None and not np.iterable(bins):
257 +@@ -787,7 +787,7 @@ class SeriesGroupBy(GroupBy[Series]):
258 +
259 + right = [diff.cumsum() - 1, codes[-1]]
260 +
261 +- _, idx = _get_join_indexers(left, right, sort=False, how="left")
262 ++ _, idx = get_join_indexers(left, right, sort=False, how="left")
263 + out = np.where(idx != -1, out[idx], 0)
264 +
265 + if sort:
266 +@@ -942,7 +942,7 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
267 + raise NotImplementedError(
268 + "Numba engine can only be used with a single function."
269 + )
270 +- with _group_selection_context(self):
271 ++ with group_selection_context(self):
272 + data = self._selected_obj
273 + result, index = self._aggregate_with_numba(
274 + data, func, *args, engine_kwargs=engine_kwargs, **kwargs
275 +diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py
276 +index 6ef2e6703..1e3e56f4f 100644
277 +--- a/pandas/core/groupby/groupby.py
278 ++++ b/pandas/core/groupby/groupby.py
279 +@@ -459,9 +459,9 @@ class GroupByPlot(PandasObject):
280 +
281 +
282 + @contextmanager
283 +-def _group_selection_context(groupby: "_GroupBy"):
284 ++def group_selection_context(groupby: "_GroupBy"):
285 + """
286 +- Set / reset the _group_selection_context.
287 ++ Set / reset the group_selection_context.
288 + """
289 + groupby._set_group_selection()
290 + try:
291 +@@ -737,7 +737,7 @@ b 2""",
292 + def _make_wrapper(self, name: str) -> Callable:
293 + assert name in self._apply_allowlist
294 +
295 +- with _group_selection_context(self):
296 ++ with group_selection_context(self):
297 + # need to setup the selection
298 + # as are not passed directly but in the grouper
299 + f = getattr(self._obj_with_exclusions, name)
300 +@@ -868,7 +868,7 @@ b 2""",
301 + # fails on *some* columns, e.g. a numeric operation
302 + # on a string grouper column
303 +
304 +- with _group_selection_context(self):
305 ++ with group_selection_context(self):
306 + return self._python_apply_general(f, self._selected_obj)
307 +
308 + return result
309 +@@ -994,7 +994,7 @@ b 2""",
310 + alias: str,
311 + npfunc: Callable,
312 + ):
313 +- with _group_selection_context(self):
314 ++ with group_selection_context(self):
315 + # try a cython aggregation if we can
316 + try:
317 + return self._cython_agg_general(
318 +@@ -1499,7 +1499,7 @@ class GroupBy(_GroupBy[FrameOrSeries]):
319 + )
320 + else:
321 + func = lambda x: x.var(ddof=ddof)
322 +- with _group_selection_context(self):
323 ++ with group_selection_context(self):
324 + return self._python_agg_general(func)
325 +
326 + @Substitution(name="groupby")
327 +@@ -1658,7 +1658,7 @@ class GroupBy(_GroupBy[FrameOrSeries]):
328 +
329 + @doc(DataFrame.describe)
330 + def describe(self, **kwargs):
331 +- with _group_selection_context(self):
332 ++ with group_selection_context(self):
333 + result = self.apply(lambda x: x.describe(**kwargs))
334 + if self.axis == 1:
335 + return result.T
336 +@@ -1963,7 +1963,7 @@ class GroupBy(_GroupBy[FrameOrSeries]):
337 + nth_values = list(set(n))
338 +
339 + nth_array = np.array(nth_values, dtype=np.intp)
340 +- with _group_selection_context(self):
341 ++ with group_selection_context(self):
342 +
343 + mask_left = np.in1d(self._cumcount_array(), nth_array)
344 + mask_right = np.in1d(
345 +@@ -2226,7 +2226,7 @@ class GroupBy(_GroupBy[FrameOrSeries]):
346 + 5 0
347 + dtype: int64
348 + """
349 +- with _group_selection_context(self):
350 ++ with group_selection_context(self):
351 + index = self._selected_obj.index
352 + result = self._obj_1d_constructor(self.grouper.group_info[0], index)
353 + if not ascending:
354 +@@ -2287,7 +2287,7 @@ class GroupBy(_GroupBy[FrameOrSeries]):
355 + 5 0
356 + dtype: int64
357 + """
358 +- with _group_selection_context(self):
359 ++ with group_selection_context(self):
360 + index = self._selected_obj.index
361 + cumcounts = self._cumcount_array(ascending=ascending)
362 + return self._obj_1d_constructor(cumcounts, index)
363 +diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py
364 +index 526dae7e2..8014b16d0 100644
365 +--- a/pandas/core/indexes/base.py
366 ++++ b/pandas/core/indexes/base.py
367 +@@ -3660,7 +3660,7 @@ class Index(IndexOpsMixin, PandasObject):
368 + return result
369 +
370 + def _join_non_unique(self, other, how="left", return_indexers=False):
371 +- from pandas.core.reshape.merge import _get_join_indexers
372 ++ from pandas.core.reshape.merge import get_join_indexers
373 +
374 + # We only get here if dtypes match
375 + assert self.dtype == other.dtype
376 +@@ -3668,7 +3668,7 @@ class Index(IndexOpsMixin, PandasObject):
377 + lvalues = self._get_engine_target()
378 + rvalues = other._get_engine_target()
379 +
380 +- left_idx, right_idx = _get_join_indexers(
381 ++ left_idx, right_idx = get_join_indexers(
382 + [lvalues], [rvalues], how=how, sort=True
383 + )
384 +
385 +diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py
386 +index 3f72577c9..154f41bf0 100644
387 +--- a/pandas/core/indexes/interval.py
388 ++++ b/pandas/core/indexes/interval.py
389 +@@ -59,7 +59,6 @@ from pandas.core.ops import get_op_result_name
390 + if TYPE_CHECKING:
391 + from pandas import CategoricalIndex # noqa:F401
392 +
393 +-_VALID_CLOSED = {"left", "right", "both", "neither"}
394 + _index_doc_kwargs = dict(ibase._index_doc_kwargs)
395 +
396 + _index_doc_kwargs.update(
397 +diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py
398 +index 030dec369..9f19ea9ae 100644
399 +--- a/pandas/core/reshape/merge.py
400 ++++ b/pandas/core/reshape/merge.py
401 +@@ -859,7 +859,7 @@ class _MergeOperation:
402 +
403 + def _get_join_indexers(self):
404 + """ return the join indexers """
405 +- return _get_join_indexers(
406 ++ return get_join_indexers(
407 + self.left_join_keys, self.right_join_keys, sort=self.sort, how=self.how
408 + )
409 +
410 +@@ -1298,7 +1298,7 @@ class _MergeOperation:
411 + raise ValueError("Not a valid argument for validate")
412 +
413 +
414 +-def _get_join_indexers(
415 ++def get_join_indexers(
416 + left_keys, right_keys, sort: bool = False, how: str = "inner", **kwargs
417 + ):
418 + """
419 +diff --git a/pandas/io/formats/printing.py b/pandas/io/formats/printing.py
420 +index edc6fbfff..0d2ca83f1 100644
421 +--- a/pandas/io/formats/printing.py
422 ++++ b/pandas/io/formats/printing.py
423 +@@ -243,7 +243,7 @@ def pprint_thing_encoded(
424 + return value.encode(encoding, errors)
425 +
426 +
427 +-def _enable_data_resource_formatter(enable: bool) -> None:
428 ++def enable_data_resource_formatter(enable: bool) -> None:
429 + if "IPython" not in sys.modules:
430 + # definitely not in IPython
431 + return
432 +diff --git a/pandas/tests/arrays/sparse/test_libsparse.py b/pandas/tests/arrays/sparse/test_libsparse.py
433 +index a2f861d37..2d6e657de 100644
434 +--- a/pandas/tests/arrays/sparse/test_libsparse.py
435 ++++ b/pandas/tests/arrays/sparse/test_libsparse.py
436 +@@ -8,7 +8,7 @@ import pandas.util._test_decorators as td
437 +
438 + from pandas import Series
439 + import pandas._testing as tm
440 +-from pandas.core.arrays.sparse import BlockIndex, IntIndex, _make_index
441 ++from pandas.core.arrays.sparse import BlockIndex, IntIndex, make_sparse_index
442 +
443 + TEST_LENGTH = 20
444 +
445 +@@ -273,41 +273,43 @@ class TestSparseIndexIntersect:
446 +
447 + class TestSparseIndexCommon:
448 + def test_int_internal(self):
449 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind="integer")
450 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind="integer")
451 + assert isinstance(idx, IntIndex)
452 + assert idx.npoints == 2
453 + tm.assert_numpy_array_equal(idx.indices, np.array([2, 3], dtype=np.int32))
454 +
455 +- idx = _make_index(4, np.array([], dtype=np.int32), kind="integer")
456 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind="integer")
457 + assert isinstance(idx, IntIndex)
458 + assert idx.npoints == 0
459 + tm.assert_numpy_array_equal(idx.indices, np.array([], dtype=np.int32))
460 +
461 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="integer")
462 ++ idx = make_sparse_index(
463 ++ 4, np.array([0, 1, 2, 3], dtype=np.int32), kind="integer"
464 ++ )
465 + assert isinstance(idx, IntIndex)
466 + assert idx.npoints == 4
467 + tm.assert_numpy_array_equal(idx.indices, np.array([0, 1, 2, 3], dtype=np.int32))
468 +
469 + def test_block_internal(self):
470 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind="block")
471 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind="block")
472 + assert isinstance(idx, BlockIndex)
473 + assert idx.npoints == 2
474 + tm.assert_numpy_array_equal(idx.blocs, np.array([2], dtype=np.int32))
475 + tm.assert_numpy_array_equal(idx.blengths, np.array([2], dtype=np.int32))
476 +
477 +- idx = _make_index(4, np.array([], dtype=np.int32), kind="block")
478 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind="block")
479 + assert isinstance(idx, BlockIndex)
480 + assert idx.npoints == 0
481 + tm.assert_numpy_array_equal(idx.blocs, np.array([], dtype=np.int32))
482 + tm.assert_numpy_array_equal(idx.blengths, np.array([], dtype=np.int32))
483 +
484 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="block")
485 ++ idx = make_sparse_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="block")
486 + assert isinstance(idx, BlockIndex)
487 + assert idx.npoints == 4
488 + tm.assert_numpy_array_equal(idx.blocs, np.array([0], dtype=np.int32))
489 + tm.assert_numpy_array_equal(idx.blengths, np.array([4], dtype=np.int32))
490 +
491 +- idx = _make_index(4, np.array([0, 2, 3], dtype=np.int32), kind="block")
492 ++ idx = make_sparse_index(4, np.array([0, 2, 3], dtype=np.int32), kind="block")
493 + assert isinstance(idx, BlockIndex)
494 + assert idx.npoints == 3
495 + tm.assert_numpy_array_equal(idx.blocs, np.array([0, 2], dtype=np.int32))
496 +@@ -315,7 +317,7 @@ class TestSparseIndexCommon:
497 +
498 + def test_lookup(self):
499 + for kind in ["integer", "block"]:
500 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind=kind)
501 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind=kind)
502 + assert idx.lookup(-1) == -1
503 + assert idx.lookup(0) == -1
504 + assert idx.lookup(1) == -1
505 +@@ -323,12 +325,14 @@ class TestSparseIndexCommon:
506 + assert idx.lookup(3) == 1
507 + assert idx.lookup(4) == -1
508 +
509 +- idx = _make_index(4, np.array([], dtype=np.int32), kind=kind)
510 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind=kind)
511 +
512 + for i in range(-1, 5):
513 + assert idx.lookup(i) == -1
514 +
515 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind=kind)
516 ++ idx = make_sparse_index(
517 ++ 4, np.array([0, 1, 2, 3], dtype=np.int32), kind=kind
518 ++ )
519 + assert idx.lookup(-1) == -1
520 + assert idx.lookup(0) == 0
521 + assert idx.lookup(1) == 1
522 +@@ -336,7 +340,7 @@ class TestSparseIndexCommon:
523 + assert idx.lookup(3) == 3
524 + assert idx.lookup(4) == -1
525 +
526 +- idx = _make_index(4, np.array([0, 2, 3], dtype=np.int32), kind=kind)
527 ++ idx = make_sparse_index(4, np.array([0, 2, 3], dtype=np.int32), kind=kind)
528 + assert idx.lookup(-1) == -1
529 + assert idx.lookup(0) == 0
530 + assert idx.lookup(1) == -1
531 +@@ -346,7 +350,7 @@ class TestSparseIndexCommon:
532 +
533 + def test_lookup_array(self):
534 + for kind in ["integer", "block"]:
535 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind=kind)
536 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind=kind)
537 +
538 + res = idx.lookup_array(np.array([-1, 0, 2], dtype=np.int32))
539 + exp = np.array([-1, -1, 0], dtype=np.int32)
540 +@@ -356,11 +360,13 @@ class TestSparseIndexCommon:
541 + exp = np.array([-1, 0, -1, 1], dtype=np.int32)
542 + tm.assert_numpy_array_equal(res, exp)
543 +
544 +- idx = _make_index(4, np.array([], dtype=np.int32), kind=kind)
545 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind=kind)
546 + res = idx.lookup_array(np.array([-1, 0, 2, 4], dtype=np.int32))
547 + exp = np.array([-1, -1, -1, -1], dtype=np.int32)
548 +
549 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind=kind)
550 ++ idx = make_sparse_index(
551 ++ 4, np.array([0, 1, 2, 3], dtype=np.int32), kind=kind
552 ++ )
553 + res = idx.lookup_array(np.array([-1, 0, 2], dtype=np.int32))
554 + exp = np.array([-1, 0, 2], dtype=np.int32)
555 + tm.assert_numpy_array_equal(res, exp)
556 +@@ -369,7 +375,7 @@ class TestSparseIndexCommon:
557 + exp = np.array([-1, 2, 1, 3], dtype=np.int32)
558 + tm.assert_numpy_array_equal(res, exp)
559 +
560 +- idx = _make_index(4, np.array([0, 2, 3], dtype=np.int32), kind=kind)
561 ++ idx = make_sparse_index(4, np.array([0, 2, 3], dtype=np.int32), kind=kind)
562 + res = idx.lookup_array(np.array([2, 1, 3, 0], dtype=np.int32))
563 + exp = np.array([1, -1, 2, 0], dtype=np.int32)
564 + tm.assert_numpy_array_equal(res, exp)
565 +@@ -402,25 +408,25 @@ class TestSparseIndexCommon:
566 +
567 + class TestBlockIndex:
568 + def test_block_internal(self):
569 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind="block")
570 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind="block")
571 + assert isinstance(idx, BlockIndex)
572 + assert idx.npoints == 2
573 + tm.assert_numpy_array_equal(idx.blocs, np.array([2], dtype=np.int32))
574 + tm.assert_numpy_array_equal(idx.blengths, np.array([2], dtype=np.int32))
575 +
576 +- idx = _make_index(4, np.array([], dtype=np.int32), kind="block")
577 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind="block")
578 + assert isinstance(idx, BlockIndex)
579 + assert idx.npoints == 0
580 + tm.assert_numpy_array_equal(idx.blocs, np.array([], dtype=np.int32))
581 + tm.assert_numpy_array_equal(idx.blengths, np.array([], dtype=np.int32))
582 +
583 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="block")
584 ++ idx = make_sparse_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="block")
585 + assert isinstance(idx, BlockIndex)
586 + assert idx.npoints == 4
587 + tm.assert_numpy_array_equal(idx.blocs, np.array([0], dtype=np.int32))
588 + tm.assert_numpy_array_equal(idx.blengths, np.array([4], dtype=np.int32))
589 +
590 +- idx = _make_index(4, np.array([0, 2, 3], dtype=np.int32), kind="block")
591 ++ idx = make_sparse_index(4, np.array([0, 2, 3], dtype=np.int32), kind="block")
592 + assert isinstance(idx, BlockIndex)
593 + assert idx.npoints == 3
594 + tm.assert_numpy_array_equal(idx.blocs, np.array([0, 2], dtype=np.int32))
595 +@@ -428,7 +434,7 @@ class TestBlockIndex:
596 +
597 + def test_make_block_boundary(self):
598 + for i in [5, 10, 100, 101]:
599 +- idx = _make_index(i, np.arange(0, i, 2, dtype=np.int32), kind="block")
600 ++ idx = make_sparse_index(i, np.arange(0, i, 2, dtype=np.int32), kind="block")
601 +
602 + exp = np.arange(0, i, 2, dtype=np.int32)
603 + tm.assert_numpy_array_equal(idx.blocs, exp)
604 +@@ -514,17 +520,19 @@ class TestIntIndex:
605 + IntIndex(length=5, indices=[1, 3, 3])
606 +
607 + def test_int_internal(self):
608 +- idx = _make_index(4, np.array([2, 3], dtype=np.int32), kind="integer")
609 ++ idx = make_sparse_index(4, np.array([2, 3], dtype=np.int32), kind="integer")
610 + assert isinstance(idx, IntIndex)
611 + assert idx.npoints == 2
612 + tm.assert_numpy_array_equal(idx.indices, np.array([2, 3], dtype=np.int32))
613 +
614 +- idx = _make_index(4, np.array([], dtype=np.int32), kind="integer")
615 ++ idx = make_sparse_index(4, np.array([], dtype=np.int32), kind="integer")
616 + assert isinstance(idx, IntIndex)
617 + assert idx.npoints == 0
618 + tm.assert_numpy_array_equal(idx.indices, np.array([], dtype=np.int32))
619 +
620 +- idx = _make_index(4, np.array([0, 1, 2, 3], dtype=np.int32), kind="integer")
621 ++ idx = make_sparse_index(
622 ++ 4, np.array([0, 1, 2, 3], dtype=np.int32), kind="integer"
623 ++ )
624 + assert isinstance(idx, IntIndex)
625 + assert idx.npoints == 4
626 + tm.assert_numpy_array_equal(idx.indices, np.array([0, 1, 2, 3], dtype=np.int32))
627 +diff --git a/pandas/tests/computation/test_compat.py b/pandas/tests/computation/test_compat.py
628 +index ead102f53..9fc3ed480 100644
629 +--- a/pandas/tests/computation/test_compat.py
630 ++++ b/pandas/tests/computation/test_compat.py
631 +@@ -5,7 +5,7 @@ import pytest
632 + from pandas.compat._optional import VERSIONS
633 +
634 + import pandas as pd
635 +-from pandas.core.computation.engines import _engines
636 ++from pandas.core.computation.engines import ENGINES
637 + import pandas.core.computation.expr as expr
638 +
639 +
640 +@@ -26,8 +26,8 @@ def test_compat():
641 + pytest.skip("not testing numexpr version compat")
642 +
643 +
644 +-@pytest.mark.parametrize("engine", _engines)
645 +-@pytest.mark.parametrize("parser", expr._parsers)
646 ++@pytest.mark.parametrize("engine", ENGINES)
647 ++@pytest.mark.parametrize("parser", expr.PARSERS)
648 + def test_invalid_numexpr_version(engine, parser):
649 + def testit():
650 + a, b = 1, 2 # noqa
651 +diff --git a/pandas/tests/computation/test_eval.py b/pandas/tests/computation/test_eval.py
652 +index 72dc04e68..cca64a6bf 100644
653 +--- a/pandas/tests/computation/test_eval.py
654 ++++ b/pandas/tests/computation/test_eval.py
655 +@@ -19,7 +19,7 @@ from pandas import DataFrame, Series, compat, date_range
656 + import pandas._testing as tm
657 + from pandas.core.computation import pytables
658 + from pandas.core.computation.check import NUMEXPR_VERSION
659 +-from pandas.core.computation.engines import NumExprClobberingError, _engines
660 ++from pandas.core.computation.engines import ENGINES, NumExprClobberingError
661 + import pandas.core.computation.expr as expr
662 + from pandas.core.computation.expr import (
663 + BaseExprVisitor,
664 +@@ -46,14 +46,14 @@ from pandas.core.computation.ops import (
665 + f"installed->{NUMEXPR_INSTALLED}",
666 + ),
667 + )
668 +- for engine in _engines
669 ++ for engine in ENGINES
670 + )
671 + ) # noqa
672 + def engine(request):
673 + return request.param
674 +
675 +
676 +-@pytest.fixture(params=expr._parsers)
677 ++@pytest.fixture(params=expr.PARSERS)
678 + def parser(request):
679 + return request.param
680 +
681 +@@ -77,7 +77,7 @@ def unary_fns_for_ne():
682 +
683 +
684 + def engine_has_neg_frac(engine):
685 +- return _engines[engine].has_neg_frac
686 ++ return ENGINES[engine].has_neg_frac
687 +
688 +
689 + def _eval_single_bin(lhs, cmp1, rhs, engine):
690 +@@ -168,7 +168,7 @@ class TestEvalNumexprPandas:
691 + def setup_method(self, method):
692 + self.setup_ops()
693 + self.setup_data()
694 +- self.current_engines = (engine for engine in _engines if engine != self.engine)
695 ++ self.current_engines = (engine for engine in ENGINES if engine != self.engine)
696 +
697 + def teardown_method(self, method):
698 + del self.lhses, self.rhses, self.scalar_rhses, self.scalar_lhses
699 +@@ -1921,7 +1921,7 @@ _parsers: Dict[str, Type[BaseExprVisitor]] = {
700 + }
701 +
702 +
703 +-@pytest.mark.parametrize("engine", _engines)
704 ++@pytest.mark.parametrize("engine", ENGINES)
705 + @pytest.mark.parametrize("parser", _parsers)
706 + def test_disallowed_nodes(engine, parser):
707 + VisitorClass = _parsers[parser]
...\ No newline at end of file ...\ No newline at end of file