@@ -4435,17 +4435,6 @@ def _interleaved_dtype(blocks):
4435
4435
for x in blocks :
4436
4436
counts [type (x )].append (x )
4437
4437
4438
- def _lcd_dtype (l ):
4439
- """ find the lowest dtype that can accomodate the given types """
4440
- m = l [0 ].dtype
4441
- for x in l [1 :]:
4442
- # the new dtype must either be wider or a strict subtype
4443
- if (x .dtype .itemsize > m .itemsize or
4444
- (np .issubdtype (m , x .dtype ) and
4445
- not np .issubdtype (x .dtype , m ))):
4446
- m = x .dtype
4447
- return m
4448
-
4449
4438
have_int = len (counts [IntBlock ]) > 0
4450
4439
have_bool = len (counts [BoolBlock ]) > 0
4451
4440
have_object = len (counts [ObjectBlock ]) > 0
@@ -4458,7 +4447,6 @@ def _lcd_dtype(l):
4458
4447
# TODO: have_sparse is not used
4459
4448
have_sparse = len (counts [SparseBlock ]) > 0 # noqa
4460
4449
have_numeric = have_float or have_complex or have_int
4461
-
4462
4450
has_non_numeric = have_dt64 or have_dt64_tz or have_td64 or have_cat
4463
4451
4464
4452
if (have_object or
@@ -4470,10 +4458,9 @@ def _lcd_dtype(l):
4470
4458
elif have_bool :
4471
4459
return np .dtype (bool )
4472
4460
elif have_int and not have_float and not have_complex :
4473
-
4474
4461
# if we are mixing unsigned and signed, then return
4475
4462
# the next biggest int type (if we can)
4476
- lcd = _lcd_dtype ( counts [IntBlock ])
4463
+ lcd = np . find_common_type ([ b . dtype for b in counts [IntBlock ]], [ ])
4477
4464
kinds = set ([i .dtype .kind for i in counts [IntBlock ]])
4478
4465
if len (kinds ) == 1 :
4479
4466
return lcd
@@ -4489,7 +4476,8 @@ def _lcd_dtype(l):
4489
4476
elif have_complex :
4490
4477
return np .dtype ('c16' )
4491
4478
else :
4492
- return _lcd_dtype (counts [FloatBlock ] + counts [SparseBlock ])
4479
+ introspection_blks = counts [FloatBlock ] + counts [SparseBlock ]
4480
+ return np .find_common_type ([b .dtype for b in introspection_blks ], [])
4493
4481
4494
4482
4495
4483
def _consolidate (blocks ):
0 commit comments