Skip to content

Commit 9dd0150

Browse files
committed
assert that _simple_new always receives an array of datetime64[ns]
1 parent deca8a4 commit 9dd0150

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ def _generate(cls, start, end, periods, name, freq,
559559
arr = arr.view(_NS_DTYPE)
560560
index = DatetimeIndex(arr)
561561

562+
562563
# index is localized datetime64 array -> have to convert
563564
# start/end as well to compare
564565
if start is not None:
@@ -611,8 +612,8 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
611612
dtype=dtype, **kwargs)
612613
values = np.array(values, copy=False)
613614

614-
# values should be a numpy array
615-
assert isinstance(values, np.ndarray)
615+
assert isinstance(values, np.ndarray), "values is not an np.ndarray"
616+
assert is_datetime64_dtype(values)
616617

617618
if is_object_dtype(values):
618619
return cls(values, name=name, freq=freq, tz=tz,
@@ -2094,6 +2095,8 @@ def _generate_regular_range(start, end, periods, freq):
20942095
"if a 'period' is given.")
20952096

20962097
data = np.arange(b, e, stride, dtype=np.int64)
2098+
2099+
# _simple_new is getting an array of int64 here
20972100
data = DatetimeIndex._simple_new(data, None, tz=tz)
20982101
else:
20992102
if isinstance(start, Timestamp):

0 commit comments

Comments
 (0)