-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix parameter type bug for non-time arrays #654
Conversation
Codecov Report
@@ Coverage Diff @@
## master #654 +/- ##
=======================================
Coverage 80.22% 80.23%
=======================================
Files 39 39
Lines 2746 2742 -4
=======================================
- Hits 2203 2200 -3
+ Misses 543 542 -1
Continue to review full report at Codecov.
|
How does this work, if we do want to use autodifferentiation? Do things break if you set the model The previous functionality (which admittedly was not considering all the cases) was that you could still set the parameters on a model as normal |
@jrising if the autodiff functionality that you are describing was something that was previously working for arrays that have a time dimension, then it should still work. The arrays of values still get converted to the model's default number type in the outer function call (before the function Not sure if that fully answers your question though, let me know if you still think there might be a problem for specifically using "Number" as the default type! Another thing, if you want to test it out, please don't use this branch, but try it on the |
here's an example with the number type set to "Number" that seems to still work: using Mimi
@defcomp bar begin
x::Int64 = Parameter(index=[regions])
y = Parameter(index=[regions])
z = Parameter(index=[time])
end
m = Model(Number)
set_dimension!(m, :time, 3)
set_dimension!(m, :regions, [:a, :b])
add_comp!(m, bar)
set_param!(m, :bar, :x, [1,2])
set_param!(m, :bar, :y, [1.,2.]) # even though y and z are provided as Floats, they will be converted to Number
set_param!(m, :bar, :z, [1.,2.,3.])
run(m)
m[:bar,:x] # returns an Array{Int64, 1}
m[:bar,:y] # returns an Array{Number, 1}
m[:bar,:z] # returns an Array{Number, 1} |
Thanks for testing this! Looks like it should work smoothly. |
@jrising found this bug, more info on this forum post:
https://forum.mimiframework.org/t/array-parameter-setting-fails-with-int64-parameter-type/113
I added a line to the test file which now passes, but represents what previously would have errored.