Skip to content

Commit fd6f627

Browse files
authored
Merge pull request #4 from pandas-dev/master
Sync Fork from Upstream Repo
2 parents 7d37ad8 + 75ecfa4 commit fd6f627

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

pandas/_libs/index.pyx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ cdef class DatetimeEngine(Int64Engine):
447447
conv = maybe_datetimelike_to_i8(val)
448448
loc = values.searchsorted(conv, side='left')
449449
except TypeError:
450-
self._date_check_type(val)
451450
raise KeyError(val)
452451

453452
if loc == len(values) or values[loc] != conv:
@@ -470,12 +469,6 @@ cdef class DatetimeEngine(Int64Engine):
470469
val = maybe_datetimelike_to_i8(val)
471470
return self.mapping.get_item(val)
472471
except (TypeError, ValueError):
473-
self._date_check_type(val)
474-
raise KeyError(val)
475-
476-
cdef inline _date_check_type(self, object val):
477-
hash(val)
478-
if not util.is_integer_object(val):
479472
raise KeyError(val)
480473

481474
def get_indexer(self, values):

pandas/conftest.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,28 @@ def pytest_runtest_setup(item):
6565
pytest.skip("skipping high memory test since --run-high-memory was not set")
6666

6767

68-
# Configurations for all tests and all test modules
69-
70-
7168
@pytest.fixture(autouse=True)
7269
def configure_tests():
70+
"""
71+
Configure settings for all tests and test modules.
72+
"""
7373
pd.set_option("chained_assignment", "raise")
7474

7575

76-
# For running doctests: make np and pd names available
77-
78-
7976
@pytest.fixture(autouse=True)
8077
def add_imports(doctest_namespace):
78+
"""
79+
Make `np` and `pd` names available for doctests.
80+
"""
8181
doctest_namespace["np"] = np
8282
doctest_namespace["pd"] = pd
8383

8484

8585
@pytest.fixture(params=["bsr", "coo", "csc", "csr", "dia", "dok", "lil"])
8686
def spmatrix(request):
87+
"""
88+
Yields scipy sparse matrix classes.
89+
"""
8790
from scipy import sparse
8891

8992
return getattr(sparse, request.param + "_matrix")
@@ -92,8 +95,8 @@ def spmatrix(request):
9295
@pytest.fixture(params=[0, 1, "index", "columns"], ids=lambda x: f"axis {repr(x)}")
9396
def axis(request):
9497
"""
95-
Fixture for returning the axis numbers of a DataFrame.
96-
"""
98+
Fixture for returning the axis numbers of a DataFrame.
99+
"""
97100
return request.param
98101

99102

@@ -237,6 +240,10 @@ def all_boolean_reductions(request):
237240

238241
@pytest.fixture(params=list(_cython_table))
239242
def cython_table_items(request):
243+
"""
244+
Yields a tuple of a function and its corresponding name. Correspond to
245+
the list of aggregator "Cython functions" used on selected table items.
246+
"""
240247
return request.param
241248

242249

@@ -337,6 +344,9 @@ def writable(request):
337344

338345
@pytest.fixture(scope="module")
339346
def datetime_tz_utc():
347+
"""
348+
Yields the UTC timezone object from the datetime module.
349+
"""
340350
return timezone.utc
341351

342352

@@ -358,6 +368,9 @@ def join_type(request):
358368

359369
@pytest.fixture
360370
def strict_data_files(pytestconfig):
371+
"""
372+
Returns the configuration for the test setting `--strict-data-files`.
373+
"""
361374
return pytestconfig.getoption("--strict-data-files")
362375

363376

pandas/core/arrays/period.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ def __arrow_array__(self, type=None):
298298
if self.freqstr != type.freq:
299299
raise TypeError(
300300
"Not supported to convert PeriodArray to array with different"
301-
" 'freq' ({0} vs {1})".format(self.freqstr, type.freq)
301+
f" 'freq' ({self.freqstr} vs {type.freq})"
302302
)
303303
else:
304304
raise TypeError(
305-
"Not supported to convert PeriodArray to '{0}' type".format(type)
305+
f"Not supported to convert PeriodArray to '{type}' type"
306306
)
307307

308308
period_type = ArrowPeriodType(self.freqstr)

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
from pandas.tseries.frequencies import to_offset
4444
from pandas.tseries.offsets import Tick
4545

46-
_BAD_DTYPE = "dtype {dtype} cannot be converted to timedelta64[ns]"
47-
4846

4947
def _is_convertible_to_td(key):
5048
return isinstance(key, (Tick, timedelta, np.timedelta64, str))
@@ -1064,7 +1062,7 @@ def _validate_td64_dtype(dtype):
10641062
raise ValueError(msg)
10651063

10661064
if not is_dtype_equal(dtype, _TD_DTYPE):
1067-
raise ValueError(_BAD_DTYPE.format(dtype=dtype))
1065+
raise ValueError(f"dtype {dtype} cannot be converted to timedelta64[ns]")
10681066

10691067
return dtype
10701068

pandas/core/dtypes/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,11 @@ def ensure_python_int(value: Union[int, np.integer]) -> int:
194194
"""
195195
if not is_scalar(value):
196196
raise TypeError(f"Value needs to be a scalar value, was type {type(value)}")
197-
msg = "Wrong type {} for value {}"
198197
try:
199198
new_value = int(value)
200199
assert new_value == value
201200
except (TypeError, ValueError, AssertionError):
202-
raise TypeError(msg.format(type(value), value))
201+
raise TypeError(f"Wrong type {type(value)} for value {value}")
203202
return new_value
204203

205204

pandas/core/dtypes/dtypes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,11 @@ def __eq__(self, other: Any) -> bool:
435435
return hash(self) == hash(other)
436436

437437
def __repr__(self) -> str_type:
438-
tpl = "CategoricalDtype(categories={data}ordered={ordered})"
439438
if self.categories is None:
440439
data = "None, "
441440
else:
442441
data = self.categories._format_data(name=type(self).__name__)
443-
return tpl.format(data=data, ordered=self.ordered)
442+
return f"CategoricalDtype(categories={data}ordered={self.ordered})"
444443

445444
@staticmethod
446445
def _hash_categories(categories, ordered: Ordered = True) -> int:

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ def _verbose_repr():
24312431
dtype = self.dtypes.iloc[i]
24322432
col = pprint_thing(col)
24332433

2434-
line_no = _put_str(" {num}".format(num=i), space_num)
2434+
line_no = _put_str(f" {i}", space_num)
24352435
count = ""
24362436
if show_counts:
24372437
count = counts.iloc[i]

0 commit comments

Comments
 (0)