@@ -2316,7 +2316,7 @@ def combine(self, blocks, copy=True):
2316
2316
2317
2317
# FIXME: optimization potential
2318
2318
indexer = np .sort (np .concatenate ([b .mgr_locs .as_array for b in blocks ]))
2319
- inv_indexer = _invert_reordering (indexer )
2319
+ inv_indexer = lib . get_reverse_indexer (indexer , self . shape [ 0 ] )
2320
2320
new_items = self .items .take (indexer )
2321
2321
2322
2322
new_blocks = []
@@ -3506,71 +3506,10 @@ def _possibly_compare(a, b, op):
3506
3506
return res
3507
3507
3508
3508
3509
-
3510
-
3511
3509
def _concat_indexes (indexes ):
3512
3510
return indexes [0 ].append (indexes [1 :])
3513
3511
3514
3512
3515
- def _invert_reordering (reordering , minlength = None ):
3516
- """
3517
- Invert reordering operation.
3518
-
3519
- Given array `reordering`, make `reordering_inv` of it, such that::
3520
-
3521
- reordering_inv[reordering[x]] = x
3522
-
3523
- There are two types of indexers:
3524
-
3525
- source
3526
- is when element *s* at position *i* means that values to fill *i-th*
3527
- item of reindex operation should be taken from *s-th* item of the
3528
- original (this is what is returned by `pandas.Index.reindex`).
3529
- destination
3530
- is when element *d* at position *i* means that values from *i-th* item
3531
- of source should be used to fill *d-th* item of reindexing operation.
3532
-
3533
- This function will convert from *source* to *destination* and vice-versa.
3534
-
3535
- .. note:: trailing ``-1`` may be lost upon conversion (this is what
3536
- `minlength` is there for).
3537
-
3538
- .. note:: if *source* indexer is not unique, corresponding *destination*
3539
- indexer will have ``dtype=object`` and will contain lists.
3540
-
3541
- Examples:
3542
-
3543
- >>> _invert_reordering([3, -1, 2, 4, -1])
3544
- array([-1, -1, 2, 0, 3])
3545
- >>> _invert_reordering([-1, -1, 0, 2, 3])
3546
- array([3, -1, 2, 4])
3547
- >>> _invert_reordering([1,3,5])
3548
- array([-1, 0, -1, 1, -1, 2])
3549
-
3550
- """
3551
- reordering = np .asanyarray (reordering , dtype = np .int64 )
3552
- if not com .is_integer_dtype (reordering ):
3553
- raise ValueError ("Only integer indexers are supported" )
3554
-
3555
- nonneg_indices = reordering [reordering >= 0 ].astype (np .int_ )
3556
- counts = np .bincount (nonneg_indices , minlength = minlength )
3557
- has_non_unique = (counts > 1 ).any ()
3558
-
3559
- dtype = np .dtype (np .object_ ) if has_non_unique else np .dtype (np .int64 )
3560
- inverted = np .empty_like (counts , dtype = dtype )
3561
- inverted .fill (- 1 )
3562
-
3563
- nonneg_positions = np .arange (len (reordering ), dtype = np .int64 )[reordering >= 0 ]
3564
- np .put (inverted , nonneg_indices , nonneg_positions )
3565
-
3566
- if has_non_unique :
3567
- nonunique_elements = np .arange (len (counts ))[counts > 1 ]
3568
- for elt in nonunique_elements :
3569
- inverted [elt ] = nonneg_positions [nonneg_indices == elt ].tolist ()
3570
-
3571
- return inverted
3572
-
3573
-
3574
3513
def _get_blkno_placements (blknos , blk_count , group = True ):
3575
3514
"""
3576
3515
0 commit comments