Skip to content

Commit

Permalink
CLN: remove values attribute from datetimelike EAs (pandas-dev#23603)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche authored and Pingviinituutti committed Feb 28, 2019
1 parent aed3852 commit 9bdc082
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
9 changes: 2 additions & 7 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def cmp_method(self, other):
with warnings.catch_warnings(record=True):
warnings.filterwarnings("ignore", "elementwise", FutureWarning)
with np.errstate(all='ignore'):
result = op(self.values, np.asarray(other))
result = op(self._data, np.asarray(other))

return result

Expand Down Expand Up @@ -119,15 +119,10 @@ def _box_values(self, values):
def __iter__(self):
return (self._box_func(v) for v in self.asi8)

@property
def values(self):
""" return the underlying data as an ndarray """
return self._data.view(np.ndarray)

@property
def asi8(self):
# do not cache or you'll create a memory leak
return self.values.view('i8')
return self._data.view('i8')

# ------------------------------------------------------------------
# Array-like Methods
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def to_period(self, freq=None):

freq = get_period_alias(freq)

return PeriodArray._from_datetime64(self.values, freq, tz=self.tz)
return PeriodArray._from_datetime64(self._data, freq, tz=self.tz)

def to_perioddelta(self, freq):
"""
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def wrapper(self, other):
raise TypeError(msg.format(cls=type(self).__name__,
typ=type(other).__name__))
else:
other = type(self)(other).values
other = type(self)(other)._data
result = meth(self, other)
result = com.values_from_object(result)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def __new__(cls, data=None,
'set specified tz: {1}')
raise TypeError(msg.format(data.tz, tz))

subarr = data.values
subarr = data._data

if freq is None:
freq = data.freq
Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/extension/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ def test_combine_add(self, data_repeated):

class TestInterface(BasePeriodTests, base.BaseInterfaceTests):

def test_no_values_attribute(self, data):
# We have a values attribute.
pass
pass


class TestArithmeticOps(BasePeriodTests, base.BaseArithmeticOpsTests):
Expand Down

0 comments on commit 9bdc082

Please sign in to comment.