From 7cda0158c769dcd66016838e86fc3917675b0028 Mon Sep 17 00:00:00 2001 From: Matt Tancik Date: Wed, 13 Jul 2022 10:08:21 -0700 Subject: [PATCH] Fix out of bounds index bug --- pyrad/graphs/modules/ray_sampler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrad/graphs/modules/ray_sampler.py b/pyrad/graphs/modules/ray_sampler.py index 69f59a331..86e2c948b 100644 --- a/pyrad/graphs/modules/ray_sampler.py +++ b/pyrad/graphs/modules/ray_sampler.py @@ -317,8 +317,8 @@ class PDFSampler(Sampler): ) inds = torch.searchsorted(cdf, u, side="right") - below = torch.clamp(inds - 1, 0, num_bins - 1) - above = torch.clamp(inds, 0, num_bins - 1) + below = torch.clamp(inds - 1, 0, existing_bins.shape[-1] - 1) + above = torch.clamp(inds, 0, existing_bins.shape[-1] - 1) cdf_g0 = torch.gather(cdf, -1, below) bins_g0 = torch.gather(existing_bins, -1, below) cdf_g1 = torch.gather(cdf, -1, above)