Skip to content

Commit 0d4962e

Browse files
authored
Added back prob and logprob macros (#609)
* added back prob and logprob macros * added refernece to issue discussing removal * added tests so we remeber they're there * export for compat and make errors runtime rather than parsetime * Update src/DynamicPPL.jl
1 parent 278a82a commit 0d4962e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/DynamicPPL.jl

+17-1
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,28 @@ export AbstractVarInfo,
129129
@submodel,
130130
value_iterator_from_chain,
131131
check_model,
132-
check_model_and_trace
132+
check_model_and_trace,
133+
# Deprecated.
134+
@logprob_str,
135+
@prob_str
133136

134137
# Reexport
135138
using Distributions: loglikelihood
136139
export loglikelihood
137140

141+
# TODO: Remove once we feel comfortable people aren't using it anymore.
142+
macro logprob_str(str)
143+
return :(error(
144+
"The `@logprob_str` macro is no longer supported. See https://turinglang.org/dev/docs/using-turing/guide/#querying-probabilities-from-model-or-chain for information on how to query probabilities, and https://github.com/TuringLang/DynamicPPL.jl/issues/356 for information regarding its removal.",
145+
))
146+
end
147+
148+
macro prob_str(str)
149+
return :(error(
150+
"The `@prob_str` macro is no longer supported. See https://turinglang.org/dev/docs/using-turing/guide/#querying-probabilities-from-model-or-chain for information on how to query probabilities, and https://github.com/TuringLang/DynamicPPL.jl/issues/356 for information regarding its removal.",
151+
))
152+
end
153+
138154
# Used here and overloaded in Turing
139155
function getspace end
140156

test/runtests.jl

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ include("test_util.jl")
7171
include("ad.jl")
7272
end
7373

74+
@testset "prob and logprob macro" begin
75+
@test_throws ErrorException prob"..."
76+
@test_throws ErrorException logprob"..."
77+
end
78+
7479
@testset "doctests" begin
7580
DocMeta.setdocmeta!(
7681
DynamicPPL,

0 commit comments

Comments
 (0)