Skip to content

Commit 25f3b97

Browse files
committed
de-privatize names imported across modules
1 parent aca77f7 commit 25f3b97

38 files changed

+224
-238
lines changed

asv_bench/benchmarks/sparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def setup(self):
7171
s.index = MultiIndex.from_product([range(10)] * 4)
7272
self.ss = s.astype("Sparse")
7373

74-
def time_sparse_series_to_coo(self):
74+
def timesparse_series_to_coo(self):
7575
self.ss.sparse.to_coo(row_levels=[0, 1], column_levels=[2, 3], sort_labels=True)
7676

7777

pandas/__init__.py

Lines changed: 90 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
# numpy compat
2222
from pandas.compat.numpy import (
23-
_np_version_under1p17,
24-
_np_version_under1p18,
25-
_is_numpy_dev,
23+
is_numpy_dev as _is_numpy_dev,
24+
np_version_under1p17 as _np_version_under1p17,
25+
np_version_under1p18 as _np_version_under1p18,
2626
)
2727

2828
try:
@@ -37,148 +37,134 @@
3737
) from e
3838

3939
from pandas._config import (
40-
get_option,
41-
set_option,
42-
reset_option,
4340
describe_option,
41+
get_option,
4442
option_context,
4543
options,
44+
reset_option,
45+
set_option,
4646
)
4747

48+
from pandas.util._print_versions import show_versions
49+
from pandas.util._tester import test
50+
51+
import pandas.api
52+
import pandas.arrays
53+
from pandas.core.arrays.sparse import SparseDtype
54+
from pandas.core.computation.api import eval
55+
4856
# let init-time option registration happen
4957
import pandas.core.config_init
58+
from pandas.core.reshape.api import (
59+
concat,
60+
crosstab,
61+
cut,
62+
get_dummies,
63+
lreshape,
64+
melt,
65+
merge,
66+
merge_asof,
67+
merge_ordered,
68+
pivot,
69+
pivot_table,
70+
qcut,
71+
wide_to_long,
72+
)
73+
import pandas.testing
5074

