Skip to content

Commit

Permalink
fixes for changes in master
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Nov 16, 2018
1 parent bade9e4 commit 8c68e2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
9 changes: 0 additions & 9 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,6 @@ def _resolution(self):
# ----------------------------------------------------------------
# Array-Like / EA-Interface Methods

def __array__(self, dtype=None):
if is_object_dtype(dtype):
return np.array(list(self), dtype=object)
elif is_int64_dtype(dtype):
return self.asi8

# TODO: warn that conversion may be lossy?
return self._data.view(np.ndarray) # follow Index.__array__

def __iter__(self):
"""
Return an iterator over the boxed values
Expand Down
6 changes: 5 additions & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ class DatetimeIndexOpsMixin(DatetimeLikeArrayMixin):

def __array__(self, dtype=None):
# TODO properly dispatch to EA
return Index.__array__(self)
if is_period_dtype(self):
return self._data.__array__(dtype=dtype)
if is_object_dtype(dtype):
return np.array(list(self), dtype=object)
return self._data

def equals(self, other):
"""
Expand Down
7 changes: 3 additions & 4 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def test_array2(self, datetime_index):
tm.assert_numpy_array_equal(result, expected)

def test_array_i8_dtype(self, tz_naive_fixture):
# GH#23524
tz = tz_naive_fixture
dti = pd.date_range('2016-01-01', periods=3, tz=tz)
arr = DatetimeArray(dti)
Expand All @@ -180,10 +179,10 @@ def test_array_i8_dtype(self, tz_naive_fixture):
result = np.array(arr, dtype=np.int64)
tm.assert_numpy_array_equal(result, expected)

# check that we are not making copies when setting copy=False
# check that we are still making copies when setting copy=False
result = np.array(arr, dtype='i8', copy=False)
assert result.base is expected.base
assert result.base is not None
assert result.base is not expected.base
assert result.base is None

def test_from_dti(self, tz_naive_fixture):
tz = tz_naive_fixture
Expand Down

0 comments on commit 8c68e2a

Please sign in to comment.