Skip to content

Commit

Permalink
Fix bin search error
Browse files Browse the repository at this point in the history
  • Loading branch information
Micki-D authored and oschulz committed Aug 23, 2024
1 parent 84cac09 commit edbf33f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/rqspline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function rqs_inverse(
k2 = one(typeof(k1))

# Is inside of range
isinside = (k1 < K) && (k1 > 0)
isinside = (1 <= k1 <= K)
k = Base.ifelse(isinside, k1, k2)

x_tmp = Base.ifelse(isinside, x, pX[k]) # Simplifies unnecessary calculations
Expand Down Expand Up @@ -352,7 +352,7 @@ end
k2 = one(typeof(k1))

# Is inside of range
isinside = (k1 < K) && (k1 > 0)
isinside = (1 <= k1 <= K)
k = Base.ifelse(isinside, k1, k2)

x_tmp = Base.ifelse(isinside, x[i,j], pX[k,i,j]) # Simplifies unnecessary calculations
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is a part of EuclidianNormalizingFlows.jl, licensed under the MIT License (MIT)
# This file is a part of MonotonicSplines.jl, licensed under the MIT License (MIT)


# Non-public:
Expand Down
3 changes: 1 addition & 2 deletions test/test_rqspline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ for compute_unit in compute_units
YM = fM(XM)
@test @inferred(broadcast(inv_f, Y)) == vec(@inferred(inv_fM(YM)))

# See issue #17:
@test_broken inv_f.(Y) X
@test inv_f.(Y) X

Y_ladj = @inferred(broadcast(with_logabsdet_jacobian, f, X))
YM_ladj = @inferred(with_logabsdet_jacobian(fM, XM))
Expand Down

0 comments on commit edbf33f

Please # to comment.