Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
jbrockmendel committed Jun 25, 2019
commit d4d0dbd05868417450d37bae122d56306bfdafe7
11 changes: 0 additions & 11 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,10 @@
class AttributesMixin: # TODO: how much of this do we still need?
_data = None # type: np.ndarray

@property
def _attributes(self):
# Inheriting subclass should implement _attributes as a list of strings
raise AbstractMethodError(self)

@classmethod
def _simple_new(cls, values, **kwargs):
raise AbstractMethodError(cls)

def _get_attributes_dict(self):
"""
return an attributes dict for my class
"""
return {k: getattr(self, k, None) for k in self._attributes}

@property
def _scalar_type(self) -> Type[DatetimeLikeScalar]:
"""The scalar associated with this datelike
Expand Down
15 changes: 4 additions & 11 deletions pandas/core/arrays/reshaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def shift(self, periods: int = 1, fill_value: object = None):
# FIXME: technically wrong to allow if we dont have ndim == 1

result = self._1dvalues.shift(periods, fill_value=fill_value)
shape = self.shape
return type(self)(result, shape=shape)
return type(self)(result, shape=self.shape)

# --------------------------------------------------
# Lightly Modified pass-through methods
Expand Down Expand Up @@ -127,11 +126,7 @@ def __sub__(self, other):
return type(self)(result, shape=self.shape)

def __array__(self, dtype=None):
if hasattr(self._1dvalues, "__array__"):
result = self._1dvalues.__array__(dtype=dtype)
else:
result = np.array(self._1dvalues, dtype=dtype)
# TODO: cant we use this unconditionally?
result = np.array(self._1dvalues, dtype=dtype)
return result.reshape(self.shape)

def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
Expand Down Expand Up @@ -472,10 +467,8 @@ def _tuplify_shape(size: int, shape) -> Tuple[int, ...]:
return shape


def unwrap_reshapeable(values, check=True):
def unwrap_reshapeable(values):
if isinstance(values, ReshapeableArray):
# FIXME: re-enablen check
# if check:
# assert values.ndim == 1
# TODO: require we are only working with 1D?
return values._1dvalues
return values
2 changes: 1 addition & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ def _maybe_coerce_values(self, values):
@property
def _holder(self):
# For extension blocks, the holder is values-dependent.
return type(unwrap_reshapeable(self.values, check=False))
return type(unwrap_reshapeable(self.values))

@property
def fill_value(self):
Expand Down