Skip to content

Commit

Permalink
fix Sample when sampling only one element (fix #4134) (#4324)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyu1994 authored Jun 18, 2021
1 parent 4167649 commit 42ddff1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/LightGBM/utils/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Random {
ret.push_back(i);
}
}
} else if (K == 1) {
int v = NextInt(0, N);
ret.push_back(v);
} else {
std::set<int> sample_set;
for (int r = N - K; r < N; ++r) {
Expand Down

0 comments on commit 42ddff1

Please sign in to comment.