Skip to content

Commit d6e2147

Browse files
authored
Default float type to float(Real), not Real (#685) (#686)
* 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 * Bump minimum Julia version to 1.10 * Bump patch version * Bump patch again
1 parent 09e997b commit d6e2147

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
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

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Requires = "1"
6565
ReverseDiff = "1"
6666
Test = "1.6"
6767
ZygoteRules = "0.2"
68-
julia = "~1.6.6, 1.7.3"
68+
julia = "1.10"
6969

7070
[extras]
7171
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

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)