{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/comments/79330880","id":79330880,"diff_hunk":"@@ -183,13 +185,86 @@ Base.length(it::ValueIterator)  = length(it.x)\n \n type KeyIterator{JA<:JuMPArray}\n     x::JA\n+    dim::Int\n+    next_k_cache::Array{Any,1}\n+    function KeyIterator(d)\n+        n = ndims(d.innerArray)\n+        new(d, n, Array(Any, n+1))\n+    end\n+end\n+\n+KeyIterator{JA}(d::JA) = KeyIterator{JA}(d)\n+\n+immutable IndexableIndexsets end\n+immutable NotIndexableIndexsets end\n+\n+function indexability(x::JuMPArray)\n+    allsetsindexable = true\n+    for i in  1:length(x.indexsets)\n+        if !method_exists(getindex, (typeof(x.indexsets[i]),))\n+            allsetsindexable = false\n+            break\n+        end\n+    end\n+\n+    if allsetsindexable\n+        IndexableIndexsets()\n+    else\n+        NotIndexableIndexsets()\n+    end\n+end\n+\n+Base.start(it::KeyIterator) = _start(it, indexability(it.x))\n+_start(it::KeyIterator, ::IndexableIndexsets) = start(it.x.innerArray)\n+_start(it::KeyIterator, ::NotIndexableIndexsets) = notindexable_start(it.x)\n+\n+@generated function notindexable_start{T,N,NT}(x::JuMPArray{T,N,NT})\n+    quote\n+        $(Expr(:tuple, 0, [:(start(x.indexsets[$i])) for i in 1:N]...))\n+    end\n end\n-Base.start(it::KeyIterator)   =  start(it.x.innerArray)\n-@generated __next{T,N,NT}(x::JuMPArray{T,N,NT}, k) =\n+\n+@generated function _next{T,N,NT}(x::JuMPArray{T,N,NT}, k::Tuple)\n+    quote\n+        $(Expr(:tuple, [:(next(x.indexsets[$i], k[$i+1])[1]) for i in 1:N]...))\n+    end\n+end\n+\n+function Base.next(it::KeyIterator, k::Tuple)\n+    cartesian_key = JuMPKey(_next(it.x, k))\n+    pos = -1\n+    for i in 1:it.dim\n+        if(!done(it.x.indexsets[i], next(it.x.indexsets[i], k[i+1])[2] ) )\n+            pos = i\n+            break\n+        end\n+    end\n+    if pos == - 1\n+        return cartesian_key, (1,1) #The second 1 is needed to ambiguity with ints","path":"src/JuMPContainer.jl","position":74,"original_position":74,"commit_id":"ee819c76f7831436fc2c3a39fa1b98927a0f664f","original_commit_id":"ee819c76f7831436fc2c3a39fa1b98927a0f664f","user":{"login":"IssamT","id":20793306,"avatar_url":"https://avatars.githubusercontent.com/u/20793306?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamT","html_url":"https://github.com/IssamT","followers_url":"https://api.github.com/users/IssamT/followers","following_url":"https://api.github.com/users/IssamT/following{/other_user}","gists_url":"https://api.github.com/users/IssamT/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamT/subscriptions","organizations_url":"https://api.github.com/users/IssamT/orgs","repos_url":"https://api.github.com/users/IssamT/repos","events_url":"https://api.github.com/users/IssamT/events{/privacy}","received_events_url":"https://api.github.com/users/IssamT/received_events","type":"User","site_admin":false},"body":"The first element of the tuple is used for indicating that we are done. The second 1 here is added because otherwise the dispatch of the function `next` fails and the function `next` with `Integer` state is called instead of the one with `Tuple` state","created_at":"2016-09-19T06:02:25Z","updated_at":"2016-09-19T06:02:25Z","html_url":"https://github.com/JuliaOpt/JuMP.jl/pull/836#discussion_r79330880","pull_request_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836","_links":{"self":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/comments/79330880"},"html":{"href":"https://github.com/JuliaOpt/JuMP.jl/pull/836#discussion_r79330880"},"pull_request":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836","id":82100434,"html_url":"https://github.com/JuliaOpt/JuMP.jl/pull/836","diff_url":"https://github.com/JuliaOpt/JuMP.jl/pull/836.diff","patch_url":"https://github.com/JuliaOpt/JuMP.jl/pull/836.patch","issue_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/836","number":836,"state":"open","locked":false,"title":"Fixing KeyIterator used for JuMPArray to work also when index sets are non indexable.","user":{"login":"IssamT","id":20793306,"avatar_url":"https://avatars.githubusercontent.com/u/20793306?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamT","html_url":"https://github.com/IssamT","followers_url":"https://api.github.com/users/IssamT/followers","following_url":"https://api.github.com/users/IssamT/following{/other_user}","gists_url":"https://api.github.com/users/IssamT/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamT/subscriptions","organizations_url":"https://api.github.com/users/IssamT/orgs","repos_url":"https://api.github.com/users/IssamT/repos","events_url":"https://api.github.com/users/IssamT/events{/privacy}","received_events_url":"https://api.github.com/users/IssamT/received_events","type":"User","site_admin":false},"body":"This just a beginning to solving issues raised #646 \r\n\r\nI think it is better to not merge it yet. Maybe just give some feedback especially I m pretty sure the iterator methods could be implemented better.\r\n\r\nThe new `KeyIterator` works fine as long as the **index sets** are iterable (including Iterators and `Set`s). They **do not need to be indexable anymore**\r\n\r\n","created_at":"2016-08-21T08:44:48Z","updated_at":"2016-09-19T06:02:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a853cb9d117818960cc65df7dc4186ff4475c879","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836/commits","review_comments_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836/comments","review_comment_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/836/comments","statuses_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/statuses/ee819c76f7831436fc2c3a39fa1b98927a0f664f","head":{"label":"IssamT:master","ref":"master","sha":"ee819c76f7831436fc2c3a39fa1b98927a0f664f","user":{"login":"IssamT","id":20793306,"avatar_url":"https://avatars.githubusercontent.com/u/20793306?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamT","html_url":"https://github.com/IssamT","followers_url":"https://api.github.com/users/IssamT/followers","following_url":"https://api.github.com/users/IssamT/following{/other_user}","gists_url":"https://api.github.com/users/IssamT/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamT/subscriptions","organizations_url":"https://api.github.com/users/IssamT/orgs","repos_url":"https://api.github.com/users/IssamT/repos","events_url":"https://api.github.com/users/IssamT/events{/privacy}","received_events_url":"https://api.github.com/users/IssamT/received_events","type":"User","site_admin":false},"repo":{"id":66158190,"name":"JuMP.jl","full_name":"IssamT/JuMP.jl","owner":{"login":"IssamT","id":20793306,"avatar_url":"https://avatars.githubusercontent.com/u/20793306?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamT","html_url":"https://github.com/IssamT","followers_url":"https://api.github.com/users/IssamT/followers","following_url":"https://api.github.com/users/IssamT/following{/other_user}","gists_url":"https://api.github.com/users/IssamT/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamT/subscriptions","organizations_url":"https://api.github.com/users/IssamT/orgs","repos_url":"https://api.github.com/users/IssamT/repos","events_url":"https://api.github.com/users/IssamT/events{/privacy}","received_events_url":"https://api.github.com/users/IssamT/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IssamT/JuMP.jl","description":"Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)","fork":true,"url":"https://api.github.com/repos/IssamT/JuMP.jl","forks_url":"https://api.github.com/repos/IssamT/JuMP.jl/forks","keys_url":"https://api.github.com/repos/IssamT/JuMP.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IssamT/JuMP.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IssamT/JuMP.jl/teams","hooks_url":"https://api.github.com/repos/IssamT/JuMP.jl/hooks","issue_events_url":"https://api.github.com/repos/IssamT/JuMP.jl/issues/events{/number}","events_url":"https://api.github.com/repos/IssamT/JuMP.jl/events","assignees_url":"https://api.github.com/repos/IssamT/JuMP.jl/assignees{/user}","branches_url":"https://api.github.com/repos/IssamT/JuMP.jl/branches{/branch}","tags_url":"https://api.github.com/repos/IssamT/JuMP.jl/tags","blobs_url":"https://api.github.com/repos/IssamT/JuMP.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IssamT/JuMP.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IssamT/JuMP.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/IssamT/JuMP.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IssamT/JuMP.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/IssamT/JuMP.jl/languages","stargazers_url":"https://api.github.com/repos/IssamT/JuMP.jl/stargazers","contributors_url":"https://api.github.com/repos/IssamT/JuMP.jl/contributors","subscribers_url":"https://api.github.com/repos/IssamT/JuMP.jl/subscribers","subscription_url":"https://api.github.com/repos/IssamT/JuMP.jl/subscription","commits_url":"https://api.github.com/repos/IssamT/JuMP.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/IssamT/JuMP.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/IssamT/JuMP.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/IssamT/JuMP.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/IssamT/JuMP.jl/contents/{+path}","compare_url":"https://api.github.com/repos/IssamT/JuMP.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IssamT/JuMP.jl/merges","archive_url":"https://api.github.com/repos/IssamT/JuMP.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IssamT/JuMP.jl/downloads","issues_url":"https://api.github.com/repos/IssamT/JuMP.jl/issues{/number}","pulls_url":"https://api.github.com/repos/IssamT/JuMP.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/IssamT/JuMP.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/IssamT/JuMP.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IssamT/JuMP.jl/labels{/name}","releases_url":"https://api.github.com/repos/IssamT/JuMP.jl/releases{/id}","deployments_url":"https://api.github.com/repos/IssamT/JuMP.jl/deployments","created_at":"2016-08-20T17:02:51Z","updated_at":"2016-08-20T17:02:52Z","pushed_at":"2016-09-12T11:11:40Z","git_url":"git://github.com/IssamT/JuMP.jl.git","ssh_url":"git@github.com:IssamT/JuMP.jl.git","clone_url":"https://github.com/IssamT/JuMP.jl.git","svn_url":"https://github.com/IssamT/JuMP.jl","homepage":"","size":6224,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JuliaOpt:master","ref":"master","sha":"1e77c97b198da17379c8c35e209ccadc73fb18a7","user":{"login":"JuliaOpt","id":5667382,"avatar_url":"https://avatars.githubusercontent.com/u/5667382?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaOpt","html_url":"https://github.com/JuliaOpt","followers_url":"https://api.github.com/users/JuliaOpt/followers","following_url":"https://api.github.com/users/JuliaOpt/following{/other_user}","gists_url":"https://api.github.com/users/JuliaOpt/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaOpt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaOpt/subscriptions","organizations_url":"https://api.github.com/users/JuliaOpt/orgs","repos_url":"https://api.github.com/users/JuliaOpt/repos","events_url":"https://api.github.com/users/JuliaOpt/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaOpt/received_events","type":"Organization","site_admin":false},"repo":{"id":6150069,"name":"JuMP.jl","full_name":"JuliaOpt/JuMP.jl","owner":{"login":"JuliaOpt","id":5667382,"avatar_url":"https://avatars.githubusercontent.com/u/5667382?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaOpt","html_url":"https://github.com/JuliaOpt","followers_url":"https://api.github.com/users/JuliaOpt/followers","following_url":"https://api.github.com/users/JuliaOpt/following{/other_user}","gists_url":"https://api.github.com/users/JuliaOpt/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaOpt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaOpt/subscriptions","organizations_url":"https://api.github.com/users/JuliaOpt/orgs","repos_url":"https://api.github.com/users/JuliaOpt/repos","events_url":"https://api.github.com/users/JuliaOpt/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaOpt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaOpt/JuMP.jl","description":"Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)","fork":false,"url":"https://api.github.com/repos/JuliaOpt/JuMP.jl","forks_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/forks","keys_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/teams","hooks_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/hooks","issue_events_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/events","assignees_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/tags","blobs_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/languages","stargazers_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/stargazers","contributors_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/contributors","subscribers_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/subscribers","subscription_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/subscription","commits_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/merges","archive_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/downloads","issues_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/labels{/name}","releases_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaOpt/JuMP.jl/deployments","created_at":"2012-10-10T00:34:45Z","updated_at":"2016-09-15T20:31:54Z","pushed_at":"2016-09-15T09:42:14Z","git_url":"git://github.com/JuliaOpt/JuMP.jl.git","ssh_url":"git@github.com:JuliaOpt/JuMP.jl.git","clone_url":"https://github.com/JuliaOpt/JuMP.jl.git","svn_url":"https://github.com/JuliaOpt/JuMP.jl","homepage":"","size":7670,"stargazers_count":273,"watchers_count":273,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":75,"mirror_url":null,"open_issues_count":72,"forks":75,"open_issues":72,"watchers":273,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836"},"html":{"href":"https://github.com/JuliaOpt/JuMP.jl/pull/836"},"issue":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/836"},"comments":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/issues/836/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/pulls/836/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaOpt/JuMP.jl/statuses/ee819c76f7831436fc2c3a39fa1b98927a0f664f"}}}}
{"actor":{"display_login":"IssamT"}}