Skip to content

Commit e8e24f8

Browse files
authored
Rename turnprogress to setprogress! (#1427)
1 parent 7dd28e6 commit e8e24f8

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Turing"
22
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
3-
version = "0.14.6"
3+
version = "0.14.7"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

docs/src/using-turing/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ For more information on Turing's automatic differentiation backend, please see t
627627

628628
Turing.jl uses ProgressLogging.jl to log the progress of sampling. Progress
629629
logging is enabled as default but might slow down inference. It can be turned on
630-
or off by setting the keyword argument `progress` of `sample` to `true` or `false`, respectively. Moreover, you can enable or disable progress logging globally by calling `turnprogress(true)` or `turnprogress(false)`, respectively.
630+
or off by setting the keyword argument `progress` of `sample` to `true` or `false`, respectively. Moreover, you can enable or disable progress logging globally by calling `setprogress!(true)` or `setprogress!(false)`, respectively.
631631

632632
Turing uses heuristics to select an appropriate visualization backend. If you
633633
use [Juno](https://junolab.org/), the progress is displayed with a

src/Turing.jl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ import AdvancedVI
1919
import DynamicPPL: getspace, NoDist, NamedDist
2020

2121
const PROGRESS = Ref(true)
22-
function turnprogress(switch::Bool)
23-
@info "[Turing]: progress logging is $(switch ? "enabled" : "disabled") globally"
24-
PROGRESS[] = switch
25-
AdvancedVI.turnprogress(switch)
22+
23+
"""
24+
setprogress!(progress::Bool)
25+
26+
Enable progress logging in Turing if `progress` is `true`, and disable it otherwise.
27+
"""
28+
function setprogress!(progress::Bool)
29+
@info "[Turing]: progress logging is $(progress ? "enabled" : "disabled") globally"
30+
PROGRESS[] = progress
31+
AdvancedVI.turnprogress(progress)
32+
return progress
2633
end
2734

2835
# Random probability measures.
@@ -109,7 +116,7 @@ export @model, # modelling
109116
setadbackend,
110117
setadsafe,
111118

112-
turnprogress, # debugging
119+
setprogress!, # debugging
113120

114121
Flat,
115122
FlatPos,
@@ -126,4 +133,8 @@ export @model, # modelling
126133
genereated_quantities,
127134
logprior,
128135
logjoint
136+
137+
# deprecations
138+
include("deprecations.jl")
139+
129140
end

src/deprecations.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@deprecate turnprogress(progress::Bool) setprogress!(progress)

src/inference/Inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ and then converts these into a `Chains` object using `AbstractMCMC.bundle_sample
612612
613613
# Example
614614
```jldoctest
615-
julia> using Turing; Turing.turnprogress(false);
615+
julia> using Turing; setprogress!(false);
616616
[ Info: [Turing]: progress logging is disabled globally
617617
618618
julia> @model function linear_reg(x, y, σ = 0.1)

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
##########################################
22
# Master file for running all test cases #
33
##########################################
4-
using Zygote, ReverseDiff, Memoization, Turing; turnprogress(false)
4+
using Zygote, ReverseDiff, Memoization, Turing
55
using Pkg
66
using Random
77
using Test
88

9+
setprogress!(false)
10+
911
include("test_utils/AllUtils.jl")
1012

1113
# Begin testing.

0 commit comments

Comments
 (0)