Skip to content

Commit f748454

Browse files
authored
Merge pull request #46 from ilabcode/dev
Updated package to 3.0
2 parents e885377 + 6673a55 commit f748454

40 files changed

+404
-307
lines changed

.github/workflows/CI.yml renamed to .github/workflows/CI_full.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
name: CI
1+
name: CI_full
22

33
on:
44
push:
55
branches:
66
- main
7-
- dev
87
tags: '*'
98
pull_request:
9+
branches:
10+
- main
1011
workflow_dispatch:
1112

12-
concurrency:
13-
# Skip intermediate builds: always.
14-
# Cancel intermediate builds: only if it is a pull request build.
15-
group: ${{ github.workflow }}-${{ github.ref }}
16-
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1713

1814
jobs:
1915
test:
2016
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
2117
runs-on: ${{ matrix.os }}
18+
# This allows a subsequently queued workflow run to interrupt previous runs
19+
concurrency:
20+
group: "${{ github.workflow }} - ${{ matrix.os }} - ${{ matrix.version }} @ ${{ github.ref }}"
21+
cancel-in-progress: true
2222
strategy:
2323
fail-fast: false
2424
matrix:
2525
version:
2626
- '1'
27+
- 'nightly'
2728
os:
2829
- ubuntu-latest
2930
- macOS-latest

.github/workflows/CI_small.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI_small
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
tags: '*'
8+
pull_request:
9+
branches:
10+
- dev
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
16+
runs-on: ${{ matrix.os }}
17+
# This allows a subsequently queued workflow run to interrupt previous runs
18+
concurrency:
19+
group: "${{ github.workflow }} - ${{ matrix.os }} @ ${{ github.ref }}"
20+
cancel-in-progress: true
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
version:
25+
- '1'
26+
os:
27+
- ubuntu-latest
28+
arch:
29+
- x64
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: julia-actions/setup-julia@v1
33+
with:
34+
version: ${{ matrix.version }}
35+
arch: ${{ matrix.arch }}
36+
- uses: julia-actions/cache@v1
37+
- uses: julia-actions/julia-buildpkg@v1
38+
- uses: julia-actions/julia-runtest@v1
39+
- uses: julia-actions/julia-processcoverage@v1
40+
- uses: codecov/codecov-action@v3
41+
with:
42+
token: ${{ secrets.CODECOV_TOKEN }}
43+
files: lcov.info

.github/workflows/CompatHelper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
env:
1414
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1515
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
16-
run: julia -e 'using CompatHelper; CompatHelper.main()'
16+
run: julia -e 'using CompatHelper; CompatHelper.main(; master_branch = "dev")'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# GitHub action to automerge dependabot PRs. Only merges if tests pass due to branch protections in the repo.
2+
3+
name: automerge-dependabot-prs
4+
5+
on: pull_request
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
dependabot-automerge:
13+
runs-on: ubuntu-latest
14+
if: ${{ github.actor == 'dependabot[bot]'}}
15+
16+
steps:
17+
# Checkout action is required for token to persist
18+
- name: Enable auto-merge for Dependabot PRs
19+
run: gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Auto approve dependabot PRs
25+
if: github.actor == 'dependabot[bot]'
26+
uses: hmarr/auto-approve-action@v2
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/documentation.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
87
tags: '*'
98
pull_request:
9+
branches:
10+
- main
1011

12+
# This allows a subsequently queued workflow run to interrupt previous runs
1113
concurrency:
12-
# Skip intermediate builds: always.
13-
# Cancel intermediate builds: only if it is a pull request build.
14-
group: ${{ github.workflow }}-${{ github.ref }}
15-
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
14+
group: "${{ github.workflow }} @ ${{ github.ref }}"
15+
cancel-in-progress: true
1616

1717
jobs:
1818
docs:

.github/workflows/formatting.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

Project.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
name = "HierarchicalGaussianFiltering"
22
uuid = "63d42c3e-681c-42be-892f-a47f35336a79"
33
authors = ["Peter Thestrup Waade [email protected]", "Jacopo Comoglio [email protected]", "Christoph Mathys [email protected]\n and contributors"]
4-
version = "0.2.3"
4+
version = "0.3.0"
55

66
[deps]
77
ActionModels = "320cf53b-cc3b-4b34-9a10-0ecb113566a3"
88
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
99
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
10-
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
1110

1211
[compat]
13-
ActionModels = "0.2"
12+
ActionModels = "0.3"
1413
Distributions = "0.25"
1514
RecipesBase = "1"
16-
Turing = "0.21, 0.22, 0.23"
1715
julia = "1.8"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
55
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
66
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
77
HierarchicalGaussianFiltering = "63d42c3e-681c-42be-892f-a47f35336a79"
8+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
89
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
910
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1011
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1112
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
12-
Turing = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"

docs/tutorials/classic_binary.jl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# First load packages
55
using ActionModels
66
using HierarchicalGaussianFiltering
7-
using Turing
87
using CSV
98
using DataFrames
109
using Plots
@@ -19,7 +18,7 @@ data_path = hgf_path * "/docs/tutorials/data/"
1918
inputs = CSV.read(data_path * "classic_binary_inputs.csv", DataFrame)[!, 1];
2019

