-
-
Notifications
You must be signed in to change notification settings - Fork 394
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
"Key not found" error with colons #643
Comments
We can fix #287 now |
FWIW: julia> @defVar(m, x[i=1:5,j=1:5,k=0:5]);
julia> x[:,1,0]
ERROR: MethodError: `isless` has no method matching isless(::Colon, ::Int64)
Closest candidates are:
isless(::AbstractFloat, ::Real)
isless(::Real, ::Real)
isless(::Char, ::Integer)
...
in getindex at /Users/huchette/.julia/v0.4/JuMP/src/JuMPArray.jl:61 |
We can give a better error message here, if we assume that nobody would use |
Well we can always make S = [Colon()]
@defVar(m, x[S]) an error... |
It's weird, but I'm not sure we can disambiguate the case @IainNZ mentions and this one: julia> @defVar(m, y[[:]]);
julia> y[:]
1-element Array{JuMP.Variable,1}:
y[Colon()] |
@joehuchette, not sure I understand. Can we disambiguate it if we disallow colons in keys? |
I guess? Seems kinda arbitrary and brittle |
Not having slicing work is also brittle and seemingly arbitrary since it works for some kinds of JuMP variables and not others. |
It's certainly less brittle to reliably throw an error than give completely unexpected behavior if you use a |
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)
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)
We should probably be providing a better error message here
The text was updated successfully, but these errors were encountered: