Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style="blue"
33 changes: 33 additions & 0 deletions .github/workflows/Format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Format

on:
push:
branches:
# This is where pull requests from "bors r+" are built.
- staging
# This is where pull requests from "bors try" are built.
- trying
# Build the master branch.
- master
pull_request:

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: 1
- name: Format code
run: |
using Pkg
Pkg.add(; name="JuliaFormatter", uuid="98e50ef6-434e-11e9-1051-2b60c6c9e899")
using JuliaFormatter
format("."; verbose=true)
shell: julia --color=yes {0}
- uses: reviewdog/action-suggester@v1
if: github.event_name == 'pull_request'
with:
tool_name: JuliaFormatter
fail_on_error: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![IntegrationTest](https://github.com/TuringLang/DynamicPPL.jl/workflows/IntegrationTest/badge.svg?branch=master)](https://github.com/TuringLang/DynamicPPL.jl/actions?query=workflow%3AIntegrationTest+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/TuringLang/DynamicPPL.jl/badge.svg?branch=master)](https://coveralls.io/github/TuringLang/DynamicPPL.jl?branch=master)
[![Codecov](https://codecov.io/gh/TuringLang/DynamicPPL.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/TuringLang/DynamicPPL.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://colprac.sciml.ai/)
[![Bors enabled](https://bors.tech/images/badge_small.svg)](https://app.bors.tech/repositories/24589)

Expand Down
3 changes: 2 additions & 1 deletion bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ status = [
"test (1.%, windows-latest, x64, 2)",
"test (1, windows-latest, x64, 1)",
"test (1, windows-latest, x64, 2)",
"Turing.jl"
"Turing.jl",
"format"
]
delete_merged_branches = true
# Require at least on approval of a project member.
Expand Down
183 changes: 91 additions & 92 deletions src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,101 +5,101 @@ using AbstractPPL
using Distributions
using Bijectors

import AbstractMCMC
import ChainRulesCore
import NaturalSort
import MacroTools
import ZygoteRules
using AbstractMCMC: AbstractMCMC
using ChainRulesCore: ChainRulesCore
using NaturalSort: NaturalSort
using MacroTools: MacroTools
using ZygoteRules: ZygoteRules

import Random
using Random: Random

import Base: Symbol,
==,
hash,
getindex,
setindex!,
push!,
show,
isempty,
empty!,
getproperty,
setproperty!,
keys,
haskey
import Base:
Symbol,
==,
hash,
getindex,
setindex!,
push!,
show,
isempty,
empty!,
getproperty,
setproperty!,
keys,
haskey

# VarInfo
export AbstractVarInfo,
VarInfo,
UntypedVarInfo,
TypedVarInfo,
getlogp,
setlogp!,
acclogp!,
resetlogp!,
get_num_produce,
set_num_produce!,
reset_num_produce!,
increment_num_produce!,
set_retained_vns_del_by_spl!,
is_flagged,
set_flag!,
unset_flag!,
setgid!,
updategid!,
setorder!,
istrans,
link!,
invlink!,
tonamedtuple,
# VarName (reexport from AbstractPPL)
VarName,
inspace,
subsumes,
@varname,
# Compiler
@model,
# Utilities
vectorize,
reconstruct,
reconstruct!,
Sample,
init,
vectorize,
# Model
Model,
getmissings,
getargnames,
generated_quantities,
# Samplers
Sampler,
SampleFromPrior,
SampleFromUniform,
# Contexts
DefaultContext,
LikelihoodContext,
PriorContext,
MiniBatchContext,
PrefixContext,
assume,
dot_assume,
observer,
dot_observe,
tilde,
dot_tilde,
# Pseudo distributions
NamedDist,
NoDist,
# Prob macros
@prob_str,
@logprob_str,
# Convenience functions
logprior,
logjoint,
pointwise_loglikelihoods,
# Convenience macros
@addlogprob!,
@submodel

export AbstractVarInfo,
VarInfo,
UntypedVarInfo,
TypedVarInfo,
getlogp,
setlogp!,
acclogp!,
resetlogp!,
get_num_produce,
set_num_produce!,
reset_num_produce!,
increment_num_produce!,
set_retained_vns_del_by_spl!,
is_flagged,
set_flag!,
unset_flag!,
setgid!,
updategid!,
setorder!,
istrans,
link!,
invlink!,
tonamedtuple,
# VarName (reexport from AbstractPPL)
VarName,
inspace,
subsumes,
@varname,
# Compiler
@model,
# Utilities
vectorize,
reconstruct,
reconstruct!,
Sample,
init,
vectorize,
# Model
Model,
getmissings,
getargnames,
generated_quantities,
# Samplers
Sampler,
SampleFromPrior,
SampleFromUniform,
# Contexts
DefaultContext,
LikelihoodContext,
PriorContext,
MiniBatchContext,
PrefixContext,
assume,
dot_assume,
observer,
dot_observe,
tilde,
dot_tilde,
# Pseudo distributions
NamedDist,
NoDist,
# Prob macros
@prob_str,
@logprob_str,
# Convenience functions
logprior,
logjoint,
pointwise_loglikelihoods,
# Convenience macros
@addlogprob!,
@submodel

# Reexport
using Distributions: loglikelihood
Expand All @@ -112,7 +112,6 @@ function getspace end
abstract type AbstractVarInfo <: AbstractModelTrace end
abstract type AbstractContext end


include("utils.jl")
include("selector.jl")
include("model.jl")
Expand Down
12 changes: 3 additions & 9 deletions src/compat/ad.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# See https://github.com/TuringLang/Turing.jl/issues/1199
ChainRulesCore.@non_differentiable push!(
vi::VarInfo,
vn::VarName,
r,
dist::Distribution,
gidset::Set{Selector}
vi::VarInfo, vn::VarName, r, dist::Distribution, gidset::Set{Selector}
)

ChainRulesCore.@non_differentiable updategid!(
vi::AbstractVarInfo,
vn::VarName,
spl::Sampler,
vi::AbstractVarInfo, vn::VarName, spl::Sampler
)

# https://github.com/TuringLang/Turing.jl/issues/1595
ZygoteRules.@adjoint function dot_observe(
spl::Union{SampleFromPrior, SampleFromUniform},
spl::Union{SampleFromPrior,SampleFromUniform},
dists::AbstractArray{<:Distribution},
value::AbstractArray,
vi,
Expand Down
Loading