2120
# Create an HGF
22-
hgf_params = Dict(
21+
hgf_parameters = Dict(
2322
("u", "category_means") => Real[0.0, 1.0],
2423
("u", "input_precision") => Inf,
2524
("x2", "evolution_rate") => -2.5,
@@ -31,11 +30,12 @@ hgf_params = Dict(
3130
("x1", "x2", "value_coupling") => 1.0,
3231
("x2", "x3", "volatility_coupling") => 1.0,
3332
);
34-
hgf = premade_hgf("binary_3level", hgf_params, verbose = false);
33+
hgf = premade_hgf("binary_3level", hgf_parameters, verbose = false);
3534

3635
# Create an agent
37-
agent_params = Dict("sigmoid_action_precision" => 5);
38-
agent = premade_agent("hgf_unit_square_sigmoid_action", hgf, agent_params, verbose = false);
36+
agent_parameters = Dict("sigmoid_action_precision" => 5);
37+
agent =
38+
premade_agent("hgf_unit_square_sigmoid_action", hgf, agent_parameters, verbose = false);
3939

4040
# Evolve agent and save actions
4141
actions = give_inputs!(agent, inputs);
@@ -48,7 +48,7 @@ plot_trajectory(agent, ("x2", "posterior"))
4848
plot_trajectory(agent, ("x3", "posterior"))
4949

5050
# Set fixed parameters
51-
fixed_params = Dict(
51+
fixed_parameters = Dict(
5252
"sigmoid_action_precision" => 5,
5353
("u", "category_means") => Real[0.0, 1.0],
5454
("u", "input_precision") => Inf,
@@ -58,26 +58,31 @@ fixed_params = Dict(
5858
("x3", "initial_precision") => 1,
5959
("x1", "x2", "value_coupling") => 1.0,
6060
("x2", "x3", "volatility_coupling") => 1.0,
61-
("x2", "evolution_rate") => -3.0,
6261
("x3", "evolution_rate") => -6.0,
6362
);
6463

6564
# Set priors for parameter recovery
6665
param_priors = Dict(("x2", "evolution_rate") => Normal(-3.0, 0.5));
6766

6867
# Prior predictive plot
69-
plot_predictive_simulation(param_priors, agent, inputs, ("x1", "prediction_mean"), n_simulations = 100)
68+
plot_predictive_simulation(
69+
param_priors,
70+
agent,
71+
inputs,
72+
("x1", "prediction_mean"),
73+
n_simulations = 100,
74+
)
7075

7176
# Get the actions from the MATLAB tutorial
7277
actions = CSV.read(data_path * "classic_binary_actions.csv", DataFrame)[!, 1];
7378

7479
# Fit the actions
7580
fitted_model = fit_model(
7681
agent,
82+
param_priors,
7783
inputs,
7884
actions,
79-
param_priors,
80-
fixed_params,
85+
fixed_parameters = fixed_parameters,
8186
verbose = true,
8287
n_iterations = 10,
8388
)
@@ -89,4 +94,10 @@ plot(fitted_model)
8994
plot_parameter_distribution(fitted_model, param_priors)
9095

9196
# Posterior predictive plot
92-
plot_predictive_simulation(fitted_model, agent, inputs, ("x1", "prediction_mean"), n_simulations = 3)
97+
plot_predictive_simulation(
98+
fitted_model,
99+
agent,
100+
inputs,
101+
("x1", "prediction_mean"),
102+
n_simulations = 3,
103+
)

docs/tutorials/classic_usdchf.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# First load packages
44
using ActionModels
55
using HierarchicalGaussianFiltering
6-
using Turing
76
using Plots
87
using StatsPlots
98

@@ -38,7 +37,7 @@ parameters = Dict(
3837
"gaussian_action_precision" => 100,
3938
);
4039

41-
set_params!(agent, parameters)
40+
set_parameters!(agent, parameters)
4241
reset!(agent)
4342

4443
# Evolve agent
@@ -74,11 +73,11 @@ plot_trajectory(
7473
size = (1300, 500),
7574
xlims = (0, 615),
7675
xlabel = "Trading days since 1 January 2010",
77-
title = "Volatility parent trajectory"
76+
title = "Volatility parent trajectory",
7877
)
7978

80-
# Set priors for turing fitting
81-
fixed_params = Dict(
79+
# Set priors for fitting
80+
fixed_parameters = Dict(
8281
("u", "x1", "value_coupling") => 1.0,
8382
("x1", "x2", "volatility_coupling") => 1.0,
8483
("x1", "initial_mean") => 0,
@@ -95,15 +94,21 @@ param_priors = Dict(
9594
);
9695

9796
# Prior predictive simulation plot
98-
plot_predictive_simulation(param_priors, agent, inputs, ("x1", "posterior_mean"); n_simulations = 3)
97+
plot_predictive_simulation(
98+
param_priors,
99+
agent,
100+
inputs,
101+
("x1", "posterior_mean");
102+
n_simulations = 3,
103+
)
99104

100105
# Do parameter recovery
101106
fitted_model = fit_model(
102107
agent,
108+
param_priors,
103109
inputs,
104110
actions,
105-
param_priors,
106-
fixed_params,
111+
fixed_parameters = fixed_parameters,
107112
verbose = true,
108113
n_iterations = 10,
109114
)

0 commit comments

Comments
 (0)