TuringLang / TuringLang/AbstractPPL.jl

Ban `VarName`s with ranges or `Colon`s in the middle

Open
#149 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
28
Forks
12
PR merge metrics
No merged PRs in 30d

Description

These sorts of VarNames are non-sense, and I think the constructor should call them out and error:

julia> @varname(a.b[1:4].c)
a.b[1:4].c

What would this mean? It could mean get the elements a.b[1:4] and get the field .c for each of them. However, that's not what this does in Julia. Rather, in Julia, indexing like that tries to get the field .c of the object a.b[1:4], which is probably an Array that only has fields ref and size. I don't think that's ever the thing we want to do in a probabilistic programming language context. Hence I think VarNames should allow an IndexLens with ranges or Colons only as the last lens.

Note that this should of course still be fine: @varname(a.b[2].c)

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 at the VarName constructor and the @varname entry point, then trace how IndexLens values are represented. Review existing validation tests if present; done means ranges and Colons are rejected in the middle while a scalar index such as [2] remains valid there.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.