Skip to content

Commit

Permalink
Added back prob and logprob macros (#609)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
torfjelde authored May 17, 2024
1 parent 278a82a commit 0d4962e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,28 @@ export AbstractVarInfo,
@submodel,
value_iterator_from_chain,
check_model,
check_model_and_trace
check_model_and_trace,
# Deprecated.
@logprob_str,
@prob_str

# Reexport
using Distributions: loglikelihood
export loglikelihood

# TODO: Remove once we feel comfortable people aren't using it anymore.
macro logprob_str(str)
return :(error(
"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.",
))
end

macro prob_str(str)
return :(error(
"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.",
))
end

# Used here and overloaded in Turing
function getspace end

Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ include("test_util.jl")
include("ad.jl")
end

@testset "prob and logprob macro" begin
@test_throws ErrorException prob"..."
@test_throws ErrorException logprob"..."
end

@testset "doctests" begin
DocMeta.setdocmeta!(
DynamicPPL,
Expand Down

2 comments on commit 0d4962e

@torfjelde
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/107057

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.27.1 -m "<description of version>" 0d4962ef83e9ef885d13ee167c0ffa6edb5777ad
git push origin v0.27.1

Please sign in to comment.