@@ -170,6 +170,10 @@ def __init__(self, values, placement, ndim: int):
170170 f"placement implies { len (self .mgr_locs )} "
171171 )
172172
173+ elif self .is_extension and self .ndim == 2 and len (self .mgr_locs ) != 1 :
174+ # TODO(EA2D): check unnecessary with 2D EAs
175+ raise AssertionError ("block.size != values.size" )
176+
173177 @classmethod
174178 def _maybe_coerce_values (cls , values ):
175179 """
@@ -185,7 +189,7 @@ def _maybe_coerce_values(cls, values):
185189 """
186190 return values
187191
188- def _check_ndim (self , values , ndim ):
192+ def _check_ndim (self , values , ndim : int ):
189193 """
190194 ndim inference and validation.
191195
@@ -196,7 +200,7 @@ def _check_ndim(self, values, ndim):
196200 Parameters
197201 ----------
198202 values : array-like
199- ndim : int or None
203+ ndim : int
200204
201205 Returns
202206 -------
@@ -206,8 +210,7 @@ def _check_ndim(self, values, ndim):
206210 ------
207211 ValueError : the number of dimensions do not match
208212 """
209- if ndim is None :
210- ndim = values .ndim
213+ assert isinstance (ndim , int ) # GH#38134 enforce this
211214
212215 if self ._validate_ndim :
213216 if values .ndim != ndim :
@@ -1466,33 +1469,6 @@ class ExtensionBlock(Block):
14661469
14671470 values : ExtensionArray
14681471
1469- def __init__ (self , values , placement , ndim : int ):
1470- """
1471- Initialize a non-consolidatable block.
1472-
1473- 'ndim' may be inferred from 'placement'.
1474-
1475- This will call continue to call __init__ for the other base
1476- classes mixed in with this Mixin.
1477- """
1478-
1479- # Placement must be converted to BlockPlacement so that we can check
1480- # its length
1481- if not isinstance (placement , libinternals .BlockPlacement ):
1482- placement = libinternals .BlockPlacement (placement )
1483-
1484- # Maybe infer ndim from placement
1485- if ndim is None :
1486- if len (placement ) != 1 :
1487- ndim = 1
1488- else :
1489- ndim = 2
1490- super ().__init__ (values , placement , ndim = ndim )
1491-
1492- if self .ndim == 2 and len (self .mgr_locs ) != 1 :
1493- # TODO(EA2D): check unnecessary with 2D EAs
1494- raise AssertionError ("block.size != values.size" )
1495-
14961472 @property
14971473 def shape (self ) -> Shape :
14981474 # TODO(EA2D): override unnecessary with 2D EAs
0 commit comments