Skip to content

Commit 392bbc0

Browse files
phipsgableryebai
andcommitted
Concretize IndexLens using to_indices (#43)
Should implement #35. The "problem" with this is that the resulting values are not exactly what you'd write by hand: ```julia julia> AbstractPPL.concretize(@varname(x.a[1:end, end][:]), x) x.a[1:2,2][Base.Slice(Base.OneTo(2))] ``` That wouldn't be so much of a problem besides printing, but unfortunately, lenses currenctly compare equality using strict types: ```julia julia> AbstractPPL.concretize(@varname(x[1:3, :]), rand(10, 10)).lens.indices == @varname(x[1:3, 1:10]).lens.indices true julia> AbstractPPL.concretize(@varname(x[1:3, :]), rand(10, 10)).lens == @varname(x[1:3, 1:10]).lens false julia> AbstractPPL.concretize(@varname(x[1:3, :]), rand(10, 10)) == @varname(x[1:3, 1:10]) false ``` Cf. jw3126/Setfield.jl#165; the equality comparison can hopefully be fixed there. The remaining thing is that subsumption must still be able to work with `Colon`, since a user might index a trace/VarInfo using a non-concretized varname containing a colon. But at least we can then be sure that one side is always concrete. Co-authored-by: Hong Ge <[email protected]> Co-authored-by: Hong Ge <[email protected]>
1 parent 1fbd526 commit 392bbc0

File tree

7 files changed

+244
-73
lines changed

7 files changed

+244
-73
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
33
keywords = ["probablistic programming"]
44
license = "MIT"
55
desc = "Common interfaces for probabilistic programming"
6-
version = "0.5.3"
6+
version = "0.6"
77

88
[deps]
99
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
@@ -15,5 +15,5 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1515
[compat]
1616
AbstractMCMC = "2, 3, 4"
1717
DensityInterface = "0.4"
18-
Setfield = "0.7.1, 0.8"
18+
Setfield = "0.8.1"
1919
julia = "~1.6.6, 1.7.3"

bors.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ required_approvals = 1
1515
use_squash_merge = true
1616
# Uncomment this to use a two hour timeout.
1717
# The default is one hour.
18-
timeout_sec = 7200
18+
timeout_sec = 7200

src/AbstractPPL.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
module AbstractPPL
22

33
# VarName
4-
export VarName, getsym, getlens, inspace, subsumes, varname, vsym, @varname, @vsym
4+
export VarName,
5+
getsym,
6+
getlens,
7+
inspace,
8+
subsumes,
9+
subsumedby,
10+
varname,
11+
vsym,
12+
@varname,
13+
@vsym
514

615

716
# Abstract model functions

0 commit comments

Comments
 (0)