@@ -585,8 +585,7 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"):
585585 newb = self .copy () if copy else self
586586 return newb
587587
588- # TODO(extension)
589- # should we make this attribute?
588+ # TODO(EA2D): special case not needed with 2D EAs
590589 if isinstance (values , np .ndarray ):
591590 values = values .reshape (self .shape )
592591
@@ -1554,13 +1553,15 @@ def __init__(self, values, placement, ndim=None):
15541553
15551554 @property
15561555 def shape (self ):
1556+ # TODO(EA2D): override unnecessary with 2D EAs
15571557 if self .ndim == 1 :
15581558 return ((len (self .values )),)
15591559 return (len (self .mgr_locs ), len (self .values ))
15601560
15611561 def iget (self , col ):
15621562
15631563 if self .ndim == 2 and isinstance (col , tuple ):
1564+ # TODO(EA2D): unnecessary with 2D EAs
15641565 col , loc = col
15651566 if not com .is_null_slice (col ) and col != 0 :
15661567 raise IndexError (f"{ self } only contains one item" )
@@ -1669,6 +1670,7 @@ def setitem(self, indexer, value):
16691670 be a compatible shape.
16701671 """
16711672 if isinstance (indexer , tuple ):
1673+ # TODO(EA2D): not needed with 2D EAs
16721674 # we are always 1-D
16731675 indexer = indexer [0 ]
16741676
@@ -1678,6 +1680,7 @@ def setitem(self, indexer, value):
16781680
16791681 def get_values (self , dtype = None ):
16801682 # ExtensionArrays must be iterable, so this works.
1683+ # TODO(EA2D): reshape not needed with 2D EAs
16811684 return np .asarray (self .values ).reshape (self .shape )
16821685
16831686 def array_values (self ) -> ExtensionArray :
@@ -1691,6 +1694,7 @@ def to_native_types(self, na_rep="nan", quoting=None, **kwargs):
16911694 values = np .asarray (values .astype (object ))
16921695 values [mask ] = na_rep
16931696
1697+ # TODO(EA2D): reshape not needed with 2D EAs
16941698 # we are expected to return a 2-d ndarray
16951699 return values .reshape (1 , len (values ))
16961700
@@ -1703,6 +1707,7 @@ def take_nd(
17031707 if fill_value is lib .no_default :
17041708 fill_value = None
17051709
1710+ # TODO(EA2D): special case not needed with 2D EAs
17061711 # axis doesn't matter; we are really a single-dim object
17071712 # but are passed the axis depending on the calling routing
17081713 # if its REALLY axis 0, then this will be a reindex and not a take
@@ -2229,6 +2234,7 @@ def diff(self, n: int, axis: int = 0) -> List["Block"]:
22292234 by apply.
22302235 """
22312236 if axis == 0 :
2237+ # TODO(EA2D): special case not needed with 2D EAs
22322238 # Cannot currently calculate diff across multiple blocks since this
22332239 # function is invoked via apply
22342240 raise NotImplementedError
@@ -2280,7 +2286,7 @@ def quantile(self, qs, interpolation="linear", axis=0):
22802286 blk = self .make_block (naive )
22812287 res_blk = blk .quantile (qs , interpolation = interpolation , axis = axis )
22822288
2283- # ravel is kludge for 2D block with 1D values, assumes column-like
2289+ # TODO(EA2D): ravel is kludge for 2D block with 1D values, assumes column-like
22842290 aware = self ._holder (res_blk .values .ravel (), dtype = self .dtype )
22852291 return self .make_block_same_class (aware , ndim = res_blk .ndim )
22862292
@@ -2693,6 +2699,7 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None):
26932699 if isinstance (values , ABCPandasArray ):
26942700 values = values .to_numpy ()
26952701 if ndim and ndim > 1 :
2702+ # TODO(EA2D): special case not needed with 2D EAs
26962703 values = np .atleast_2d (values )
26972704
26982705 if isinstance (dtype , PandasDtype ):
@@ -2759,6 +2766,7 @@ def _safe_reshape(arr, new_shape):
27592766 if isinstance (arr , ABCSeries ):
27602767 arr = arr ._values
27612768 if not isinstance (arr , ABCExtensionArray ):
2769+ # TODO(EA2D): special case not needed with 2D EAs
27622770 arr = arr .reshape (new_shape )
27632771 return arr
27642772
0 commit comments