Skip to content

Commit

Permalink
Deepcopy model in LibtaskModel (#92)
Browse files Browse the repository at this point in the history
* Move things around

* Add test, fix comments

* Copy

* Update Project.toml

---------

Co-authored-by: Hong Ge <hg344@cam.ac.uk>
  • Loading branch information
FredericWantiez and yebai committed Nov 9, 2023
1 parent 955a562 commit 1e5dfdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AdvancedPS"
uuid = "576499cb-2369-40b2-a588-c64705576edc"
authors = ["TuringLang"]
version = "0.5.3"
version = "0.5.4"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
7 changes: 6 additions & 1 deletion ext/AdvancedPSLibtaskExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ function AdvancedPS.LibtaskModel(
)
end

"""
copy(model::AdvancedPS.LibtaskModel)
The task is copied (forked) and the inner model is deepcopied.
"""
function Base.copy(model::AdvancedPS.LibtaskModel)
return AdvancedPS.LibtaskModel(model.f, copy(model.ctask))
return AdvancedPS.LibtaskModel(deepcopy(model.f), copy(model.ctask))
end

const LibtaskTrace{R} = AdvancedPS.Trace{<:AdvancedPS.LibtaskModel,R}
Expand Down

2 comments on commit 1e5dfdd

@yebai
Copy link
Member

@yebai yebai commented on 1e5dfdd Nov 9, 2023

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/95072

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.5.4 -m "<description of version>" 1e5dfddc7330fecf1885a776ae2b13ab265fe710
git push origin v0.5.4

Please sign in to comment.