Skip to content
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

Add getparameters and setparameters!! #86

Merged
merged 24 commits into from
Oct 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e2bdfb7
added state_from_transition, parameters and setparameters!!
torfjelde Oct 21, 2021
7fa8de0
Update src/AbstractMCMC.jl
torfjelde Oct 23, 2021
0a4fd17
renamed state_from_transition to updatestate!!
torfjelde Nov 17, 2021
28bdf91
adhere to julia convention
torfjelde Nov 17, 2021
86a7826
added docs
torfjelde Nov 17, 2021
e19cea7
fixed docs
torfjelde Nov 17, 2021
d86499f
fixed docs
torfjelde Nov 17, 2021
bce436d
added example for why updatestate!! is useful
torfjelde Nov 17, 2021
21f4d56
improved MixtureState example
torfjelde Nov 17, 2021
de0e5b2
further improvements to docs
torfjelde Nov 17, 2021
23b9119
renamed parameters and setparameters!! to values and setvalues!!
torfjelde Nov 19, 2021
b9f476c
fixed typo in docs
torfjelde Nov 19, 2021
f7b6096
fixed documenting values
torfjelde Nov 19, 2021
4ca57b0
improved and fixed some bugs in docs
torfjelde Nov 19, 2021
abebd59
fixed typo in docs
torfjelde Nov 19, 2021
d1d4642
renamed values and setvalues!! to realize and realize!!
torfjelde Dec 7, 2021
c6c9554
added model to updatestate!!
torfjelde Dec 7, 2021
d9f8585
Merge branch 'master' into tor/state-transition-related
torfjelde Oct 24, 2023
600d36c
Apply suggestions from code review
torfjelde Oct 10, 2024
1bfbef1
Update docs/src/api.md
torfjelde Oct 10, 2024
d9480d1
Apply suggestions from code review
torfjelde Oct 10, 2024
3f861bf
Merge branch 'master' into tor/state-transition-related
torfjelde Oct 10, 2024
ddb588c
Update docs/src/api.md
torfjelde Oct 10, 2024
d6ab10a
version bump
sunxd3 Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/AbstractMCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@ The `MCMCSerial` algorithm allows users to sample serially, with no thread or pr
"""
struct MCMCSerial <: AbstractMCMCEnsemble end

"""
state_from_transiton(state, transition_prev[, state_prev])
Copy link
Member

Choose a reason for hiding this comment

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

This one seems a bit confusing - so one already needs a state to return it? Based on the name I would have assumed a function signature state_from_transition(transition) -> state.

Copy link
Member

Choose a reason for hiding this comment

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

Well if you already have the state, wouldn't it just be an identity call? i.e.

state_from_transition(state, a, b) = state

You could just dispatch to a different state type. For example, state=nothing would try to reconstruct the state from the transitions. Maybe? Not sure. Perhaps I am just playing devils advocate here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, maybe update_from_transition!!(state, transition_prev, state_prev) is more descriptive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yo, whadda yah guys think?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry, my bad. Yeah your proposed name change is clearer, let's do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Or maybe just update!!? Given that we might also want to pass in state_prev?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, since we don't want to export any of these functions anyway I'm fine with update!!. Is a bit nicer than update_from_transition!! IMO, and as you say we might not only update based on the transition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, I'll make that change then 👍


Return new instance of `state` using information from `transition_prev` and, optionally, `state_prev`.

Defaults to `setparameters!!(state, parameters(transition_prev))`.
"""
function state_from_transition(state, transition_prev, state_prev)
return state_from_transition(state, transition_prev)
end

function state_from_transition(state, transition)
return setparameters!!(state, parameters(transition))
end

"""
setparameters!!(state, parameters)

Return new instance of `state` with parameters set to `parameters`.
torfjelde marked this conversation as resolved.
Show resolved Hide resolved
"""
setparameters!!

"""
parameters(transition)

Return parameters in `transition`.
"""
parameters


torfjelde marked this conversation as resolved.
Show resolved Hide resolved
include("samplingstats.jl")
include("logging.jl")
include("interface.jl")
Expand Down