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

Update juliacall_unfold.jl #206

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions docs/literate/HowTo/juliacall_unfold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@

# ## Example: Unfold model fitting from Python
# In this [notebook](https://github.com/unfoldtoolbox/Unfold.jl/blob/main/docs/src/HowTo/juliacall_unfold.ipynb), you can find a more detailed example of how to use Unfold from Python to load data, fit an Unfold model and visualise the results in Python.

# ## Important limitations
# Python doesnt not offer the full expressions that are available in Julia. So there are some things you need to give special attention:
#
# `@formula` - we havent found a way to call macros yet, even though we think it should be possible. For now please use `f = jl.seval("@formula(0~1+my+cool+design)")`. Later versions might support something like f = `@formula("0~1+my+cool+design)"` directly
#
# specifying the design: Since Unfold 0.7 we officially switched to the `["eventtypeA"=>(formula,basisfunction),"eventtypeB"=>(otherformula,otherbasisfunction)]` syntax from a Dict-based syntax. Unfortunately, `=>` (a pair) is not supported in Python and one needs to do some rewriting:
# `jl.convert(jl.Pair,(formula,basisfunction))` which makes the code less readable. We are thinking of ways to remedy this - but right now there is now way around. For now, it is also possible to use the old syntax {"eventtypeA"=>(formula,basisfunction),"eventtypeB"=>(otherformula,otherbasisfunction)} which is clearly easier to read :)
#
# `UnfoldSim.design` special case in UnfoldSim design, we need a `Dict` with a `Symbol` , one has to do something like `condition_dict_jl = {convert(jl.Symbol,"condA"):["car", "face"]}` to do so. We will try to allow strings here as well, removing this constraint.
Loading