Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
54b3435
Begin VarName rework
penelopeysm Dec 23, 2025
1957e5d
finish optic.jl and varname.jl
penelopeysm Dec 23, 2025
b4aee1c
fix optic composition
penelopeysm Dec 23, 2025
9a8a236
use view
penelopeysm Dec 23, 2025
41430d3
Add some tsts
penelopeysm Dec 23, 2025
f0ac406
fix some stuff
penelopeysm Dec 23, 2025
e7dd774
fix x[1: :]
penelopeysm Dec 23, 2025
bb93f3d
Fix dynamic indices fully
penelopeysm Dec 23, 2025
5e9401a
changelog
penelopeysm Dec 23, 2025
6d73a5a
Docs
penelopeysm Dec 23, 2025
ed3ba78
Add a bunch of tests
penelopeysm Dec 23, 2025
07a7e53
Fix more bugs, add more tests
penelopeysm Dec 23, 2025
8464ea2
more tests
penelopeysm Dec 23, 2025
5aa3997
tests
penelopeysm Dec 23, 2025
8826e60
fix DynamicIndex comparisons
penelopeysm Dec 23, 2025
0fe06bb
typo
penelopeysm Dec 23, 2025
e9b1f98
implement get and set
penelopeysm Dec 23, 2025
ea89272
Handle keyword arguments to getindex
penelopeysm Dec 23, 2025
6a72e8b
Changelog
penelopeysm Dec 23, 2025
04231f0
make a start on subsumption
penelopeysm Dec 23, 2025
6bccab0
allow string/symbol indices and stuff like that
penelopeysm Dec 23, 2025
0bbaf31
subsumes works
penelopeysm Dec 23, 2025
c103602
use views where possible, add more tests
penelopeysm Dec 23, 2025
8555095
docs
penelopeysm Dec 23, 2025
b2b23b9
prefixing works
penelopeysm Dec 24, 2025
1ab00dd
hasvalue works
penelopeysm Dec 24, 2025
7efa65d
comment
penelopeysm Dec 24, 2025
57d50dc
leaves works
penelopeysm Dec 24, 2025
9bc9f3d
bump min version to 1.10.8 for extension stuff
penelopeysm Dec 24, 2025
839eaa1
docs
penelopeysm Dec 24, 2025
f31e37d
don't view
penelopeysm Dec 24, 2025
c759a2e
workaround undef
penelopeysm Dec 24, 2025
c4a2a15
add a comment
penelopeysm Dec 24, 2025
43c969a
export canview
penelopeysm Dec 24, 2025
ecb6590
export the macro AST function too
penelopeysm Dec 24, 2025
add9d34
improve tuple tupling tupled
penelopeysm Dec 24, 2025
58636a8
there are two hard things in computer science
penelopeysm Dec 24, 2025
2eb7e7f
interpolate
penelopeysm Dec 24, 2025
7083a69
interpolate
penelopeysm Dec 24, 2025
ac95c23
fix name
penelopeysm Dec 24, 2025
456c322
more interpolation
penelopeysm Dec 24, 2025
63b04b9
fix name
penelopeysm Dec 24, 2025
e9eab0a
so dirty ugh
penelopeysm Dec 24, 2025
4ef515e
try to fix tuple equality
penelopeysm Dec 24, 2025
e11e23e
workaround for base Julia issue
penelopeysm Dec 24, 2025
5a28760
add `with_mutation`
penelopeysm Dec 24, 2025
0317af7
fix undef vectors
penelopeysm Dec 24, 2025
38cbf74
Fix some docs typos
penelopeysm Dec 24, 2025
3b0c376
Add more tests for mutating optics
penelopeysm Dec 24, 2025
7ee1d04
serialization works
penelopeysm Dec 24, 2025
84b3865
Add more tests
penelopeysm Dec 24, 2025
95a69e1
Docs
penelopeysm Dec 24, 2025
0282e15
reenable Aqua tests
penelopeysm Dec 24, 2025
9733bfe
fix ambiguities
penelopeysm Dec 24, 2025
e5277af
Add more tests for coverage
penelopeysm Dec 24, 2025
a2a7c1f
Add a test for undef
penelopeysm Dec 24, 2025
b77ed52
Add JET tests to prevent regressions on base Julia thingy
penelopeysm Dec 24, 2025
15c6968
Add more tests to satisfy the coverage demon
penelopeysm Dec 24, 2025
bc36cdc
Fix canview for DimArray
penelopeysm Dec 24, 2025
2571d7d
even. more. tests.
penelopeysm Dec 24, 2025
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
53 changes: 53 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
## 0.14.0

This release overhauls the `VarName` type.
Much of the external API for traversing and manipulating `VarName`s (once they have been constructed) has been preserved, but if you use the `VarName` type directly, there are significant changes.

