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

Allow Setting Defaults with Strings or Symbols #873

Closed
lrennels opened this issue Nov 12, 2021 · 1 comment
Closed

Allow Setting Defaults with Strings or Symbols #873

lrennels opened this issue Nov 12, 2021 · 1 comment

Comments

@lrennels
Copy link
Collaborator

Setting a default value with a Symbol or String errors because of a check that tries to take ndims(default), we should adapt this so it does not error and returns 1. Examples below

works fine:

using Mimi
@defcomp mycomp begin
    p1 = Parameter{Symbol}()
    function run_timestep(p,v,d,t)
        #blank
    end
end
m = Model()
set_dimension!(m, :time, 1:10)
add_comp!(m, mycomp)
update_param!(m, :mycomp, :p1, :hello)
run(m)

breaks with the error below:

using Mimi
@defcomp mycomp begin
    p1 = Parameter{Symbol}(default=:hello)
    function run_timestep(p,v,d,t)
        #blank
    end
end
m = Model()
set_dimension!(m, :time, 1:10)
add_comp!(m, mycomp)
run(m)

image

@lrennels
Copy link
Collaborator Author

@bryanparthum thanks for the find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant