Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"MethodError: no method matching..." with default agent attribute values. #983

Closed
jlambvo opened this issue Feb 23, 2024 · 1 comment · Fixed by #984
Closed

"MethodError: no method matching..." with default agent attribute values. #983

jlambvo opened this issue Feb 23, 2024 · 1 comment · Fixed by #984
Labels
agent-construction About making agents bug Something isn't working

Comments

@jlambvo
Copy link

jlambvo commented Feb 23, 2024

Following the new 6.0.0 macro for defining agents, I'd like to be able to add agents with default values for all additional attributes. However, I get a no matching method error unless I supply at least one keyword argument for additional attributes, or positional arguments for all. If I supply one karg, defaults are applied for other attributes.

Is this expected behavior?

Minimum working example mostly copied and pasted from source comments:

using Agents
using Graphs
@agent struct Agent(GraphAgent)
    w::Float64 = 0.1
    k::Bool = false
end
model = StandardABM(Agent, GraphSpace(complete_digraph(5)))

add_agent!(model; w = 0.5, k = true)
add_agent!(model; w = 0.5)
add_agent!(model; k = true)
add_agent!(model)

See my results:

image

@Tortar Tortar added bug Something isn't working agent-construction About making agents labels Feb 23, 2024
@Tortar
Copy link
Member

Tortar commented Feb 23, 2024

No, this is not intended, thank you for reporting it, it should be fixed as soon as #984 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-construction About making agents bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants