@@ -376,10 +376,10 @@ def ordered_left_join_int64(ndarray[int64_t] left, ndarray[int64_t] right):
376
376
377
377
@ cython.wraparound (False )
378
378
@ cython.boundscheck (False )
379
- def ordered_left_join_put (ndarray[int64_t] left , ndarray[int64_t] right ,
380
- ndarray[float64_t , ndim = 2 ] lvalues,
381
- ndarray[float64_t , ndim = 2 ] rvalues,
382
- ndarray[float64_t , ndim = 2 ] out):
379
+ def left_join_2d (ndarray[int64_t] left , ndarray[int64_t] right ,
380
+ ndarray[float64_t , ndim = 2 ] lvalues,
381
+ ndarray[float64_t , ndim = 2 ] rvalues,
382
+ ndarray[float64_t , ndim = 2 ] out):
383
383
cdef:
384
384
Py_ssize_t i, j, k, nright, nleft, kright, kleft
385
385
int64_t val
@@ -409,6 +409,37 @@ def ordered_left_join_put(ndarray[int64_t] left, ndarray[int64_t] right,
409
409
for k from kleft <= k < kleft + kright:
410
410
out[i, k] = NaN
411
411
412
+ @ cython.wraparound (False )
413
+ @ cython.boundscheck (False )
414
+ def left_join_1d (ndarray[int64_t] left , ndarray[int64_t] right ,
415
+ ndarray[float64_t] lvalues ,
416
+ ndarray[float64_t] rvalues ,
417
+ ndarray[float64_t , ndim = 2 ] out):
418
+ cdef:
419
+ Py_ssize_t i, j, nright, nleft
420
+ int64_t val
421
+
422
+ nleft = len (lvalues)
423
+ nright = len (rvalues)
424
+
425
+ j = 0
426
+ for i from 0 <= i < nleft:
427
+ out[i, 0 ] = lvalues[i]
428
+
429
+ val = left[i]
430
+
431
+ while j < nright and right[j] < val:
432
+ j += 1
433
+
434
+ if j == nright:
435
+ out[i, 1 ] = NaN
436
+ continue
437
+
438
+ if val == right[j]:
439
+ out[i, 1 ] = rvalues[j]
440
+ else :
441
+ out[i, 1 ] = NaN
442
+
412
443
@ cython.wraparound (False )
413
444
@ cython.boundscheck (False )
414
445
def inner_join_indexer (ndarray[int64_t] left , ndarray[int64_t] right ):
@@ -528,6 +559,83 @@ def outer_join_indexer(ndarray[int64_t] left, ndarray[int64_t] right):
528
559
lindexer[:count].copy(),
529
560
rindexer[:count].copy())
530
561
562
+ # @cython.wraparound(False)
563
+ # @cython.boundscheck(False)
564
+ def take_axis0 (ndarray[float64_t , ndim = 2 ] values,
565
+ ndarray[int32_t] indexer ,
566
+ out = None ):
567
+ cdef:
568
+ Py_ssize_t i, j, k, n, idx
569
+ ndarray[float64_t, ndim= 2 ] outbuf
570
+
571
+ n = len (indexer)
572
+ k = values.shape[1 ]
573
+
574
+ if out is None :
575
+ outbuf = np.empty((n, k), dtype = values.dtype)
576
+ else :
577
+ outbuf = out
578
+
579
+ for i from 0 <= i < n:
580
+ idx = indexer[i]
581
+
582
+ if idx == - 1 :
583
+ for j from 0 <= j < k:
584
+ outbuf[i, j] = NaN
585
+ else :
586
+ for j from 0 <= j < k:
587
+ outbuf[i, j] = values[idx, j]
588
+
589
+
590
+ @ cython.wraparound (False )
591
+ @ cython.boundscheck (False )
592
+ def take_axis1 (ndarray[float64_t , ndim = 2 ] values,
593
+ ndarray[int32_t] indexer ,
594
+ out = None ):
595
+ cdef:
596
+ Py_ssize_t i, j, k, n, idx
597
+ ndarray[float64_t, ndim= 2 ] outbuf
598
+
599
+ n = len (indexer)
600
+ k = values.shape[1 ]
601
+
602
+ if out is None :
603
+ outbuf = np.empty((n, k), dtype = values.dtype)
604
+ else :
605
+ outbuf = out
606
+
607
+ for j from 0 <= j < k:
608
+ idx = indexer[j]
609
+
610
+ if idx == - 1 :
611
+ for i from 0 <= i < n:
612
+ outbuf[i, j] = NaN
613
+ else :
614
+ for i from 0 <= i < n:
615
+ outbuf[i, j] = values[i, idx]
616
+
617
+ @ cython.wraparound (False )
618
+ @ cython.boundscheck (False )
619
+ def take_1d (ndarray[float64_t] values , ndarray[int32_t] indexer ,
620
+ out = None ):
621
+ cdef:
622
+ Py_ssize_t i, n, idx
623
+ ndarray[float64_t] outbuf
624
+
625
+ n = len (indexer)
626
+
627
+ if out is None :
628
+ outbuf = np.empty(n, dtype = values.dtype)
629
+ else :
630
+ outbuf = out
631
+
632
+ for i from 0 <= i < n:
633
+ idx = indexer[i]
634
+ if idx == - 1 :
635
+ outbuf[i] = NaN
636
+ else :
637
+ outbuf[i] = values[idx]
638
+
531
639
def ordered_put_indexer (ndarray[int64_t] left , ndarray[int64_t] right ,
532
640
ndarray[float64_t , ndim = 2 ] lvalues,
533
641
ndarray[float64_t , ndim = 2 ] rvalues,
0 commit comments