TuringLang / TuringLang/DynamicPPL.jl

Drop `.~` syntax entirely

Open
#825 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

breaking-change modelling-syntax
Dominant language
Julia
Stars
286
Forks
41
Avg merge
1d 11h
Merged PRs (30d)
34

Description

The .~ syntax allows one to define parameters in a vectorised manner:

x = Vector(undef, 4) 
x .~ Distribution()

https://github.com/TuringLang/DynamicPPL.jl/pull/804 introduced extra constraints on the RHS: it has to be univariate distributions. This makes the need for the broadcasting syntax . questionable: it is much less flexible than Julia's broadcasting. So, using the broadcasting .~ might be confusing actually. I think we should further simplify vectorised tilde into

x = Vector(undef, 4) 
x ~ UnivariateDistribution()

This is semantically equivalent to x ~ filldist(UnivariateDistribution(), 4) but with a cleaner syntax. It also provides a clean syntax for supporting (univariate) identically-independently-distributed (IID) distributions discussed previously.

This proposal is also consistent with the Stan syntax for vectorised random variables.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PR #804 and locating the implementation and tests for the .~ syntax. Determine the affected handling of vectorised tilde expressions, then update the behavior so the proposed x ~ UnivariateDistribution() form replaces .~; done means the old syntax is removed and the new syntax is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.