-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Container revamp #1102
Container revamp #1102
Conversation
0607602
to
3dcd39b
Compare
3dcd39b
to
497083b
Compare
Codecov Report
@@ Coverage Diff @@
## jump/moi #1102 +/- ##
===========================================
+ Coverage 21.46% 22.17% +0.7%
===========================================
Files 20 20
Lines 3647 3571 -76
===========================================
+ Hits 783 792 +9
+ Misses 2864 2779 -85
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## jump/moi #1102 +/- ##
=========================================
+ Coverage 21.46% 22.47% +1%
=========================================
Files 20 20
Lines 3647 3578 -69
=========================================
+ Hits 783 804 +21
+ Misses 2864 2774 -90
Continue to review full report at Codecov.
|
1438546
to
041d4b7
Compare
Replace JuMPDict with Dict. Rewrite JuMPArray to be compatible with AbstractArray. Explicit keyword argument in macro to force container type. Closes #1099 Closes #1047 Closes #417 (collect is now well defined for Array, JuMPArray, and Dict) Closes #833 (`eachindex` and `indices` are defined for JuMPArray) Closes #740 (dot broadcast syntax is now the default, no need to explicitly define vectorized functions) Closes #922 (fixed by checking for duplicates) Closes #933 (corollary: closes #346) Closes #643 (colons work for Array and JuMPArray, obviously not Dict) Closes #730 (end is not supported for JuMPArray) Closes #646 (we now rely on built-in iteration behavior for Dict)
041d4b7
to
852a3af
Compare
I plan on adding some more tests but otherwise this is ready for review. Note that it closes 11 issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Do you have a sense of the performance relative to the current implementation?
src/JuMPArray.jl
Outdated
struct JuMPArray{T,N,Ax} <: AbstractArray{T,N} | ||
data::Array{T,N} | ||
axes::Ax | ||
lookup::Vector{Dict} # TODO: correctly type return type of the Dict as Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO out of scope for this PR?
src/JuMPArray.jl
Outdated
# AbstractArray interface | ||
|
||
Base.linearindices(A::JuMPArray) = error("JuMPArray does not support this operation.") | ||
Base.size(A::JuMPArray) = error("JuMPArray does not define this operation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this might something users could reasonably expect to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't define size
for the old JuMPArray, and neither does OffsetArrays. Defining it causes end
to return the wrong result.
3. Otherwise, generate an empty `Dict{Any,T}`. | ||
|
||
The second element of the return tuple is a `Bool`, `true` if the container type | ||
automatically checks for duplicate terms in the index sets and `false` otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be simpler to add a autocheckforduplicates(::Symbol)
function, rather than explicitly returning a boolean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that it depends on the processing of indexvars
and indexsets
(hasdependentsets
). I agree that this solution isn't too tidy though.
There's no reason to benchmark |
OK. What's the roadmap then with this PR, generated functions, and AxisArrays? |
I'd like to merge this PR soon and get back to MOI work. When MOI is close to being wrapped up we can revisit and see if AxisArrays has implemented the functionality we need or if we need to tidy up JuMPArray. |
Replace JuMPDict with Dict. Rewrite JuMPArray to be compatible with AbstractArray. Explicit keyword argument in macro to force container type.
Unfortunately we can't use AxisArrays at the moment because of JuliaArrays/AxisArrays.jl#117. I'm hoping that we can swap AxisArray for JuMPArray before JuMP 1.0/0.19, but for now I'd like to go ahead with this since the basic functionality is there. If we keep JuMPArray, it will need to be polished and performance-tested before the next release.
Broadcast is implemented for JuMPArray, so we can just do
resultvalue.(A)
whenA
is an Array or a JuMPArray (but not when it's a Dict).See commit for list of 11 issues that this PR closes (once merged into master).
Remaining to do for merge:
container
keyword argument to all macros