-
Notifications
You must be signed in to change notification settings - Fork 31
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
Depreciate@submodel l ~ m
in favour of l ~ to_submodel(m)
; rename generated_quantities
to returned
#696
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #696 +/- ##
==========================================
+ Coverage 86.38% 86.48% +0.09%
==========================================
Files 35 35
Lines 4180 4209 +29
==========================================
+ Hits 3611 3640 +29
Misses 569 569 ☔ View full report in Codecov by Sentry. |
Pull Request Test Coverage Report for Build 12144617184Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Co-authored-by: Xianda Sun <[email protected]>
@torfjelde I suggest we change the prefix feature to a # submodel prefixing
julia> @model function demo2(x, y, z)
a = @returned_quantities prefix_variables(demo1(x), "sub1")
b = @returned_quantities prefix_variables(demo1(y), "sub2")
return z ~ Uniform(-a, b)
end;
julia> rand(demo2(missing, missing, 0.4))
(var"sub1.x" = 0.5865756059371534, var"sub2.x" = -0.25563799658500047)
# rand prefixing
julia> ret = rand(prefix_variables(demo1(1.), "prior_sample"))
# generated quantities / predict
julia> returned_quantities(prefix_variables(demo1(1.), "generated_var_"), chain)
This would also help unify the syntax of This could be further unified with |
We already have prefix(model::Model, x) = contextualize(model, PrefixContext(model.context, Symbol(x))) or something as an additional definition. However, I'm a bit worred about
|
I like the
Point taken, but this is very minor and a bit subjective. |
But this means that the user needs to be careful and do |
It is a standard Julia performance trick, so it is okay. By default, we can print a performance warning message when users call |
I'm also happy to turn @returned_quantities @prefix(model, :prefix_) |
make things easier to basic users
before wrapping in `Val`
contexts in `model.context`
Added a |
…cro' into torfjelde/returned-quantities-macro
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thanks, @torfjelde; I'm happy with the changes. To minimise interface confusion ( Thoughts? @mhauru and @penelopeysm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For prefix
/@prefix
, maybe keep both but only export the macro? It sounds like unless you know what you are doing, you should use @prefix
. And if you know what you're doing, you don't need it be exported. I do generally think it's a good idea to have a macro-free option available if possible.
For returned_quantities
/@returned_quantities
we still need both, because one is to be used outside of @model
, the other inside, right? I forget what we concluded about this in our call, but I do worry users will mix the two up and get confusing errors.
src/submodel_macro.jl
Outdated
true | ||
|
||
julia> # Or using some arbitrary expression. | ||
@model submodel_prefix_expr() = a = @returned_quantities prefix=1 + 2 inner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found
@returned_quantities prefix=1 + 2 inner()
hard and unintuitive to parse. I think
@returned_quantities prefix=(1 + 2) inner()
would be much clearer. Not sure if this a documentation issue, or if we should disallow the former.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a documentation issue IMO, as this is not doing any special parsing but reliying on Julia's expression parsing.
Then, |
Just so we're all on the same page: |
Deprecated |
…cro' into torfjelde/returned-quantities-macro
Final question @yebai , in which struct do you want the EDIT: I put it in |
That looks good to me. |
Hmm, thought this would be a simple thing to fix (it's just a depwarn happening that I didn't expect to happen). Think there's something funky going on with Documenter.jl... |
don't understand why this is needed for Documenter.jl)
@returned_quantities
macro@submodel l ~ m
in favour of l ~ to_submodel(m)
; rename generated_quantities
to returned
This is now ready to go I think:) Anyone wants a final lookover or just hit the green button? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy, just had one question about a docstring. Merge when you consider it ready. Thanks @torfjelde for doing all the heavy lifting here!
…cro' into torfjelde/returned-quantities-macro
Seems like we're hitting OOM failures unrelated to this PR again 😕 |
I merged it manually. This PR has some very nice improvements—many thanks to @torfjelde, @mhauru, and all who helped. |
This adds the
@returned_quantities
macro as discussed @yebai @mhauruThis is meant to be a replacement for
@submodel
macro, but without the ability to do automatic prefixing. It ends up looking likeLikely TODOs:
@submodel
telling the user to use@returned_quantities
.generated_quantities
toreturned_quantities
in this PR?Fix #691