Skip to content

Conversation

@torfjelde
Copy link
Member

This PR does the following:

  • Moves the varname_leaves from TestUtils to main module.
    • It can be very useful in Turing.jl for constructing Chains and the like, so I think it's a good idea to make it part of the main module rather than keeping it "hidden" there.
  • Makes the default varinfo in the constructor of LogDensityFunction be model.context rather than a new DynamicPPL.DefaultContext.
    • The context pass to evaluate!! will override the leaf-context in model.context, and so the current default constructor always uses DefaultContext as the leaf-context, even if the Model has been contextualized with some other leaf-context, e.g. PriorContext. This PR fixes this issue.

src/utils.jl Outdated
varname_leaves(vn::VarName, val)
Return iterator over all varnames that are represented by `vn` on `val`,
e.g. `varname_leaves(@varname(x), rand(2))` results in an iterator over `[@varname(x[1]), @varname(x[2])]`.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this example a doctest?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point 👍

model::Model,
varinfo::AbstractVarInfo=VarInfo(model),
context::AbstractContext=DefaultContext(),
context::AbstractContext=model.context,
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a test for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@torfjelde
Copy link
Member Author

bors r+

bors bot pushed a commit that referenced this pull request Jan 25, 2023
This PR does the following:
- Moves the `varname_leaves` from `TestUtils` to main module.
  - It can be very useful in Turing.jl for constructing `Chains` and the like, so I think it's a good idea to make it part of the main module rather than keeping it "hidden" there.
- Makes the default `varinfo` in the constructor of `LogDensityFunction` be `model.context` rather than a new `DynamicPPL.DefaultContext`.
  - The `context` pass to `evaluate!!` will override the leaf-context in `model.context`, and so the current default constructor always uses `DefaultContext` as the leaf-context, even if the `Model` has been `contextualize`d with some other leaf-context, e.g. `PriorContext`. This PR fixes this issue.
@bors
Copy link
Contributor

bors bot commented Jan 25, 2023

@bors bors bot changed the title Some minor utility improvements [Merged by Bors] - Some minor utility improvements Jan 25, 2023
@bors bors bot closed this Jan 25, 2023
@bors bors bot deleted the torfjelde/minor-improvements branch January 25, 2023 23:46
yebai added a commit that referenced this pull request Mar 2, 2023
…eep existing compat) (#469)

* Fixed a typo in tutorial (#451)

* CompatHelper: bump compat for Turing to 0.24 for package turing, (keep existing compat) (#450)

This pull request changes the compat entry for the `Turing` package from `0.21` to `0.21, 0.24` for package turing.
This keeps the compat entries for earlier versions.



Note: I have not tested your package with this new compat entry.
It is your responsibility to make sure that your package tests pass before you merge this pull request.

Co-authored-by: Hong Ge <[email protected]>

* Some minor utility improvements (#452)

This PR does the following:
- Moves the `varname_leaves` from `TestUtils` to main module.
  - It can be very useful in Turing.jl for constructing `Chains` and the like, so I think it's a good idea to make it part of the main module rather than keeping it "hidden" there.
- Makes the default `varinfo` in the constructor of `LogDensityFunction` be `model.context` rather than a new `DynamicPPL.DefaultContext`.
  - The `context` pass to `evaluate!!` will override the leaf-context in `model.context`, and so the current default constructor always uses `DefaultContext` as the leaf-context, even if the `Model` has been `contextualize`d with some other leaf-context, e.g. `PriorContext`. This PR fixes this issue.

* Always run CI  (#453)

I find the current `bors` workflow a bit tedious. Most of the time, I summon `bors` to see the CI results (see e.g. #438). Given that most `CI` tests are quick (< 10mins), we can always run them by default. 

The most time-consuming `IntegrationTests` is still run by `bors` to avoid excessive CI runs.

* Compat with new Bijectors.jl (#454)

This PR makes DPPL compatible with the changes to come in TuringLang/Bijectors.jl#214.

Tests are passing locally.

Closes #455 Closes #456

* Another Bijectors.jl compat bound bump (#457)

* CompatHelper: bump compat for MCMCChains to 6 for package test, (keep existing compat) (#467)

This pull request changes the compat entry for the `MCMCChains` package from `4.0.4, 5` to `4.0.4, 5, 6` for package test.
This keeps the compat entries for earlier versions.



Note: I have not tested your package with this new compat entry.
It is your responsibility to make sure that your package tests pass before you merge this pull request.

Co-authored-by: Hong Ge <[email protected]>

* CompatHelper: bump compat for AbstractPPL to 0.6 for package test, (keep existing compat)

---------

Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: github-actions[bot] <[email protected]>
Co-authored-by: Tor Erlend Fjelde <[email protected]>
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.

3 participants