Skip to content

Commit b906235

Browse files
committed
Don't throw custom errors for ops on NoLogAbsDetJacobian
1 parent c30bc6f commit b906235

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/with_ladj.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ For `(y, ladj) = with_logabsdet_jacobian(f, x)`, the following must hold true:
1414
`with_logabsdet_jacobian` comes with support for broadcasted/mapped functions
1515
(via `Base.Fix1`) and (Julia >=v1.6 only) `ComposedFunction`.
1616
17-
If no volume element is defined/applicable, `with_logabsdet_jacobian(f, x)` returns
18-
[`NoLogAbsDetJacobian(f)`](@ref).
17+
If no volume element is defined/applicable, `with_logabsdet_jacobian(f::F, x::T)`
18+
returns [`NoLogAbsDetJacobian{F,T}(f)`](@ref).
1919
2020
# Examples
2121
@@ -83,15 +83,6 @@ struct NoLogAbsDetJacobian{F,T}
8383
end
8484
export NoLogAbsDetJacobian
8585

86-
function _no_ladj_errmsg(@nospecialize noladj::NoLogAbsDetJacobian{F,T}) where {F,T}
87-
("with_logabsdet_jacobian(", noladj.f, ", ::", T, " is not defined ")
88-
end
89-
90-
Base.getindex(@nospecialize(noladj::NoLogAbsDetJacobian), args...) = error(_no_ladj_errmsg(noladj)...)
91-
Base.iterate(@nospecialize(noladj::NoLogAbsDetJacobian)) = error(_no_ladj_errmsg(noladj)...)
92-
Base.firstindex(@nospecialize(noladj::NoLogAbsDetJacobian)) = error(_no_ladj_errmsg(noladj)...)
93-
Base.lastindex(@nospecialize(noladj::NoLogAbsDetJacobian)) = error(_no_ladj_errmsg(noladj)...)
94-
9586
with_logabsdet_jacobian(f::F, ::T) where {F,T} = NoLogAbsDetJacobian{F,T}(f, )
9687

9788

test/test_with_ladj.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ include("getjacobian.jl")
1414

1515
@testset "with_logabsdet_jacobian" begin
1616
@test with_logabsdet_jacobian(sum, rand(5)) == NoLogAbsDetJacobian{typeof(sum),Vector{Float64}}(sum)
17-
noladj = with_logabsdet_jacobian(sum, rand(5))
18-
@test_throws ErrorException noladj[1]
19-
@test_throws ErrorException noladj[2]
20-
@test_throws ErrorException firstindex(noladj)
21-
@test_throws ErrorException lastindex(noladj)
22-
@test_throws ErrorException first(noladj)
23-
@test_throws ErrorException last(noladj)
24-
@test_throws ErrorException _, _ = noladj
17+
@test_throws MethodError _, _ = with_logabsdet_jacobian(sum, rand(5))
2518

2619
function ChangesOfVariables.with_logabsdet_jacobian(::typeof(foo), x)
2720
y = foo(x)

0 commit comments

Comments
 (0)