Skip to content

Commit 8c68e2a

Browse files
fixes for changes in master
1 parent bade9e4 commit 8c68e2a

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,6 @@ def _resolution(self):
386386
# ----------------------------------------------------------------
387387
# Array-Like / EA-Interface Methods
388388

389-
def __array__(self, dtype=None):
390-
if is_object_dtype(dtype):
391-
return np.array(list(self), dtype=object)
392-
elif is_int64_dtype(dtype):
393-
return self.asi8
394-
395-
# TODO: warn that conversion may be lossy?
396-
return self._data.view(np.ndarray) # follow Index.__array__
397-
398389
def __iter__(self):
399390
"""
400391
Return an iterator over the boxed values

pandas/core/indexes/datetimelike.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ class DatetimeIndexOpsMixin(DatetimeLikeArrayMixin):
230230

231231
def __array__(self, dtype=None):
232232
# TODO properly dispatch to EA
233-
return Index.__array__(self)
233+
if is_period_dtype(self):
234+
return self._data.__array__(dtype=dtype)
235+
if is_object_dtype(dtype):
236+
return np.array(list(self), dtype=object)
237+
return self._data
234238

235239
def equals(self, other):
236240
"""

pandas/tests/arrays/test_datetimelike.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def test_array2(self, datetime_index):
168168
tm.assert_numpy_array_equal(result, expected)
169169

170170
def test_array_i8_dtype(self, tz_naive_fixture):
171-
# GH#23524
172171
tz = tz_naive_fixture
173172
dti = pd.date_range('2016-01-01', periods=3, tz=tz)
174173
arr = DatetimeArray(dti)
@@ -180,10 +179,10 @@ def test_array_i8_dtype(self, tz_naive_fixture):
180179
result = np.array(arr, dtype=np.int64)
181180
tm.assert_numpy_array_equal(result, expected)
182181

183-
# check that we are not making copies when setting copy=False
182+
# check that we are still making copies when setting copy=False
184183
result = np.array(arr, dtype='i8', copy=False)
185-
assert result.base is expected.base
186-
assert result.base is not None
184+
assert result.base is not expected.base
185+
assert result.base is None
187186

188187
def test_from_dti(self, tz_naive_fixture):
189188
tz = tz_naive_fixture

0 commit comments

Comments
 (0)