Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
thevolatilebit committed Jan 17, 2024
1 parent 3b3e102 commit dccb8fb
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/agents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ function aagent(base_type, super_type, type, __module)
constructor = define_agent(base_type, super_type, type, __module,
quote
function $(tname)(name::AbstractString,
args...) where {
$(param_tnames_constraints...),
args...) where {
$(param_tnames_constraints...),
}
uuid = AlgebraicAgents.uuid4()
inners = Dict{String, AbstractAlgebraicAgent}()
Expand Down
8 changes: 4 additions & 4 deletions src/integrations/AgentsIntegration/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ mutable struct ABMAgent <: AbstractAlgebraicAgent

## implement constructor
function ABMAgent(name::AbstractString, abm::Agents.AgentBasedModel;
agent_step! = Agents.dummystep, model_step! = Agents.dummystep,
when = true, when_model = when, step_size = 1.0,
tspan::NTuple{2, Float64} = (0.0, Inf), kwargs...)
agent_step! = Agents.dummystep, model_step! = Agents.dummystep,
when = true, when_model = when, step_size = 1.0,
tspan::NTuple{2, Float64} = (0.0, Inf), kwargs...)

# initialize wrap
i = new()
Expand Down Expand Up @@ -89,7 +89,7 @@ mutable struct ABMAgent <: AbstractAlgebraicAgent
end

function wrap_system(name::AbstractString, abm::Agents.AgentBasedModel, args...;
kwargs...)
kwargs...)
ABMAgent(name, abm, args...; kwargs...)
end

Expand Down
8 changes: 4 additions & 4 deletions src/integrations/AlgebraicDynamicsIntegration/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GraphicalAgent("rabbit", ContinuousMachine{Float64}(1,1,1, dotr, (u, p, t) -> u)
end

function wrap_system(name::AbstractString, sharer::GraphicalModelType, args...;
kwargs...)
kwargs...)
GraphicalAgent(name, sharer, args...; kwargs...)
end

Expand Down Expand Up @@ -62,7 +62,7 @@ Apply `oapply(diagram, systems...)` and wrap the result as a `GraphicalAgent`.

@doc sum_algebraicdynamics_docstring
function (x::Vector{M}; diagram, pushout = nothing,
name = "diagram") where {M <: GraphicalAgent}
name = "diagram") where {M <: GraphicalAgent}
x_ = map(x -> x.system, x)
m = isnothing(pushout) ? oapply(diagram, x_) :
oapply(diagram, x, pushout)
Expand All @@ -76,7 +76,7 @@ end

@doc sum_algebraicdynamics_docstring
function (x::Vararg{M}; diagram, pushout = nothing,
name = "diagram") where {M <: GraphicalAgent}
name = "diagram") where {M <: GraphicalAgent}
x_ = map(x -> x.system, collect(x))
m = isnothing(pushout) ? oapply(diagram, x_) :
oapply(diagram, x, pushout)
Expand All @@ -101,7 +101,7 @@ end

