Skip to content

Commit

Permalink
Fix occasional test failure of TestWalkerAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
asi1024 committed Jan 23, 2019
1 parent 3b014b0 commit 2d75429
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chainer/utils/walker_alias.py
Expand Up @@ -104,12 +104,11 @@ def sample(self, shape):

def sample_xp(self, xp, shape):
thr_dtype = self.threshold.dtype
ps = xp.random.uniform(0, 1, shape).astype(thr_dtype)
pb = ps * len(self.threshold)
pb = xp.random.uniform(0, len(self.threshold), shape)
index = pb.astype(numpy.int32)
left_right = (
self.threshold[index]
< (pb - index.astype(thr_dtype)))
< (pb.astype(thr_dtype) - index.astype(thr_dtype)))
left_right = left_right.astype(numpy.int32)
return self.values[index * 2 + left_right]

Expand Down

0 comments on commit 2d75429

Please sign in to comment.