-
-
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
Slicing DenseAxisArrays #287
Comments
I think we don't transform the ranges, would be a good idea to do so... |
So this is working for JuMPArrays now. For JuMPDicts it's not immediately obvious what slice indexing for a dictionary should mean and how we can disambiguate it from using ranges as dictionary keys themselves. |
Actually that fix doesn't work because it breaks |
Which also reveals that we have no test coverage for the |
Would adding a method with |
I don't think |
Yeah, this is weird:
|
Maybe worth opening an issue? Wanting to dispatch on Colon seems legitimate. |
Yikes |
https://groups.google.com/forum/#!topic/julia-dev/NOF6MA6tb9Y |
Ah I gues not, or rather,
|
@timholy, are there plans to dispatch on |
Yes, it seems likely to happen, but I wouldn't call it certain. There would be quite a few new methods needed for any object that supports indexing. |
Looks like colon isn't desugared at parse time anymore (?): julia> dump(:(a[1,:]))
Expr
head: Symbol ref
args: Array(Any,(3,))
1: Symbol a
2: Int64 1
3: Symbol :
typ: Any |
This has always been a compile-time transformation. |
The remaining issue, if any, is: julia> m = Model();
julia> @variable(m, x[0:5]);
julia> x[0:2]
ERROR: KeyError: key 0:2 not found |
Are there any news on this? Why is slicing not supported in the first place? |
We're likely missing an appropriate |
AxisArrays has this functionality in some form. You may be interested in https://github.com/rdeits/AxisArrayVariables.jl (which would need to be updated for the latest JuMP). |
How about sneakily passing it through? JuMP.Containers.lookup_index(i, lookup::Dict) = isa(i, Colon) ? Colon() : isa(i, AbstractRange) ? i : lookup[i] |
What's the interpretation of indexing by 5:7 when the index set is 1:2:9? "passing it through" would be the equivalent of See the discussion at JuliaArrays/AxisArrays.jl#84 for more context. |
Better: if T::AbstractUnitRange then just pass through |
|
Is there any (dirty) workaround for making that @variable(m, x[1:DN,1:DN,1:NTC,-36:T,1:NivelesC] >= 0, Int)
[constraints]
[optimize!]
JuMP.value.(x)[:, :, :, 3:40,:] work easily? |
+1 on this issue |
The text was updated successfully, but these errors were encountered: