Skip to content

Commit 7ed4d70

Browse files
committed
Default float type to float(Real), not Real (#685)
* Default float type to float(Real), not Real Closes #684 * Trigger CI on backport branches/PRs * Add integration test for #684 * Bump Turing version to 0.34 in test subfolder
1 parent 99def88 commit 7ed4d70

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- master
7+
- backport-*
78
pull_request:
89
branches:
910
- master
11+
- backport-*
1012
merge_group:
1113
types: [checks_requested]
1214

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,10 @@ end
941941
"""
942942
float_type_with_fallback(x)
943943
944-
Return type corresponding to `float(typeof(x))` if possible; otherwise return `Real`.
944+
Return type corresponding to `float(typeof(x))` if possible; otherwise return `float(Real)`.
945945
"""
946-
float_type_with_fallback(::Type) = Real
947-
float_type_with_fallback(::Type{Union{}}) = Real
946+
float_type_with_fallback(::Type) = float(Real)
947+
float_type_with_fallback(::Type{Union{}}) = float(Real)
948948
float_type_with_fallback(::Type{T}) where {T<:Real} = float(T)
949949

950950
"""

test/turing/varinfo.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,19 @@
342342
model = state_space(y, length(t))
343343
@test size(sample(model, NUTS(; adtype=AutoReverseDiff(true)), n), 1) == n
344344
end
345+
346+
if Threads.nthreads() > 1
347+
@testset "DynamicPPL#684: OrderedDict with multiple types when multithreaded" begin
348+
@model function f(x)
349+
ns ~ filldist(Normal(0, 2.0), 3)
350+
m ~ Uniform(0, 1)
351+
return x ~ Normal(m, 1)
352+
end
353+
model = f(1)
354+
chain = sample(model, NUTS(), MCMCThreads(), 10, 2)
355+
loglikelihood(model, chain)
356+
logprior(model, chain)
357+
logjoint(model, chain)
358+
end
359+
end
345360
end

0 commit comments

Comments
 (0)