Skip to content

Commit 41859ee

Browse files
example with line length limit of 79
1 parent 4d30876 commit 41859ee

File tree

569 files changed

+28371
-8455
lines changed

Some content is hidden

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

569 files changed

+28371
-8455
lines changed

pandas/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
if missing_dependencies:
1616
raise ImportError(
17-
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
17+
"Unable to import required dependencies:\n"
18+
+ "\n".join(missing_dependencies)
1819
)
1920
del hard_dependencies, dependency, missing_dependencies
2021

@@ -27,7 +28,11 @@
2728
)
2829

2930
try:
30-
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
31+
from pandas._libs import (
32+
hashtable as _hashtable,
33+
lib as _lib,
34+
tslib as _tslib,
35+
)
3136
except ImportError as e: # pragma: no cover
3237
# hack but overkill to use re
3338
module = str(e).replace("cannot import name ", "")

pandas/_config/config.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
import warnings
5656

5757
DeprecatedOption = namedtuple("DeprecatedOption", "key msg rkey removal_ver")
58-
RegisteredOption = namedtuple("RegisteredOption", "key defval doc validator cb")
58+
RegisteredOption = namedtuple(
59+
"RegisteredOption", "key defval doc validator cb"
60+
)
5961

6062
# holds deprecated option metdata
6163
_deprecated_options = {} # type: Dict[str, DeprecatedOption]
@@ -110,7 +112,9 @@ def _set_option(*args, **kwargs):
110112
# must at least 1 arg deal with constraints later
111113
nargs = len(args)
112114
if not nargs or nargs % 2 != 0:
113-
raise ValueError("Must provide an even number of non-keyword " "arguments")
115+
raise ValueError(
116+
"Must provide an even number of non-keyword " "arguments"
117+
)
114118

115119
# default to false
116120
silent = kwargs.pop("silent", False)
@@ -236,7 +240,9 @@ def __call__(self, *args, **kwds):
236240
def __doc__(self):
237241
opts_desc = _describe_option("all", _print_desc=False)
238242
opts_list = pp_options_list(list(_registered_options.keys()))
239-
return self.__doc_tmpl__.format(opts_desc=opts_desc, opts_list=opts_list)
243+
return self.__doc_tmpl__.format(
244+
opts_desc=opts_desc, opts_list=opts_list
245+
)
240246

241247

242248
_get_option_tmpl = """
@@ -395,13 +401,16 @@ class option_context:
395401
def __init__(self, *args):
396402
if not (len(args) % 2 == 0 and len(args) >= 2):
397403
raise ValueError(
398-
"Need to invoke as" " option_context(pat, val, [(pat, val), ...])."
404+
"Need to invoke as"
405+
" option_context(pat, val, [(pat, val), ...])."
399406
)
400407

401408
self.ops = list(zip(args[::2], args[1::2]))
402409

403410
def __enter__(self):
404-
self.undo = [(pat, _get_option(pat, silent=True)) for pat, val in self.ops]
411+
self.undo = [
412+
(pat, _get_option(pat, silent=True)) for pat, val in self.ops
413+
]
405414

406415
for pat, val in self.ops:
407416
_set_option(pat, val, silent=True)
@@ -623,7 +632,9 @@ def _warn_if_deprecated(key):
623632
else:
624633
msg = "'{key}' is deprecated".format(key=key)
625634
if d.removal_ver:
626-
msg += " and will be removed in {version}".format(version=d.removal_ver)
635+
msg += " and will be removed in {version}".format(
636+
version=d.removal_ver
637+
)
627638
if d.rkey:
628639
msg += ", please use '{rkey}' instead.".format(rkey=d.rkey)
629640
else:

pandas/_config/display.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@ def detect_console_encoding():
5252

5353
with cf.config_prefix("display"):
5454
cf.register_option(
55-
"encoding", detect_console_encoding(), pc_encoding_doc, validator=cf.is_text
55+
"encoding",
56+
detect_console_encoding(),
57+
pc_encoding_doc,
58+
validator=cf.is_text,
5659
)

pandas/_config/localization.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def _default_locale_getter():
108108
return raw_locales
109109

110110

111-
def get_locales(prefix=None, normalize=True, locale_getter=_default_locale_getter):
111+
def get_locales(
112+
prefix=None, normalize=True, locale_getter=_default_locale_getter
113+
):
112114
"""
113115
Get all the locales that are available on the system.
114116

