Skip to content

Conversation

@torfjelde
Copy link
Member

torfjelde and others added 2 commits January 14, 2023 16:36
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@torfjelde torfjelde requested a review from devmotion January 14, 2023 16:39
Return instance similar to `vi` but with `vns` set to values from `vals`.
"""
function update_values!!(vi::AbstractVarInfo, vals::NamedTuple, vns)
for vn in vns
Copy link
Member

Choose a reason for hiding this comment

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

Made me wonder if there are any advantages/disadvantages compared with a more functional approach using e.g. foldl. Feel free to ignore though, I'm just curious but don't think it matters for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Haha yeah when I moved this I was thinking "we should probably do this using recursion or a reduce but I'll leave it for now". I think at some point it might be worth including this in DPPL proper rather than in TestUtils, and then I think we should look into this 👍

"""
function test_values(vi::AbstractVarInfo, vals::NamedTuple, vns)
for vn in vns
@test vi[vn] == get(vals, vn)
Copy link
Member

Choose a reason for hiding this comment

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

Would it be useful to check approximate rquality as well? By allowing e.g. to specify a test function (with the default being ==)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good point! I'll make it a kwarg.

@torfjelde
Copy link
Member Author

Wanna have another look @devmotion ?

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Widmann <[email protected]>
@torfjelde
Copy link
Member Author

Good to go?

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

Looks good to me, feel free to merge once the minor remaining comments are resolved.

end

"""
DynamicPPL.TestUtils.setup_varinfos(model::Model, example_values::NamedTuple, varnames)
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason for why the modules are included in the signature here but in the docstrings above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoos, no that's just a misplaced replace! Will fix.

@torfjelde
Copy link
Member Author

bors r+

bors bot pushed a commit that referenced this pull request Jan 14, 2023
@bors
Copy link
Contributor

bors bot commented Jan 15, 2023

@bors bors bot changed the title Moved LogDensityFunction from Turing to DPPL [Merged by Bors] - Moved LogDensityFunction from Turing to DPPL Jan 15, 2023
@bors bors bot closed this Jan 15, 2023
@bors bors bot deleted the torfjelde/logdensityfunction branch January 15, 2023 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants