Skip to content

Commit a32e020

Browse files
committed
Small diff cleanups
1 parent a499ed8 commit a32e020

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

pandas/core/arrays/timedeltas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def _generate_range(cls, start, end, periods, freq, closed=None):
259259
# DatetimeLike Interface
260260

261261
def _unbox_scalar(self, value):
262-
if not isinstance(value, (self._scalar_type, type(NaT))):
263-
raise ValueError("'value' should be a a Timestamp.")
262+
if not isinstance(value, self._scalar_type) and value is not NaT:
263+
raise ValueError("'value' should be a Timedelta.")
264264
self._check_compatible_with(value)
265265
return value.value
266266

pandas/core/indexes/timedeltas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ def astype(self, dtype, copy=True):
345345
dtype = pandas_dtype(dtype)
346346
if is_timedelta64_dtype(dtype) and not is_timedelta64_ns_dtype(dtype):
347347
# Have to repeat the check for 'timedelta64' (not ns) dtype
348-
# so that we can return a numeric index, since pandas will return
349-
# a TimedeltaIndex when dtype='timedelta'
348+
# so that we can return a numeric index, since pandas will return
349+
# a TimedeltaIndex when dtype='timedelta'
350350
result = self._data.astype(dtype, copy=copy)
351351
if self.hasnans:
352352
return Index(result, name=self.name)

pandas/tests/arithmetic/test_datetime64.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ def test_dti_sub_tdi(self, tz_naive_fixture):
19811981
result = dti - tdi
19821982
tm.assert_index_equal(result, expected)
19831983

1984-
msg = 'cannot subtract .*TimedeltaArray'
1984+
msg = 'cannot subtract .*TimedeltaArrayMixin'
19851985
with pytest.raises(TypeError, match=msg):
19861986
tdi - dti
19871987

pandas/tests/indexes/datetimes/test_astype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_astype_object_with_nat(self):
177177
def test_astype_raises(self, dtype):
178178
# GH 13149, GH 13209
179179
idx = DatetimeIndex(['2016-05-16', 'NaT', NaT, np.NaN])
180-
msg = 'Cannot cast DatetimeArray(Mixin)? to dtype'
180+
msg = 'Cannot cast DatetimeArrayMixin to dtype'
181181
with pytest.raises(TypeError, match=msg):
182182
idx.astype(dtype)
183183

pandas/tests/indexes/timedeltas/test_astype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_astype_timedelta64(self):
8484
def test_astype_raises(self, dtype):
8585
# GH 13149, GH 13209
8686
idx = TimedeltaIndex([1e14, 'NaT', NaT, np.NaN])
87-
msg = 'Cannot cast TimedeltaArray(Mixin)? to dtype'
87+
msg = 'Cannot cast TimedeltaArrayMixin to dtype'
8888
with pytest.raises(TypeError, match=msg):
8989
idx.astype(dtype)
9090

0 commit comments

Comments
 (0)