Skip to content

Commit a7e39b8

Browse files
authored
De-privatize imported names (#36156)
1 parent 9228066 commit a7e39b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+101
-101
lines changed

pandas/_libs/hashtable.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ from pandas._libs.missing cimport checknull
5656

5757

5858
cdef int64_t NPY_NAT = util.get_nat()
59-
_SIZE_HINT_LIMIT = (1 << 20) + 7
59+
SIZE_HINT_LIMIT = (1 << 20) + 7
6060

6161

6262
cdef Py_ssize_t _INIT_VEC_CAP = 128
@@ -176,7 +176,7 @@ def unique_label_indices(const int64_t[:] labels):
176176
ndarray[int64_t, ndim=1] arr
177177
Int64VectorData *ud = idx.data
178178

179-
kh_resize_int64(table, min(n, _SIZE_HINT_LIMIT))
179+
kh_resize_int64(table, min(n, SIZE_HINT_LIMIT))
180180

181181
with nogil:
182182
for i in range(n):

pandas/_libs/hashtable_class_helper.pxi.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ cdef class {{name}}HashTable(HashTable):
268268
def __cinit__(self, int64_t size_hint=1):
269269
self.table = kh_init_{{dtype}}()
270270
if size_hint is not None:
271-
size_hint = min(size_hint, _SIZE_HINT_LIMIT)
271+
size_hint = min(size_hint, SIZE_HINT_LIMIT)
272272
kh_resize_{{dtype}}(self.table, size_hint)
273273

274274
def __len__(self) -> int:
@@ -603,7 +603,7 @@ cdef class StringHashTable(HashTable):
603603
def __init__(self, int64_t size_hint=1):
604604
self.table = kh_init_str()
605605
if size_hint is not None:
606-
size_hint = min(size_hint, _SIZE_HINT_LIMIT)
606+
size_hint = min(size_hint, SIZE_HINT_LIMIT)
607607
kh_resize_str(self.table, size_hint)
608608

609609
def __dealloc__(self):
@@ -916,7 +916,7 @@ cdef class PyObjectHashTable(HashTable):
916916
def __init__(self, int64_t size_hint=1):
917917
self.table = kh_init_pymap()
918918
if size_hint is not None:
919-
size_hint = min(size_hint, _SIZE_HINT_LIMIT)
919+
size_hint = min(size_hint, SIZE_HINT_LIMIT)
920920
kh_resize_pymap(self.table, size_hint)
921921

922922
def __dealloc__(self):

pandas/_libs/hashtable_func_helper.pxi.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def duplicated_{{dtype}}(const {{c_type}}[:] values, object keep='first'):
138138
kh_{{ttype}}_t *table = kh_init_{{ttype}}()
139139
ndarray[uint8_t, ndim=1, cast=True] out = np.empty(n, dtype='bool')
140140

141-
kh_resize_{{ttype}}(table, min(n, _SIZE_HINT_LIMIT))
141+
kh_resize_{{ttype}}(table, min(n, SIZE_HINT_LIMIT))
142142

143143
if keep not in ('last', 'first', False):
144144
raise ValueError('keep must be either "first", "last" or False')

pandas/_libs/parsers.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ from pandas._libs.khash cimport (
6767
khiter_t,
6868
)
6969

70-
from pandas.compat import _get_lzma_file, _import_lzma
70+
from pandas.compat import get_lzma_file, import_lzma
7171
from pandas.errors import DtypeWarning, EmptyDataError, ParserError, ParserWarning
7272

7373
from pandas.core.dtypes.common import (
@@ -82,7 +82,7 @@ from pandas.core.dtypes.common import (
8282
)
8383
from pandas.core.dtypes.concat import union_categoricals
8484

85-
lzma = _import_lzma()
85+
lzma = import_lzma()
8686

8787
cdef:
8888
float64_t INF = <float64_t>np.inf
@@ -638,9 +638,9 @@ cdef class TextReader:
638638
f'zip file {zip_names}')
639639
elif self.compression == 'xz':
640640
if isinstance(source, str):
641-
source = _get_lzma_file(lzma)(source, 'rb')
641+
source = get_lzma_file(lzma)(source, 'rb')
642642
else:
643-
source = _get_lzma_file(lzma)(filename=source)
643+
source = get_lzma_file(lzma)(filename=source)
644644
else:
645645
raise ValueError(f'Unrecognized compression type: '
646646
f'{self.compression}')

pandas/_testing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pandas._libs.lib import no_default
2626
import pandas._libs.testing as _testing
2727
from pandas._typing import Dtype, FilePathOrBuffer, FrameOrSeries
28-
from pandas.compat import _get_lzma_file, _import_lzma
28+
from pandas.compat import get_lzma_file, import_lzma
2929

3030
from pandas.core.dtypes.common import (
3131
is_bool,
@@ -70,7 +70,7 @@
7070
from pandas.io.common import urlopen
7171
from pandas.io.formats.printing import pprint_thing
7272

73-
lzma = _import_lzma()
73+
lzma = import_lzma()
7474

7575
_N = 30
7676
_K = 4
@@ -243,7 +243,7 @@ def decompress_file(path, compression):
243243
elif compression == "bz2":
244244
f = bz2.BZ2File(path, "rb")
245245
elif compression == "xz":
246-
f = _get_lzma_file(lzma)(path, "rb")
246+
f = get_lzma_file(lzma)(path, "rb")
247247
elif compression == "zip":
248248
zip_file = zipfile.ZipFile(path)
249249
zip_names = zip_file.namelist()
@@ -288,7 +288,7 @@ def write_to_compressed(compression, path, data, dest="test"):
288288
elif compression == "bz2":
289289
compress_method = bz2.BZ2File
290290
elif compression == "xz":
291-
compress_method = _get_lzma_file(lzma)
291+
compress_method = get_lzma_file(lzma)
292292
else:
293293
raise ValueError(f"Unrecognized compression type: {compression}")
294294

pandas/compat/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def is_platform_mac() -> bool:
7777
return sys.platform == "darwin"
7878

7979

80-
def _import_lzma():
80+
def import_lzma():
8181
"""
8282
Importing the `lzma` module.
8383
@@ -97,7 +97,7 @@ def _import_lzma():
9797
warnings.warn(msg)
9898

9999

100-
def _get_lzma_file(lzma):
100+
def get_lzma_file(lzma):
101101
"""
102102
Importing the `LZMAFile` class from the `lzma` module.
103103

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
462462
return f(comps, values)
463463

464464

465-
def _factorize_array(
465+
def factorize_array(
466466
values, na_sentinel: int = -1, size_hint=None, na_value=None, mask=None
467467
) -> Tuple[np.ndarray, np.ndarray]:
468468
"""
@@ -671,7 +671,7 @@ def factorize(
671671
else:
672672
na_value = None
673673

674-
codes, uniques = _factorize_array(
674+
codes, uniques = factorize_array(
675675
values, na_sentinel=na_sentinel, size_hint=size_hint, na_value=na_value
676676
)
677677

pandas/core/arrays/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from pandas.core.dtypes.missing import isna
3232

3333
from pandas.core import ops
34-
from pandas.core.algorithms import _factorize_array, unique
34+
from pandas.core.algorithms import factorize_array, unique
3535
from pandas.core.missing import backfill_1d, pad_1d
3636
from pandas.core.sorting import nargminmax, nargsort
3737

@@ -845,7 +845,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, "ExtensionArray"
845845
# Complete control over factorization.
846846
arr, na_value = self._values_for_factorize()
847847

848-
codes, uniques = _factorize_array(
848+
codes, uniques = factorize_array(
849849
arr, na_sentinel=na_sentinel, na_value=na_value
850850
)
851851

pandas/core/arrays/masked.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from pandas.core.dtypes.missing import isna, notna
1818

1919
from pandas.core import nanops
20-
from pandas.core.algorithms import _factorize_array, take
20+
from pandas.core.algorithms import factorize_array, take
2121
from pandas.core.array_algos import masked_reductions
2222
from pandas.core.arrays import ExtensionArray, ExtensionOpsMixin
2323
from pandas.core.indexers import check_array_indexer
@@ -287,7 +287,7 @@ def factorize(self, na_sentinel: int = -1) -> Tuple[np.ndarray, ExtensionArray]:
287287
arr = self._data
288288
mask = self._mask
289289

290-
codes, uniques = _factorize_array(arr, na_sentinel=na_sentinel, mask=mask)
290+
codes, uniques = factorize_array(arr, na_sentinel=na_sentinel, mask=mask)
291291

292292
# the hashtables don't handle all different types of bits
293293
uniques = uniques.astype(self.dtype.numpy_dtype, copy=False)

pandas/core/computation/check.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from pandas.compat._optional import import_optional_dependency
22

33
ne = import_optional_dependency("numexpr", raise_on_missing=False, on_version="warn")
4-
_NUMEXPR_INSTALLED = ne is not None
5-
if _NUMEXPR_INSTALLED:
6-
_NUMEXPR_VERSION = ne.__version__
4+
NUMEXPR_INSTALLED = ne is not None
5+
if NUMEXPR_INSTALLED:
6+
NUMEXPR_VERSION = ne.__version__
77
else:
8-
_NUMEXPR_VERSION = None
8+
NUMEXPR_VERSION = None
99

10-
__all__ = ["_NUMEXPR_INSTALLED", "_NUMEXPR_VERSION"]
10+
__all__ = ["NUMEXPR_INSTALLED", "NUMEXPR_VERSION"]

0 commit comments

Comments
 (0)