51-
from pandas.core.api import (
52-
# dtype
75+
from pandas.io.json import _json_normalize as json_normalize
76+
from pandas.tseries import offsets
77+
from pandas.tseries.api import infer_freq
78+
79+
# use the closest tagged version if possible
80+
from ._version import get_versions
81+
82+
from pandas.core.api import ( # dtype; missing; indexes; tseries; conversion; misc
83+
NA,
84+
BooleanDtype,
85+
Categorical,
86+
CategoricalDtype,
87+
CategoricalIndex,
88+
DataFrame,
89+
DateOffset,
90+
DatetimeIndex,
91+
DatetimeTZDtype,
92+
Flags,
93+
Float64Index,
94+
Grouper,
95+
Index,
96+
IndexSlice,
5397
Int8Dtype,
5498
Int16Dtype,
5599
Int32Dtype,
56100
Int64Dtype,
101+
Int64Index,
102+
Interval,
103+
IntervalDtype,
104+
IntervalIndex,
105+
MultiIndex,
106+
NamedAgg,
107+
NaT,
108+
Period,
109+
PeriodDtype,
110+
PeriodIndex,
111+
RangeIndex,
112+
Series,
113+
StringDtype,
114+
Timedelta,
115+
TimedeltaIndex,
116+
Timestamp,
57117
UInt8Dtype,
58118
UInt16Dtype,
59119
UInt32Dtype,
60120
UInt64Dtype,
61-
CategoricalDtype,
62-
PeriodDtype,
63-
IntervalDtype,
64-
DatetimeTZDtype,
65-
StringDtype,
66-
BooleanDtype,
67-
# missing
68-
NA,
121+
UInt64Index,
122+
array,
123+
bdate_range,
124+
date_range,
125+
factorize,
126+
interval_range,
69127
isna,
70128
isnull,
71129
notna,
72130
notnull,
73-
# indexes
74-
Index,
75-
CategoricalIndex,
76-
Int64Index,
77-
UInt64Index,
78-
RangeIndex,
79-
Float64Index,
80-
MultiIndex,
81-
IntervalIndex,
82-
TimedeltaIndex,
83-
DatetimeIndex,
84-
PeriodIndex,
85-
IndexSlice,
86-
# tseries
87-
NaT,
88-
Period,
89131
period_range,
90-
Timedelta,
132+
set_eng_float_format,
91133
timedelta_range,
92-
Timestamp,
93-
date_range,
94-
bdate_range,
95-
Interval,
96-
interval_range,
97-
DateOffset,
98-
# conversion
99-
to_numeric,
100134
to_datetime,
135+
to_numeric,
101136
to_timedelta,
102-
# misc
103-
Flags,
104-
Grouper,
105-
factorize,
106137
unique,
107138
value_counts,
108-
NamedAgg,
109-
array,
110-
Categorical,
111-
set_eng_float_format,
112-
Series,
113-
DataFrame,
114-
)
115-
116-
from pandas.core.arrays.sparse import SparseDtype
117-
118-
from pandas.tseries.api import infer_freq
119-
from pandas.tseries import offsets
120-
121-
from pandas.core.computation.api import eval
122-
123-
from pandas.core.reshape.api import (
124-
concat,
125-
lreshape,
126-
melt,
127-
wide_to_long,
128-
merge,
129-
merge_asof,
130-
merge_ordered,
131-
crosstab,
132-
pivot,
133-
pivot_table,
134-
get_dummies,
135-
cut,
136-
qcut,
137139
)
138140

139-
import pandas.api
140-
from pandas.util._print_versions import show_versions
141141

142-
from pandas.io.api import (
143-
# excel
142+
from pandas.io.api import ( # excel; parsers; pickle; pytables; sql; misc
144143
ExcelFile,
145144
ExcelWriter,
146-
read_excel,
147-
# parsers
148-
read_csv,
149-
read_fwf,
150-
read_table,
151-
# pickle
152-
read_pickle,
153-
to_pickle,
154-
# pytables
155145
HDFStore,
156-
read_hdf,
157-
# sql
158-
read_sql,
159-
read_sql_query,
160-
read_sql_table,
161-
# misc
162146
read_clipboard,
163-
read_parquet,
164-
read_orc,
147+
read_csv,
148+
read_excel,
165149
read_feather,
150+
read_fwf,
166151
read_gbq,
152+
read_hdf,
167153
read_html,
168154
read_json,
169-
read_stata,
155+
read_orc,
156+
read_parquet,
157+
read_pickle,
170158
read_sas,
171159
read_spss,
160+
read_sql,
161+
read_sql_query,
162+
read_sql_table,
163+
read_stata,
164+
read_table,
165+
to_pickle,
172166
)
173167

174-
from pandas.io.json import _json_normalize as json_normalize
175-
176-
from pandas.util._tester import test
177-
import pandas.testing
178-
import pandas.arrays
179-
180-
# use the closest tagged version if possible
181-
from ._version import get_versions
182168

183169
v = get_versions()
184170
__version__ = v.get("closest-tag", v["version"])

pandas/_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ def use_numexpr(use, min_elements=None):
27132713
if min_elements is None:
27142714
min_elements = expr._MIN_ELEMENTS
27152715

2716-
olduse = expr._USE_NUMEXPR
2716+
olduse = expr.USE_NUMEXPR
27172717
oldmin = expr._MIN_ELEMENTS
27182718
expr.set_use_numexpr(use)
27192719
expr._MIN_ELEMENTS = min_elements

pandas/compat/numpy/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
# numpy versioning
99
_np_version = np.__version__
1010
_nlv = LooseVersion(_np_version)
11-
_np_version_under1p17 = _nlv < LooseVersion("1.17")
12-
_np_version_under1p18 = _nlv < LooseVersion("1.18")
11+
np_version_under1p17 = _nlv < LooseVersion("1.17")
12+
np_version_under1p18 = _nlv < LooseVersion("1.18")
1313
_np_version_under1p19 = _nlv < LooseVersion("1.19")
1414
_np_version_under1p20 = _nlv < LooseVersion("1.20")
15-
_is_numpy_dev = ".dev" in str(_nlv)
15+
is_numpy_dev = ".dev" in str(_nlv)
1616
_min_numpy_ver = "1.16.5"
1717

1818

@@ -65,6 +65,6 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
6565
__all__ = [
6666
"np",
6767
"_np_version",
68-
"_np_version_under1p17",
69-
"_is_numpy_dev",
68+
"np_version_under1p17",
69+
"is_numpy_dev",
7070
]

pandas/core/array_algos/masked_reductions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99

1010
from pandas._libs import missing as libmissing
11-
from pandas.compat.numpy import _np_version_under1p17
11+
from pandas.compat.numpy import np_version_under1p17
1212

1313
from pandas.core.nanops import check_below_min_count
1414

@@ -46,7 +46,7 @@ def _sumprod(
4646
if check_below_min_count(values.shape, mask, min_count):
4747
return libmissing.NA
4848

49-
if _np_version_under1p17:
49+
if np_version_under1p17:
5050
return func(values[~mask])
5151
else:
5252
return func(values, where=~mask)

pandas/core/arrays/sparse/accessor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def from_coo(cls, A, dense_index=False):
8888
dtype: Sparse[float64, nan]
8989
"""
9090
from pandas import Series
91-
from pandas.core.arrays.sparse.scipy_sparse import _coo_to_sparse_series
91+
from pandas.core.arrays.sparse.scipy_sparse import coo_to_sparse_series
9292

93-
result = _coo_to_sparse_series(A, dense_index=dense_index)
93+
result = coo_to_sparse_series(A, dense_index=dense_index)
9494
result = Series(result.array, index=result.index, copy=False)
9595

9696
return result
@@ -168,9 +168,9 @@ def to_coo(self, row_levels=(0,), column_levels=(1,), sort_labels=False):
168168
>>> columns
169169
[('a', 0), ('a', 1), ('b', 0), ('b', 1)]
170170
"""
171-
from pandas.core.arrays.sparse.scipy_sparse import _sparse_series_to_coo
171+
from pandas.core.arrays.sparse.scipy_sparse import sparse_series_to_coo
172172

173-
A, rows, columns = _sparse_series_to_coo(
173+
A, rows, columns = sparse_series_to_coo(
174174
self._parent, row_levels, column_levels, sort_labels=sort_labels
175175
)
176176
return A, rows, columns

pandas/core/arrays/sparse/scipy_sparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _get_index_subset_to_coord_dict(index, subset, sort_labels=False):
8585
return values, i_coord, j_coord, i_labels, j_labels
8686

8787

88-
def _sparse_series_to_coo(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
88+
def sparse_series_to_coo(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
8989
"""
9090
Convert a sparse Series to a scipy.sparse.coo_matrix using index
9191
levels row_levels, column_levels as the row and column
@@ -113,7 +113,7 @@ def _sparse_series_to_coo(ss, row_levels=(0,), column_levels=(1,), sort_labels=F
113113
return sparse_matrix, rows, columns
114114

115115

116-
def _coo_to_sparse_series(A, dense_index: bool = False):
116+
def coo_to_sparse_series(A, dense_index: bool = False):
117117
"""
118118
Convert a scipy.sparse.coo_matrix to a SparseSeries.
119119

pandas/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from pandas._libs import lib, tslibs
1818
from pandas._typing import AnyArrayLike, Scalar, T
19-
from pandas.compat.numpy import _np_version_under1p18
19+
from pandas.compat.numpy import np_version_under1p18
2020

2121
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
2222
from pandas.core.dtypes.common import (
@@ -425,7 +425,7 @@ def random_state(state=None):
425425
if (
426426
is_integer(state)
427427
or is_array_like(state)
428-
or (not _np_version_under1p18 and isinstance(state, np.random.BitGenerator))
428+
or (not np_version_under1p18 and isinstance(state, np.random.BitGenerator))
429429
):
430430
return np.random.RandomState(state)
431431
elif isinstance(state, np.random.RandomState):

pandas/core/computation/engines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
from typing import Dict, Type
77

88
from pandas.core.computation.align import align_terms, reconstruct_object
9-
from pandas.core.computation.ops import _mathops, _reductions
9+
from pandas.core.computation.ops import MATHOPS, REDUCTIONS
1010

1111
import pandas.io.formats.printing as printing
1212

13-
_ne_builtins = frozenset(_mathops + _reductions)
13+
_ne_builtins = frozenset(MATHOPS + REDUCTIONS)
1414

1515

1616
class NumExprClobberingError(NameError):

0 commit comments

Comments
 (0)