Skip to content

Commit a0e915c

Browse files
committed
assert that _simple_new always receives an array of datetime64[ns]
1 parent 605f365 commit a0e915c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/indexes/datetimes.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ def _generate(cls, start, end, periods, name, freq,
557557
tz,
558558
ambiguous=ambiguous)
559559

560-
arr = arr.view(_NS_DTYPE)
561560
index = DatetimeIndex(arr)
562561

562+
563563
# index is localized datetime64 array -> have to convert
564564
# start/end as well to compare
565565
if start is not None:
@@ -612,8 +612,8 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
612612
dtype=dtype, **kwargs)
613613
values = np.array(values, copy=False)
614614

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

618618
if is_object_dtype(values):
619619
return cls(values, name=name, freq=freq, tz=tz,
@@ -1918,6 +1918,8 @@ def _generate_regular_range(start, end, periods, freq):
19181918
"if a 'period' is given.")
19191919

19201920
data = np.arange(b, e, stride, dtype=np.int64)
1921+
1922+
# _simple_new is getting an array of int64 here
19211923
data = DatetimeIndex._simple_new(data, None, tz=tz)
19221924
else:
19231925
if isinstance(start, Timestamp):

0 commit comments

Comments
 (0)