@doc sum_algebraicdynamics_docstring
function (x::AbstractDict{S, M}; diagram, pushout = nothing,
name = "diagram") where {S, M <: GraphicalAgent}
name = "diagram") where {S, M <: GraphicalAgent}
x_ = Dict(x -> x[1] => x[2].system, x)
m = isnothing(pushout) ? oapply(diagram, x_) :
oapply(diagram, x, pushout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DiffEqAgent(system, u0, tspan, params; alg=Tsit5())
```
"""
function DiffEqAgent(agent::GraphicalAgent, args...;
alg = nothing, kwargs...)
alg = nothing, kwargs...)
# get DEProblem
prob = _get_problem_type(agent.system)(agent.system, args...)
# get alg
Expand Down
8 changes: 4 additions & 4 deletions src/integrations/SciMLIntegration/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ mutable struct DiffEqAgent <: AbstractAlgebraicAgent
observables::Dict{Any, Int}

function DiffEqAgent(name, problem::DiffEqBase.DEProblem,
alg = DifferentialEquations.default_algorithm(problem)[1], args...;
observables = Dict{Any, Int}(), kwargs...)
alg = DifferentialEquations.default_algorithm(problem)[1], args...;
observables = Dict{Any, Int}(), kwargs...)
problem = DifferentialEquations.remake(problem;
p = Params(Val(DummyType), problem.p))

Expand Down Expand Up @@ -67,8 +67,8 @@ end
Base.setindex!(p::Params, v, i::Int) = getfield(p, :params)[i] = v

function wrap_system(name::AbstractString, problem::DiffEqBase.DEProblem, args...;
alg = DifferentialEquations.default_algorithm(problem)[1],
kwargs...)
alg = DifferentialEquations.default_algorithm(problem)[1],
kwargs...)
DiffEqAgent(name, problem, alg, args...; kwargs...)
end

Expand Down
10 changes: 5 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mutable struct FreeAgent <: AbstractAlgebraicAgent
```
"""
function FreeAgent(name::AbstractString,
agents::Vector{<:AbstractAlgebraicAgent} = AbstractAlgebraicAgent[])
agents::Vector{<:AbstractAlgebraicAgent} = AbstractAlgebraicAgent[])
m = new()
m.uuid = uuid4()
m.name = name
Expand Down Expand Up @@ -348,7 +348,7 @@ end

"Pretty-print agent's parent and inners. Optionally specify indent."
function print_neighbors(io::IO, m::MIME"text/plain", a::AbstractAlgebraicAgent,
expand_inners = true)
expand_inners = true)
indent = get(io, :indent, 0)

expand_inners && !isnothing(getparent(a)) &&
Expand Down Expand Up @@ -388,7 +388,7 @@ end

# specialize show method
function Base.show(io::IO, m::MIME"text/plain", a::AbstractAlgebraicAgent,
expand_inners = true)
expand_inners = true)
print_header(io, m, a)
print_custom(io, m, a)
print_neighbors(io, m, a, expand_inners)
Expand Down Expand Up @@ -455,8 +455,8 @@ end
This is a low-level method used for instantiating an agent of the specified `type`. It also instantiates all the inner sub-agents found within the given `hierarchy` dictionary.
"""
function _load(type::Type{T},
hierarchy::AbstractDict;
eval_scope = @__MODULE__) where {T <: AbstractAlgebraicAgent}
hierarchy::AbstractDict;
eval_scope = @__MODULE__) where {T <: AbstractAlgebraicAgent}
agent = type(hierarchy["name"],
get(hierarchy, "arguments", [])...;
get(hierarchy, "keyword_arguments", [])...)
Expand Down
8 changes: 4 additions & 4 deletions src/opera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ add_instantious!(agent, () -> wake_up(agent))
```
"""
function add_instantious!(opera::Opera, call, priority::Number = 0.0,
id = "instantious_" *
get_count(opera, :n_instantious_interactions))
id = "instantious_" *
get_count(opera, :n_instantious_interactions))
add_instantious!(opera, (; id, call, priority))
end

Expand Down Expand Up @@ -191,7 +191,7 @@ poke(agent, 1.) # with priority equal to 1
```
"""
function poke(agent, priority::Number = 0.0,
id = "instantious_" * get_count(getopera(agent), :n_instantious_interactions))
id = "instantious_" * get_count(getopera(agent), :n_instantious_interactions))
add_instantious!(getopera(agent),
(; id, call = () -> _interact!(agent),
priority = Float64(priority)))
Expand Down Expand Up @@ -251,7 +251,7 @@ add_future!(alice, 5.0, () -> interact(alice), "alice_schedule")
function add_future! end

function add_future!(opera::Opera, time, call,
id = "future_" * get_count(opera, :n_futures))
id = "future_" * get_count(opera, :n_futures))
new_action = (; id, call, time)

# sorted insert
Expand Down
2 changes: 1 addition & 1 deletion src/paths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Return agents in the hierarchy whose names match the given wildcard.
If `inners_only==true`, consider descendants of `agent` only.
"""
function by_name(agent::AbstractAlgebraicAgent, name::Union{Glob.FilenameMatch, Regex};
inners_only = false)
inners_only = false)
agent = inners_only ? agent : topmost(agent)
agents = []
prewalk(a -> (occursin(name, getname(a))) && push!(agents, a), agent)
Expand Down
8 changes: 4 additions & 4 deletions src/queries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function Base.filter(a::AbstractAlgebraicAgent, queries::Vararg{<:FilterQuery})
end

function Base.filter(a::Vector{<:AbstractAlgebraicAgent},
queries::Vararg{<:FilterQuery})
queries::Vararg{<:FilterQuery})
filtered = AbstractAlgebraicAgent[]
for a in a
all(q -> _filter(a, q), queries) && push!(filtered, a)
Expand Down Expand Up @@ -125,8 +125,8 @@ struct TransformQuery{F <: Function} <: AbstractQuery
query::F

function TransformQuery(name::T,
query::F) where {T <: Union{Symbol, AbstractString},
F <: Function}
query::F) where {T <: Union{Symbol, AbstractString},
F <: Function}
new{F}(Symbol(name), query)
end
end
Expand Down Expand Up @@ -170,7 +170,7 @@ function transform(a::AbstractAlgebraicAgent, queries::Vararg{<:TransformQuery})
end

function transform(a::Vector{<:AbstractAlgebraicAgent},
queries::Vararg{<:TransformQuery})
queries::Vararg{<:TransformQuery})
results = []
for a in a
try
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ print(join(typetree_mmd(Integer), ""))
```
"""
function typetree_mmd(T::Type, TT::S = nothing;
rem = false) where {S <: Union{Type, Nothing}}
rem = false) where {S <: Union{Type, Nothing}}
ret = Vector{String}()
if isnothing(TT)
append!(ret, ["classDiagram\n"])
Expand Down

0 comments on commit dccb8fb

Please sign in to comment.