pandas/_typing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
np.ndarray,
2626
)
2727
ArrayLike = TypeVar("ArrayLike", ABCExtensionArray, np.ndarray)
28-
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", Period, Timestamp, Timedelta)
28+
DatetimeLikeScalar = TypeVar(
29+
"DatetimeLikeScalar", Period, Timestamp, Timedelta
30+
)
2931
Dtype = Union[str, np.dtype, ExtensionDtype]
3032
FilePathOrBuffer = Union[str, Path, IO[AnyStr]]
3133

pandas/_version.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
103103
print(
104104
"guessing rootdir is '{root}', but '{dirname}' "
105105
"doesn't start with prefix '{parentdir_prefix}'".format(
106-
root=root, dirname=dirname, parentdir_prefix=parentdir_prefix
106+
root=root,
107+
dirname=dirname,
108+
parentdir_prefix=parentdir_prefix,
107109
)
108110
)
109111
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
@@ -249,7 +251,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
249251
# tag
250252
full_tag = mo.group(1)
251253
if not full_tag.startswith(tag_prefix):
252-
fmt = "tag '{full_tag}' doesn't start with prefix " "'{tag_prefix}'"
254+
fmt = (
255+
"tag '{full_tag}' doesn't start with prefix " "'{tag_prefix}'"
256+
)
253257
msg = fmt.format(full_tag=full_tag, tag_prefix=tag_prefix)
254258
if verbose:
255259
print(msg)
@@ -267,7 +271,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
267271
else:
268272
# HEX: no tags
269273
pieces["closest-tag"] = None
270-
count_out = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
274+
count_out = run_command(
275+
GITS, ["rev-list", "HEAD", "--count"], cwd=root
276+
)
271277
pieces["distance"] = int(count_out) # total number of commits
272278

273279
return pieces
@@ -296,7 +302,9 @@ def render_pep440(pieces):
296302
rendered += ".dirty"
297303
else:
298304
# exception #1
299-
rendered = "0+untagged.{:d}.g{}".format(pieces["distance"], pieces["short"])
305+
rendered = "0+untagged.{:d}.g{}".format(
306+
pieces["distance"], pieces["short"]
307+
)
300308
if pieces["dirty"]:
301309
rendered += ".dirty"
302310
return rendered
@@ -446,7 +454,9 @@ def get_versions():
446454
verbose = cfg.verbose
447455

448456
try:
449-
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose)
457+
return git_versions_from_keywords(
458+
get_keywords(), cfg.tag_prefix, verbose
459+
)
450460
except NotThisMethod:
451461
pass
452462

pandas/api/extensions/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
)
77
from pandas.core.algorithms import take # noqa
88
from pandas.core.arrays import ExtensionArray, ExtensionScalarOpsMixin # noqa
9-
from pandas.core.dtypes.dtypes import ExtensionDtype, register_extension_dtype # noqa
9+
from pandas.core.dtypes.dtypes import (
10+
ExtensionDtype,
11+
register_extension_dtype,
12+
) # noqa

pandas/compat/_optional.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,17 @@ def _get_version(module: types.ModuleType) -> str:
4444
version = getattr(module, "__VERSION__", None)
4545

4646
if version is None:
47-
raise ImportError("Can't determine version for {}".format(module.__name__))
47+
raise ImportError(
48+
"Can't determine version for {}".format(module.__name__)
49+
)
4850
return version
4951

5052

