Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProgressMeter Deprecation Warning and nothing comparison #536

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/POMDPTools/src/POMDPDistributions/sparse_cat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Base.iterate(d::SparseCat, dstate::Tuple)
vstate, pstate = dstate
vnext = iterate(d.vals, vstate)
pnext = iterate(d.probs, pstate)
if vnext == nothing || pnext == nothing
if vnext === nothing || pnext === nothing
return nothing
end
val, vstate_next = vnext
Expand Down
2 changes: 1 addition & 1 deletion lib/POMDPTools/src/Policies/utility_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function PolicyWrapper(policy::Policy; payload=nothing)
end

function action(p::PolicyWrapper, s)
if p.payload == nothing
if p.payload === nothing
return p.f(p.policy, s)
else
return p.f(p.policy, p.payload, s)
Expand Down
8 changes: 4 additions & 4 deletions lib/POMDPTools/src/Simulators/history_recorder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function simulate(sim::HistoryRecorder,
end

if sim.show_progress
if (sim.max_steps == nothing) && (sim.eps == nothing)
if (sim.max_steps === nothing) && (sim.eps === nothing)
error("If show_progress=true in a HistoryRecorder, you must also specify max_steps or eps.")
end
prog = Progress(max_steps, "Simulating..." )
prog = Progress(max_steps; desc="Simulating..." )
else
prog = nothing
end
Expand Down Expand Up @@ -147,10 +147,10 @@ function simulate(sim::HistoryRecorder,
max_steps)

if sim.show_progress
if (sim.max_steps == nothing) && (sim.eps == nothing)
if (sim.max_steps === nothing) && (sim.eps === nothing)
error("If show_progress=true in a HistoryRecorder, you must also specify max_steps or eps.")
end
prog = Progress(max_steps, "Simulating..." )
prog = Progress(max_steps; desc="Simulating..." )
else
prog = nothing
end
Expand Down
8 changes: 4 additions & 4 deletions lib/POMDPTools/src/Simulators/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Sim(pomdp::POMDP,
metadata = NamedTuple()
)

if initialstate == nothing && statetype(pomdp) != Nothing
if initialstate === nothing && statetype(pomdp) != Nothing
is = rand(rng, initial_belief)
else
is = initialstate
Expand All @@ -76,7 +76,7 @@ function Sim(mdp::MDP,
metadata = NamedTuple()
)

if initialstate == nothing && statetype(mdp) != Nothing
if initialstate === nothing && statetype(mdp) != Nothing
is = rand(rng, POMDPs.initialstate(mdp))
else
is = initialstate
Expand Down Expand Up @@ -119,7 +119,7 @@ end
will return a dataframe with with the number of steps and the reward in it.
"""
function run_parallel(process::Function, queue::AbstractVector, pool::AbstractWorkerPool=default_worker_pool();
progress=Progress(length(queue), desc="Simulating..."),
progress=Progress(length(queue); desc="Simulating..."),
proc_warn::Bool=true, show_progress::Bool=true)

if nworkers(pool) == 1 && proc_warn
Expand All @@ -133,7 +133,7 @@ function run_parallel(process::Function, queue::AbstractVector, pool::AbstractWo
end

if progress in (nothing, false)
progstr = (progress == nothing) ? "nothing" : "false"
progstr = (progress === nothing) ? "nothing" : "false"
@warn("run_parallel(..., progress=$progstr) is deprecated. Use run_parallel(..., show_progress=false) instead.")
show_progress = false
end
Expand Down
10 changes: 5 additions & 5 deletions lib/POMDPTools/test/simulators/test_history_recorder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ r2 = simulate(sim, problem, policy)
@test length(ainfo_hist(r2)) == steps
@test length(uinfo_hist(r2)) == steps

@test exception(r1) == nothing
@test exception(r2) == nothing
@test backtrace(r1) == nothing
@test backtrace(r2) == nothing
@test exception(r1) === nothing
@test exception(r2) === nothing
@test backtrace(r1) === nothing
@test backtrace(r2) === nothing

@test n_steps(r1) == n_steps(r2)
@test undiscounted_reward(r1) == undiscounted_reward(r2)
Expand All @@ -41,7 +41,7 @@ for tuple in r1
end

for ui in eachstep(r2, "update_info")
@test ui == nothing
@test ui === nothing
end

@test r1[1] == first(r1)
Expand Down