Skip to content

Commit 6144899

Browse files
oschulzdevmotion
andcommitted
Turn NoLogAbsDetJacobian into a singleton
Co-authored-by: David Widmann <[email protected]>
1 parent b906235 commit 6144899

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/with_ladj.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For `(y, ladj) = with_logabsdet_jacobian(f, x)`, the following must hold true:
1515
(via `Base.Fix1`) and (Julia >=v1.6 only) `ComposedFunction`.
1616
1717
If no volume element is defined/applicable, `with_logabsdet_jacobian(f::F, x::T)`
18-
returns [`NoLogAbsDetJacobian{F,T}(f)`](@ref).
18+
returns [`NoLogAbsDetJacobian{F,T}()`](@ref).
1919
2020
# Examples
2121
@@ -75,15 +75,12 @@ export with_logabsdet_jacobian
7575
"""
7676
struct NoLogAbsDetJacobian{F,T}
7777
78-
An instance `NoLogAbsDetJacobian{F,T}(f)` signifies that
79-
`with_logabsdet_jacobian(f, ::T)` is not defined.
78+
An instance `NoLogAbsDetJacobian{F,T}()` signifies that `with_logabsdet_jacobian(::F, ::T)` is not defined.
8079
"""
81-
struct NoLogAbsDetJacobian{F,T}
82-
f::F
83-
end
80+
struct NoLogAbsDetJacobian{F,T} end
8481
export NoLogAbsDetJacobian
8582

86-
with_logabsdet_jacobian(f::F, ::T) where {F,T} = NoLogAbsDetJacobian{F,T}(f, )
83+
with_logabsdet_jacobian(::F, ::T) where {F,T} = NoLogAbsDetJacobian{F,T}()
8784

8885

8986

test/test_with_ladj.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include("getjacobian.jl")
1313

1414

1515
@testset "with_logabsdet_jacobian" begin
16-
@test with_logabsdet_jacobian(sum, rand(5)) == NoLogAbsDetJacobian{typeof(sum),Vector{Float64}}(sum)
16+
@test with_logabsdet_jacobian(sum, rand(5)) == NoLogAbsDetJacobian{typeof(sum),Vector{Float64}}()
1717
@test_throws MethodError _, _ = with_logabsdet_jacobian(sum, rand(5))
1818

1919
function ChangesOfVariables.with_logabsdet_jacobian(::typeof(foo), x)

0 commit comments

Comments
 (0)