5153
def import_optional_dependency(
52-
name: str, extra: str = "", raise_on_missing: bool = True, on_version: str = "raise"
54+
name: str,
55+
extra: str = "",
56+
raise_on_missing: bool = True,
57+
on_version: str = "raise",
5358
):
5459
"""
5560
Import an optional dependency.
@@ -99,7 +104,9 @@ def import_optional_dependency(
99104
if distutils.version.LooseVersion(version) < minimum_version:
100105
assert on_version in {"warn", "raise", "ignore"}
101106
msg = version_message.format(
102-
minimum_version=minimum_version, name=name, actual_version=version
107+
minimum_version=minimum_version,
108+
name=name,
109+
actual_version=version,
103110
)
104111
if on_version == "warn":
105112
warnings.warn(msg, UserWarning)

pandas/compat/numpy/function.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@
3333

3434

3535
class CompatValidator:
36-
def __init__(self, defaults, fname=None, method=None, max_fname_arg_count=None):
36+
def __init__(
37+
self, defaults, fname=None, method=None, max_fname_arg_count=None
38+
):
3739
self.fname = fname
3840
self.method = method
3941
self.defaults = defaults
4042
self.max_fname_arg_count = max_fname_arg_count
4143

42-
def __call__(self, args, kwargs, fname=None, max_fname_arg_count=None, method=None):
44+
def __call__(
45+
self, args, kwargs, fname=None, max_fname_arg_count=None, method=None
46+
):
4347
if args or kwargs:
4448
fname = self.fname if fname is None else fname
4549
max_fname_arg_count = (
@@ -59,7 +63,8 @@ def __call__(self, args, kwargs, fname=None, max_fname_arg_count=None, method=No
5963
)
6064
else:
6165
raise ValueError(
62-
"invalid validation method " "'{method}'".format(method=method)
66+
"invalid validation method "
67+
"'{method}'".format(method=method)
6368
)
6469

6570

@@ -108,7 +113,9 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
108113
return skipna
109114

110115

111-
ARGSORT_DEFAULTS = OrderedDict() # type: OrderedDict[str, Optional[Union[int, str]]]
116+
ARGSORT_DEFAULTS = (
117+
OrderedDict()
118+
) # type: OrderedDict[str, Optional[Union[int, str]]]
112119
ARGSORT_DEFAULTS["axis"] = -1
113120
ARGSORT_DEFAULTS["kind"] = "quicksort"
114121
ARGSORT_DEFAULTS["order"] = None
@@ -128,7 +135,10 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
128135
ARGSORT_DEFAULTS_KIND["axis"] = -1
129136
ARGSORT_DEFAULTS_KIND["order"] = None
130137
validate_argsort_kind = CompatValidator(
131-
ARGSORT_DEFAULTS_KIND, fname="argsort", max_fname_arg_count=0, method="both"
138+
ARGSORT_DEFAULTS_KIND,
139+
fname="argsort",
140+
max_fname_arg_count=0,
141+
method="both",
132142
)
133143

134144

@@ -241,7 +251,9 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name):
241251
ROUND_DEFAULTS, fname="round", method="both", max_fname_arg_count=1
242252
)
243253

244-
SORT_DEFAULTS = OrderedDict() # type: OrderedDict[str, Optional[Union[int, str]]]
254+
SORT_DEFAULTS = (
255+
OrderedDict()
256+
) # type: OrderedDict[str, Optional[Union[int, str]]]
245257
SORT_DEFAULTS["axis"] = -1
246258
SORT_DEFAULTS["kind"] = "quicksort"
247259
SORT_DEFAULTS["order"] = None
@@ -275,11 +287,15 @@ def validate_cum_func_with_skipna(skipna, args, kwargs, name):
275287
MEDIAN_DEFAULTS, fname="median", method="both", max_fname_arg_count=1
276288
)
277289

278-
STAT_DDOF_FUNC_DEFAULTS = OrderedDict() # type: OrderedDict[str, Optional[bool]]
290+
STAT_DDOF_FUNC_DEFAULTS = (
291+
OrderedDict()
292+
) # type: OrderedDict[str, Optional[bool]]
279293
STAT_DDOF_FUNC_DEFAULTS["dtype"] = None
280294
STAT_DDOF_FUNC_DEFAULTS["out"] = None
281295
STAT_DDOF_FUNC_DEFAULTS["keepdims"] = False
282-
validate_stat_ddof_func = CompatValidator(STAT_DDOF_FUNC_DEFAULTS, method="kwargs")
296+
validate_stat_ddof_func = CompatValidator(
297+
STAT_DDOF_FUNC_DEFAULTS, method="kwargs"
298+
)
283299

284300
TAKE_DEFAULTS = OrderedDict() # type: OrderedDict[str, Optional[str]]
285301
TAKE_DEFAULTS["out"] = None

pandas/compat/pickle_compat.py

+28-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def load_reduce(self):
5757

5858
# If classes are moved, provide compat here.
5959
_class_locations_map = {
60-
("pandas.core.sparse.array", "SparseArray"): ("pandas.core.arrays", "SparseArray"),
60+
("pandas.core.sparse.array", "SparseArray"): (
61+
"pandas.core.arrays",
62+
"SparseArray",
63+
),
6164
# 15477
6265
#
6366
# TODO: When FrozenNDArray is removed, add
@@ -74,7 +77,10 @@ def load_reduce(self):
7477
"pandas.core.indexes.frozen",
7578
"FrozenNDArray",
7679
),
77-
("pandas.core.base", "FrozenList"): ("pandas.core.indexes.frozen", "FrozenList"),
80+
("pandas.core.base", "FrozenList"): (
81+
"pandas.core.indexes.frozen",
82+
"FrozenList",
83+
),
7884
# 10890
7985
("pandas.core.series", "TimeSeries"): ("pandas.core.series", "Series"),
8086
("pandas.sparse.series", "SparseTimeSeries"): (
@@ -86,7 +92,10 @@ def load_reduce(self):
8692
("pandas.tslib", "Timestamp"): ("pandas._libs.tslib", "Timestamp"),
8793
# 18543 moving period
8894
("pandas._period", "Period"): ("pandas._libs.tslibs.period", "Period"),
89-
("pandas._libs.period", "Period"): ("pandas._libs.tslibs.period", "Period"),
95+
("pandas._libs.period", "Period"): (
96+
"pandas._libs.tslibs.period",
97+
"Period",
98+
),
9099
# 18014 moved __nat_unpickle from _libs.tslib-->_libs.tslibs.nattype
91100
("pandas.tslib", "__nat_unpickle"): (
92101
"pandas._libs.tslibs.nattype",
@@ -109,14 +118,23 @@ def load_reduce(self):
109118
"pandas.core.sparse.frame",
110119
"SparseDataFrame",
111120
),
112-
("pandas.indexes.base", "_new_Index"): ("pandas.core.indexes.base", "_new_Index"),
121+
("pandas.indexes.base", "_new_Index"): (
122+
"pandas.core.indexes.base",
123+
"_new_Index",
124+
),
113125
("pandas.indexes.base", "Index"): ("pandas.core.indexes.base", "Index"),
114126
("pandas.indexes.numeric", "Int64Index"): (
115127
"pandas.core.indexes.numeric",
116128
"Int64Index",
117129
),
118-
("pandas.indexes.range", "RangeIndex"): ("pandas.core.indexes.range", "RangeIndex"),
119-
("pandas.indexes.multi", "MultiIndex"): ("pandas.core.indexes.multi", "MultiIndex"),
130+
("pandas.indexes.range", "RangeIndex"): (
131+
"pandas.core.indexes.range",
132+
"RangeIndex",
133+
),
134+
("pandas.indexes.multi", "MultiIndex"): (
135+
"pandas.core.indexes.multi",
136+
"MultiIndex",
137+
),
120138
("pandas.tseries.index", "_new_DatetimeIndex"): (
121139
"pandas.core.indexes.datetimes",
122140
"_new_DatetimeIndex",
@@ -130,7 +148,10 @@ def load_reduce(self):
130148
"PeriodIndex",
131149
),
132150
# 19269, arrays moving
133-
("pandas.core.categorical", "Categorical"): ("pandas.core.arrays", "Categorical"),
151+
("pandas.core.categorical", "Categorical"): (
152+
"pandas.core.arrays",
153+
"Categorical",
154+
),
134155
# 19939, add timedeltaindex, float64index compat from 15998 move
135156
("pandas.tseries.tdi", "TimedeltaIndex"): (
136157
"pandas.core.indexes.timedeltas",

0 commit comments

Comments
 (0)