@@ -170,6 +170,10 @@ def __init__(self, values, placement, ndim: int):
170
170
f"placement implies { len (self .mgr_locs )} "
171
171
)
172
172
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
+
173
177
@classmethod
174
178
def _maybe_coerce_values (cls , values ):
175
179
"""
@@ -185,7 +189,7 @@ def _maybe_coerce_values(cls, values):
185
189
"""
186
190
return values
187
191
188
- def _check_ndim (self , values , ndim ):
192
+ def _check_ndim (self , values , ndim : int ):
189
193
"""
190
194
ndim inference and validation.
191
195
@@ -196,7 +200,7 @@ def _check_ndim(self, values, ndim):
196
200
Parameters
197
201
----------
198
202
values : array-like
199
- ndim : int or None
203
+ ndim : int
200
204
201
205
Returns
202
206
-------
@@ -206,8 +210,7 @@ def _check_ndim(self, values, ndim):
206
210
------
207
211
ValueError : the number of dimensions do not match
208
212
"""
209
- if ndim is None :
210
- ndim = values .ndim
213
+ assert isinstance (ndim , int ) # GH#38134 enforce this
211
214
212
215
if self ._validate_ndim :
213
216
if values .ndim != ndim :
@@ -1466,33 +1469,6 @@ class ExtensionBlock(Block):
1466
1469
1467
1470
values : ExtensionArray
1468
1471
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
-
1496
1472
@property
1497
1473
def shape (self ) -> Shape :
1498
1474
# TODO(EA2D): override unnecessary with 2D EAs
0 commit comments