You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
insert_fixed_sorted_perm!(perm, res, i, x[i], (y1, y2) ->TOPK_ISLESS(y1, y2))
511
+
insert_fixed_sorted_perm!(perm, res, i, x[i], (y1, y2) ->isless(y1, y2))
481
512
cnt +=1
482
513
end
483
514
end
484
515
if cnt < k
485
-
res[1:cnt], perm[1:cnt]
516
+
allowmissing(perm[1:cnt])
486
517
else
487
-
res, perm
518
+
allowmissing(perm)
488
519
end
489
520
end
490
521
491
522
492
523
"""
493
-
topk(x, k; rev = false, output_indices = false)
524
+
topk(x, k; rev = false)
494
525
495
526
Return upto `k` largest nonmissing elements of `x`. When `rev = true` it returns upto `k` smallest nonmissing elements of `x`. When all elements are missing, the function returns `[missing]`.
496
527
497
-
If `output_indices = true`, the function returns the values and their indices.
498
-
499
528
> The `topk` function uses `isless` for comparing values
@assertfirstindex(x) ==1"topk only supports 1-based indexing"
503
534
if rev
504
-
if output_indices
505
-
k_smallest_perm(x, k)
506
-
else
507
-
k_smallest(x, k)
508
-
end
535
+
k_smallest(x, k)
509
536
else
510
-
if output_indices
511
-
k_largest_perm(x, k)
512
-
else
513
-
k_largest(x, k)
514
-
end
537
+
k_largest(x, k)
538
+
end
539
+
end
540
+
"""
541
+
topkperm(x, k; rev = false)
542
+
543
+
Return the indices of upto `k` largest nonmissing elements of `x`. When `rev = true` it returns the indices of upto `k` smallest nonmissing elements of `x`. When all elements are missing, the function returns `[missing]`.
544
+
545
+
> The `topkperm` function uses `isless` for comparing values
0 commit comments