File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,9 @@ def setup(self, N):
196
196
self .intv = IntervalIndex .from_arrays (left , right )
197
197
self .intv ._engine
198
198
199
+ self .intv2 = IntervalIndex .from_arrays (left + 1 , right + 1 )
200
+ self .intv2 ._engine
201
+
199
202
self .left = IntervalIndex .from_breaks (np .arange (N ))
200
203
self .right = IntervalIndex .from_breaks (np .arange (N - 3 , 2 * N - 3 ))
201
204
@@ -208,8 +211,11 @@ def time_is_unique(self, N):
208
211
def time_intersection (self , N ):
209
212
self .left .intersection (self .right )
210
213
211
- def time_intersection_duplicate (self , N ):
214
+ def time_intersection_one_duplicate (self , N ):
212
215
self .intv .intersection (self .right )
213
216
217
+ def time_intersection_both_duplicate (self , N ):
218
+ self .intv .intersection (self .intv2 )
219
+
214
220
215
221
from .pandas_vb_common import setup # noqa: F401
Original file line number Diff line number Diff line change @@ -1143,6 +1143,11 @@ def overlaps(self, other):
1143
1143
def intersection (self , other , sort = False ):
1144
1144
if self .left .is_unique and self .right .is_unique :
1145
1145
taken = self ._intersection_unique (other )
1146
+ elif (other .left .is_unique and other .right .is_unique and
1147
+ self .isna ().sum () <= 1 ):
1148
+ # Swap other/self if other is unique and self does not have
1149
+ # multiple NaNs
1150
+ taken = other ._intersection_unique (self )
1146
1151
else :
1147
1152
# duplicates
1148
1153
taken = self ._intersection_non_unique (other )
You can’t perform that action at this time.
0 commit comments