Skip to content

Commit a7fff46

Browse files
committed
fix bounds error when upper range is too small
1 parent f94d1d1 commit a7fff46

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/bivariate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function tabulate(data::(RealVector, RealVector), midpoints::(Range, Range))
3535
for (x, y) in zip(xdata,ydata)
3636
kx, ky = searchsortedfirst(xmid,x), searchsortedfirst(ymid,y)
3737
jx, jy = kx-1, ky-1
38-
if 1 <= jx <= nx && 1 <= jy <= ny
38+
if 1 <= jx <= nx-1 && 1 <= jy <= ny-1
3939
grid[jx,jy] += (xmid[kx]-x)*(ymid[ky]-y)*ainc
4040
grid[kx,jy] += (x-xmid[jx])*(ymid[ky]-y)*ainc
4141
grid[jx,ky] += (xmid[kx]-x)*(y-ymid[jy])*ainc

src/univariate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function tabulate(data::RealVector, midpoints::Range)
8080
for x in data
8181
k = searchsortedfirst(midpoints,x)
8282
j = k-1
83-
if 1 <= j <= npoints
83+
if 1 <= j <= npoints-1
8484
grid[j] += (midpoints[k]-x)*ainc
8585
grid[k] += (x-midpoints[j])*ainc
8686
end

0 commit comments

Comments
 (0)