JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
729 stars 117 forks source link

Agents macro allows parametric types and subtyping #843

Closed Tortar closed 1 year ago

Tortar commented 1 year ago

this should solve #725 , can you @mastrof say to me if this is what you intended and that it works for your use case please?

Now this works:

using Agents
abstract type AbstractFoo{D} <: AbstractAgent where D end
@agent MyFoo2{D} ContinuousAgent{D} where D AbstractFoo{D} begin; end
codecov-commenter commented 1 year ago

Codecov Report

Merging #843 (1112553) into main (3ac17b8) will increase coverage by 0.56%. Report is 1 commits behind head on main. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #843      +/-   ##
==========================================
+ Coverage   70.18%   70.75%   +0.56%     
==========================================
  Files          42       42              
  Lines        2727     2773      +46     
==========================================
+ Hits         1914     1962      +48     
+ Misses        813      811       -2     
Files Changed Coverage Δ
src/core/agents.jl 100.00% <ø> (ø)

... and 4 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

mastrof commented 1 year ago

Yes that's what I needed, thanks a lot.

Tortar commented 1 year ago

with the latest commit

using Agents
abstract type AbstractFoo{D} <: AbstractAgent where D end
@agent MyFoo2{D} ContinuousAgent{D} AbstractFoo{D} begin end

works!

edit:

but it has the side effect that

using Agents
abstract type AbstractFoo{D} <: AbstractAgent where D end
@agent MyFoo2{D} ContinuousAgent{D, D} AbstractFoo{D} begin end

also works, which doesn't make sense, so I reverted the change in the latest commit