Skip to content

Commit

Permalink
fix a bug in ArgMaxAtK (#1196)
Browse files Browse the repository at this point in the history
* fix a bug in `ArgMaxAtK`
  • Loading branch information
guolinke committed Jan 12, 2018
1 parent 9e223c3 commit 3a665f6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/LightGBM/utils/array_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class ArrayArgs {
int l = start;
int r = end - 1;
Partition(arr, start, end, &l, &r);
if ((k > l && k < r) || l == 0 || r == end - 1) {
// if find or all elements are the same.
if ((k > l && k < r) || (l == start - 1 && r == end - 1)) {
return k;
} else if (k <= l) {
return ArgMaxAtK(arr, start, l + 1, k);
Expand Down

0 comments on commit 3a665f6

Please sign in to comment.