Skip to content

Commit 45e4d59

Browse files
authored
Merge pull request #167 from ComputationalPsychiatry/dev
0.7.1
2 parents 90e74cd + a76ca72 commit 45e4d59

File tree

9 files changed

+19
-20
lines changed

9 files changed

+19
-20
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,4 @@ jobs:
4141
shell: julia --color=yes {0}
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
# This repo uses Documenter, so we can reuse our [Documenter SSH key](https://documenter.juliadocs.org/stable/man/hosting/walkthrough/).
45-
# If we didn't have one of those setup, we could configure a dedicated ssh deploy key `COMPATHELPER_PRIV` following https://juliaregistries.github.io/CompatHelper.jl/dev/#Creating-SSH-Key.
46-
# Either way, we need an SSH key if we want the PRs that CompatHelper creates to be able to trigger CI workflows themselves.
47-
# That is because GITHUB_TOKEN's can't trigger other workflows (see https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow).
48-
# Check if you have a deploy key setup using these docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-deploy-keys.
49-
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
50-
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
44+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ActionModels"
22
uuid = "320cf53b-cc3b-4b34-9a10-0ecb113566a3"
33
authors = ["Peter Thestrup Waade [email protected]", "Luke Ring [email protected]", "Malte Lau Møller", "Christoph Mathys [email protected]"]
4-
version = "0.7.0"
4+
version = "0.7.1"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Stable](https://img.shields.io/badge/docs-dev-blue.svg)](https://ComputationalPsychiatry.github.io/ActionModels.jl/dev/)
33
[![Build Status](https://github.com/ComputationalPsychiatry/ActionModels.jl/actions/workflows/CI_full.yml/badge.svg?branch=main)](https://github.com/ComputationalPsychiatry/ActionModels.jl/actions/workflows/CI_full.yml?query=branch%3Amain)
44
[![Coverage](https://codecov.io/gh/ComputationalPsychiatry/ActionModels.jl/branch/main/graph/badge.svg?token=NVFiiPydFA)](https://codecov.io/gh/ComputationalPsychiatry/ActionModels.jl)
5-
[![License: GNU](https://img.shields.io/badge/License-GNU-yellow)](<https://www.gnu.org/licenses/>)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
77

88
# Welcome to ActionModels!

docs/julia_files/B_user_guide/7_using_submodels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838
# The attributes object, or whichvever subpart of it that will contain the states and parameters, needs to be mutable, as it will be updated during the model fitting process.
3939
# Additionally, in order to function with Turing, the attributes struct needs to have type parameters that are subtypes of Real for continuous (Float64) and discrete (Int64) parameters and states.
4040
# This is because some AD backends like ForwardDiff and ReverseDiff need to switch between different subtypes of Real to calculate gradients.
41-
# Notably, users may in some situations want to use the same type for the attributes object as for the submodel object above. This is possible.
41+
# Notably, users may in some situations want to use the same type for the attributes object as for the submodel object above. This is possible, since `AbstractSubmodelAttributes` is a subtype of `AbstractSubmodel`.
4242

4343
Base.@kwdef mutable struct RescorlaWagnerAttributes{T<:Real} <:
4444
ActionModels.AbstractSubmodelAttributes

docs/julia_files/README.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# [![Stable](https://img.shields.io/badge/docs-dev-blue.svg)](https://ComputationalPsychiatry.github.io/ActionModels.jl/dev/)
33
# [![Build Status](https://github.com/ComputationalPsychiatry/ActionModels.jl/actions/workflows/CI_full.yml/badge.svg?branch=main)](https://github.com/ComputationalPsychiatry/ActionModels.jl/actions/workflows/CI_full.yml?query=branch%3Amain)
44
# [![Coverage](https://codecov.io/gh/ComputationalPsychiatry/ActionModels.jl/branch/main/graph/badge.svg?token=NVFiiPydFA)](https://codecov.io/gh/ComputationalPsychiatry/ActionModels.jl)
5-
# [![License: GNU](https://img.shields.io/badge/License-GNU-yellow)](<https://www.gnu.org/licenses/>)
5+
# [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
# [![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
77

88
# # Welcome to ActionModels!

src/ActionModels.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export set_parameters!, set_states!, set_actions!, reset!
3939

4040
## For fitting models ##
4141
export create_model
42-
export Regression, RegressionPrior, exp, logistic
42+
export Regression, RegressionPrior
43+
export exp, logistic, softmax #export commonly used LogExpFunctions functions
4344
export sample_prior!, sample_posterior!, SampleSaveResume
4445
export get_session_parameters!, get_state_trajectories!, summarize
4546
# export parameter_recovery

src/defining_models/structs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ end
459459
### TYPES FOR USE IN THE ACTION MODEL ###
460460
#########################################
461461
## Abstract type for submodel attributes ##
462-
abstract type AbstractSubmodelAttributes end
462+
# It is a subtype of AbstractSubmodel, so that attributes can be as Submodels too
463+
abstract type AbstractSubmodelAttributes <: AbstractSubmodel end
463464

464465
struct NoSubModelAttributes <: AbstractSubmodelAttributes end
465466

src/simulation/plots/plot_trajectory.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Plot{Plots.GRBackend() n=1}
3030
state_history = get_history(agent, target_state)
3131

3232
if !isnothing(index) && !(first(state_history) isa AbstractArray)
33-
@error "And index was provided, but the state is not an array."
33+
@error "An index was provided, but the state is not an array."
3434
end
3535

3636
if isnothing(index) && first(state_history) isa AbstractArray
@@ -48,8 +48,8 @@ Plot{Plots.GRBackend() n=1}
4848
#Replace missings with NaNs for plotting
4949
state_history = replace(state_history, missing => NaN)
5050

51-
#The x-axis starts at 0
52-
x_axis = collect(0:(length(state_history)-1))
51+
#The x-axis starts at 0 and goes to the number of timesteps
52+
x_axis = collect(0:agent.n_timesteps.value)
5353

5454
xlabel --> "Timestep"
5555
yguide --> "$target_state"

src/simulation/structs.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Agent{TH}
2+
Agent{T<:AbstractSubmodel}
33
44
Container for a simulated agent, including the action model, model attributes, state history, and number of timesteps.
55
@@ -19,10 +19,10 @@ Action model: rescorla_wagner_act_after_update
1919
This agent has received 0 observations
2020
```
2121
"""
22-
struct Agent{TH<:NamedTuple}
22+
struct Agent{T<:AbstractSubmodel}
2323
action_model::Function
2424
model_attributes::ModelAttributes
25-
history::TH
25+
history::NamedTuple
2626
n_timesteps::Variable{Int64}
2727
end
2828

@@ -105,6 +105,9 @@ function init_agent(
105105
push!(state, get_states(model_attributes, state_name))
106106
end
107107

108+
#Get submodel type
109+
submodel_type = typeof(action_model.submodel)
110+
108111
## Create agent ##
109-
Agent(action_model.action_model, model_attributes, history, Variable{Int64}(0))
112+
Agent{submodel_type}(action_model.action_model, model_attributes, history, Variable{Int64}(0))
110113
end

0 commit comments

Comments
 (0)