**Internal representation**

The `optic` field of VarName now uses our hand-rolled optic types, which are subtypes of `AbstractPPL.AbstractOptic`.
Previously these were optics from Accessors.jl.

This change was made for two reasons: firstly, it is easier to provide custom behaviour for VarNames as we avoid running into possible type piracy issues, and secondly, the linked-list data structure used in `AbstractOptic` is easier to work with than Accessors.jl, which used `Base.ComposedFunction` to represent optic compositions and required a lot of care to avoid a litany of issues with associativity and identity optics (see e.g. https://github.com/JuliaLang/julia/pull/54877).

To construct an optic, the easiest way is to use the `@opticof` macro, which superficially behaves similarly to `Accessors.@optic` (for example, you can write `@opticof _[1].y.z`), but also supports automatic concretization by passing a second parameter (just like `@varname`).

**Concretization**

VarNames using 'dynamic' indices, i.e., `begin` and `end`, are now instantiated in a 'dynamic' form, meaning that these indices are unresolved.
These indices need to be resolved, or concretized, against the actual container.
For example, `@varname(x[end])` is dynamic, but when concretized against `x = randn(3)`, this becomes `@varname(x[3])`.
This can be done using `concretize(varname, x)`.

The idea of concretization is not new to AbstractPPL.
However, there are some differences:

- Colons are no longer concretized: they *always* remain as Colons, even after calling `concretize`.
- Previously, AbstractPPL would refuse to allow you to construct unconcretized versions of `begin` and `end`. This is no longer the case; you can now create such VarNames in their unconcretized forms.
This is useful, for example, when indexing into a chain that contains `x` as a variable-length vector. This change allows you to write `chain[@varname(x[end])]` without having AbstractPPL throw an error.

**Keyword arguments to `getindex`**

VarNames can now be constructed with keyword arguments in `Index` optics, for example `@varname(x[i=1])`.
This is specifically implemented to support DimensionalData.jl's DimArrays.

**Other interface functions**

The `vsym` function (and `@vsym`) has been removed; you should use `getsym(vn)` instead.

The `Base.get` and `Accessors.set` methods for VarNames have been removed (these were responsible for method ambiguities).
Instead of using these methods you can first convert the `VarName` to an optic using `varname_to_optic(vn)`, and then use the getter and setter methods on the optics.

VarNames cannot be composed with optics now (compose the optics yourself).

The `inspace` function has been removed.
It used to be relevant for Turing's old Gibbs sampler; but now it no longer serves any use.

`ConcretizedSlice` has been removed (since colons are no longer concretized).

The subsumption interface has been pared down to just a single function, `subsumes`.
All other functions, such as `subsumedby`, `uncomparable`, and the Unicode operators, have been removed.

Serialization still works exactly as before.
However, you will see differences in the serialization output compared to previous versions, due to the changes in the internal structure.

## 0.13.6

Fix a missing qualifier in AbstractPPLDistributionsExt.
Expand Down
12 changes: 8 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@ uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
keywords = ["probablistic programming"]
license = "MIT"
desc = "Common interfaces for probabilistic programming"
version = "0.13.6"
version = "0.14.0"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[weakdeps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

[extensions]
AbstractPPLDistributionsExt = ["Distributions"]
AbstractPPLDistributionsExt = ["Distributions", "LinearAlgebra"]

[compat]
AbstractMCMC = "2, 3, 4, 5"
Accessors = "0.1"
BangBang = "0.4"
DensityInterface = "0.4"
Distributions = "0.25"
JSON = "0.19 - 0.21, 1"
LinearAlgebra = "<0.0.1, 1.10"
LinearAlgebra = "<0.0.1, 1"
MacroTools = "0.5"
Random = "1.6"
StatsBase = "0.32, 0.33, 0.34"
julia = "1.10"
julia = "1.10.8"
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ AbstractPPL = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[sources]
AbstractPPL = {path = "../"}
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DocMeta.setdocmeta!(AbstractPPL, :DocTestSetup, :(using AbstractPPL); recursive=
makedocs(;
sitename="AbstractPPL",
modules=[AbstractPPL, Base.get_extension(AbstractPPL, :AbstractPPLDistributionsExt)],
pages=["index.md", "api.md", "interface.md"],
pages=["index.md", "varname.md", "pplapi.md", "interface.md"],
checkdocs=:exports,
doctest=false,
)
64 changes: 0 additions & 64 deletions docs/src/api.md

This file was deleted.

20 changes: 20 additions & 0 deletions docs/src/pplapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Probabilistic programming API

## Abstract model functions

```@docs
AbstractProbabilisticProgram
condition
decondition
fix
unfix
logdensityof
AbstractContext
evaluate!!
```

## Abstract traces

```@docs
AbstractModelTrace
```
Loading