-
-
Notifications
You must be signed in to change notification settings - Fork 411
Fix scoping issue in user-defined Containers #2916
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
Conversation
|
Do we document the interface that external containers need to satisfy for this to work? |
|
No, this is essentially undocumented because it's not something we really want to advertise: https://discourse.julialang.org/t/using-alternative-array-container-types-in-jump/77707/3. We should instead encourage people to create their own containers outside of JuMP, rather than extending things in this way. |
|
Why support it at all if we don't want to document it? |
Codecov Report
@@ Coverage Diff @@
## master #2916 +/- ##
=======================================
Coverage 95.20% 95.20%
=======================================
Files 43 43
Lines 5774 5777 +3
=======================================
+ Hits 5497 5500 +3
Misses 277 277
Continue to review full report at Codecov.
|
|
I'd be okay documenting this in the Developer/Extensions section. We introduced it with the view to unifying the named-array landscape in Julia, #2523, but we have some unique requirements that I don't know if it makes sense to do so. The main distinction is that some package developers might want to extend things, but general users probably shouldn't. |
|
Documenting it in the Developer/Extensions section would be fine. What error message will users get if they try a container that hasn't implemented the Containers method? |
|
It's currently (after this PR) julia> struct Foo end;
julia> @variable(model, x[S], Bin, container = Foo)
ERROR: Unable to build a container with the provided type Foo. Implement `Containers.container`.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] container(#unused#::Function, #unused#::JuMP.Containers.VectorizedProductIterator{Tuple{Vector{String}}}, D::Type)
@ JuMP.Containers ~/.julia/dev/JuMP/src/Containers/container.jl:176
[3] macro expansion
@ ~/.julia/dev/JuMP/src/macros.jl:142 [inlined]
[4] top-level scope
@ REPL[21]:1TODOs
|
|
Ok, that's already a decent error message as is. I was worried about MethodErrors. |
We'd discussed this before, #2523, and I thought I fixed it, but I missed a scoping issue.
Raised on discourse: https://discourse.julialang.org/t/using-alternative-array-container-types-in-jump/77707