{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/46093919","id":46093919,"diff_hunk":"@@ -863,3 +863,193 @@ If `dim` is specified, returns unique regions of the array `itr` along `dim`.\n         @nref $N A d->d == dim ? sort!(uniquerows) : (1:size(A, d))\n     end\n end\n+\n+\"\"\"\n+    C, ia, ib, ic = uniqueind(itr, dim)\n+\n+A function that operates similiarly to `unique(itr,dim)` but returns multiple\n+output arguments having the following properties:\n+\n+C - the unique elements of the array `itr` along the selected dimension `dim`\n+ia - a Vector{Int} of indices such that:\n+     `itr[ia] == C` returns `true` if `itr` is a one-dimensional array and `dim == 1`\n+     `itr[ia,:] == C` returns `true` if `itr` is a two-dimensional array and `dim == 1`\n+     `itr[:,ia] == C` returns `true` if `itr` is a two-dimensional array and `dim == 2`\n+     `itr[:,:,ia] == C` returns `true if `itr` is a three-dimensional array and `dim == 3`\n+     and so forth for higher dimensional arrays.\n+ib - a Vector{Vector{Int}} where each Vector{Int} contains the indices associated with the\n+     individual entries of `C` along the dimension `dim`\n+ic - A Vector{Int} of indices such that:\n+     `C[ic] == itr` returns `true` if `itr` is a one-dimensional array and `dim == 1`\n+     `C[ic,:] == itr` returns `true` if `itr` is a two-dimensional array and `dim == 1`\n+     `C[:,ic] == itr` returns `true` if `itr` is a two-dimensional array and `dim == 2`\n+     `C[:,:,ic] == itr` returns `true if `itr` is a three-dimensional array and `dim == 3`\n+     and so forth for higher dimensional arrays.\n+\n+Examples:\n+\n+julia> itr = [1;2;3;2;3;5;6;5;7;1];\n+julia> C, ia, ib, ic = uniqueind(itr,1)\n+([1,2,3,5,6,7],[1,2,3,6,7,9],[[1,10],[2,4],[3,5],[6,8],[7],[9]],[1,2,3,2,3,4,5,4,6,1])\n+julia> C[ic] == itr\n+true\n+julia> itr[ia] == C\n+true\n+julia> ib\n+6-element Array{Array{Int64,1},1}:\n+ [1,10]\n+ [2,4]\n+ [3,5]\n+ [6,8]\n+ [7]\n+ [9]\n+\n+julia> D = rand(Int,2,3,1);","path":"base/multidimensional.jl","position":45,"original_position":45,"commit_id":"cdfd617309413af93b7ce55b20ff762a4180068d","original_commit_id":"cdfd617309413af93b7ce55b20ff762a4180068d","user":{"login":"nalimilan","id":1120448,"avatar_url":"https://avatars.githubusercontent.com/u/1120448?v=3","gravatar_id":"","url":"https://api.github.com/users/nalimilan","html_url":"https://github.com/nalimilan","followers_url":"https://api.github.com/users/nalimilan/followers","following_url":"https://api.github.com/users/nalimilan/following{/other_user}","gists_url":"https://api.github.com/users/nalimilan/gists{/gist_id}","starred_url":"https://api.github.com/users/nalimilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nalimilan/subscriptions","organizations_url":"https://api.github.com/users/nalimilan/orgs","repos_url":"https://api.github.com/users/nalimilan/repos","events_url":"https://api.github.com/users/nalimilan/events{/privacy}","received_events_url":"https://api.github.com/users/nalimilan/received_events","type":"User","site_admin":false},"body":"I'd simply create arrays from fixed inputs. This has the advantage of allowing to use small positive integers, making the output easier to read.","created_at":"2015-11-29T15:54:56Z","updated_at":"2015-11-29T15:54:56Z","html_url":"https://github.com/JuliaLang/julia/pull/14142#discussion_r46093919","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/14142","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/46093919"},"html":{"href":"https://github.com/JuliaLang/julia/pull/14142#discussion_r46093919"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/14142"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/14142","id":51842037,"html_url":"https://github.com/JuliaLang/julia/pull/14142","diff_url":"https://github.com/JuliaLang/julia/pull/14142.diff","patch_url":"https://github.com/JuliaLang/julia/pull/14142.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/14142","number":14142,"state":"open","locked":false,"title":"Proposal for function uniqueind","user":{"login":"AndyGreenwell","id":11096243,"avatar_url":"https://avatars.githubusercontent.com/u/11096243?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyGreenwell","html_url":"https://github.com/AndyGreenwell","followers_url":"https://api.github.com/users/AndyGreenwell/followers","following_url":"https://api.github.com/users/AndyGreenwell/following{/other_user}","gists_url":"https://api.github.com/users/AndyGreenwell/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyGreenwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyGreenwell/subscriptions","organizations_url":"https://api.github.com/users/AndyGreenwell/orgs","repos_url":"https://api.github.com/users/AndyGreenwell/repos","events_url":"https://api.github.com/users/AndyGreenwell/events{/privacy}","received_events_url":"https://api.github.com/users/AndyGreenwell/received_events","type":"User","site_admin":false},"body":"This commit introduces a function `uniqueind` that is a slight modification of the existing [`unique`](https://github.com/JuliaLang/julia/blob/master/base/multidimensional.jl#L797) function accepting a `dim` argument but returns an additional three index vectors.\r\n\r\nThe outputs, as described in the docstring, are as follows:\r\n\r\n`C` - an array of the unique elements/rows/columns/hyperplanes of the input AbstractArray `itr` along the dimension `dim`\r\n\r\n`ia` - a vector of index values such that slice indexing into `itr` along dimension `dim` re-produces `C`. \r\n        For example, if `itr` is a vector, `itr[ia] == C` returns `true`\r\n\r\n`ib` - a vector of vectors of integers, where each vector of integers contains the index positions of the unique elements/rows/columns/hyperplanes within `C`\r\n\r\n`ic` - a vector of index values such that slice indexing into `C` along dimension `dim` re-produces `itr`\r\n        For example, if `itr` is a vector, `C[ic] == itr` returns `true`\r\n\r\nThe presence of `ia`, `ib`, and `ic` are meant to mimic the behaviors (but with potentially different output order) of various unique and group functions found in a few other technical computing languages.  This function provides all three of those outputs from a single function, while some other languages might only produce one or two arrays of index vectors from a given function.\r\n\r\nIt might be decided upon review that instead of a single function returning all four outputs, there should be multiple functions that return separate output arguments and more closely mimic similar functions from other languages.\r\n\r\nThis PR is in relation to issue #1845.","created_at":"2015-11-25T20:22:42Z","updated_at":"2015-11-29T15:54:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"064290797fe6946df799b246ba033414d49bd207","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/14142/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/14142/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/14142/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/cdfd617309413af93b7ce55b20ff762a4180068d","head":{"label":"AndyGreenwell:patch-1","ref":"patch-1","sha":"cdfd617309413af93b7ce55b20ff762a4180068d","user":{"login":"AndyGreenwell","id":11096243,"avatar_url":"https://avatars.githubusercontent.com/u/11096243?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyGreenwell","html_url":"https://github.com/AndyGreenwell","followers_url":"https://api.github.com/users/AndyGreenwell/followers","following_url":"https://api.github.com/users/AndyGreenwell/following{/other_user}","gists_url":"https://api.github.com/users/AndyGreenwell/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyGreenwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyGreenwell/subscriptions","organizations_url":"https://api.github.com/users/AndyGreenwell/orgs","repos_url":"https://api.github.com/users/AndyGreenwell/repos","events_url":"https://api.github.com/users/AndyGreenwell/events{/privacy}","received_events_url":"https://api.github.com/users/AndyGreenwell/received_events","type":"User","site_admin":false},"repo":{"id":31182190,"name":"julia","full_name":"AndyGreenwell/julia","owner":{"login":"AndyGreenwell","id":11096243,"avatar_url":"https://avatars.githubusercontent.com/u/11096243?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyGreenwell","html_url":"https://github.com/AndyGreenwell","followers_url":"https://api.github.com/users/AndyGreenwell/followers","following_url":"https://api.github.com/users/AndyGreenwell/following{/other_user}","gists_url":"https://api.github.com/users/AndyGreenwell/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyGreenwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyGreenwell/subscriptions","organizations_url":"https://api.github.com/users/AndyGreenwell/orgs","repos_url":"https://api.github.com/users/AndyGreenwell/repos","events_url":"https://api.github.com/users/AndyGreenwell/events{/privacy}","received_events_url":"https://api.github.com/users/AndyGreenwell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AndyGreenwell/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/AndyGreenwell/julia","forks_url":"https://api.github.com/repos/AndyGreenwell/julia/forks","keys_url":"https://api.github.com/repos/AndyGreenwell/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AndyGreenwell/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AndyGreenwell/julia/teams","hooks_url":"https://api.github.com/repos/AndyGreenwell/julia/hooks","issue_events_url":"https://api.github.com/repos/AndyGreenwell/julia/issues/events{/number}","events_url":"https://api.github.com/repos/AndyGreenwell/julia/events","assignees_url":"https://api.github.com/repos/AndyGreenwell/julia/assignees{/user}","branches_url":"https://api.github.com/repos/AndyGreenwell/julia/branches{/branch}","tags_url":"https://api.github.com/repos/AndyGreenwell/julia/tags","blobs_url":"https://api.github.com/repos/AndyGreenwell/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AndyGreenwell/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AndyGreenwell/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/AndyGreenwell/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AndyGreenwell/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/AndyGreenwell/julia/languages","stargazers_url":"https://api.github.com/repos/AndyGreenwell/julia/stargazers","contributors_url":"https://api.github.com/repos/AndyGreenwell/julia/contributors","subscribers_url":"https://api.github.com/repos/AndyGreenwell/julia/subscribers","subscription_url":"https://api.github.com/repos/AndyGreenwell/julia/subscription","commits_url":"https://api.github.com/repos/AndyGreenwell/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/AndyGreenwell/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/AndyGreenwell/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/AndyGreenwell/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/AndyGreenwell/julia/contents/{+path}","compare_url":"https://api.github.com/repos/AndyGreenwell/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AndyGreenwell/julia/merges","archive_url":"https://api.github.com/repos/AndyGreenwell/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AndyGreenwell/julia/downloads","issues_url":"https://api.github.com/repos/AndyGreenwell/julia/issues{/number}","pulls_url":"https://api.github.com/repos/AndyGreenwell/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/AndyGreenwell/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/AndyGreenwell/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AndyGreenwell/julia/labels{/name}","releases_url":"https://api.github.com/repos/AndyGreenwell/julia/releases{/id}","created_at":"2015-02-22T21:47:17Z","updated_at":"2015-02-22T21:47:22Z","pushed_at":"2015-11-26T01:54:53Z","git_url":"git://github.com/AndyGreenwell/julia.git","ssh_url":"git@github.com:AndyGreenwell/julia.git","clone_url":"https://github.com/AndyGreenwell/julia.git","svn_url":"https://github.com/AndyGreenwell/julia","homepage":"http://julialang.org/","size":88940,"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":"JuliaLang:master","ref":"master","sha":"944dcbd98f40acfab62667916c9208456fb0da9b","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","created_at":"2011-04-21T07:01:50Z","updated_at":"2015-11-29T12:38:55Z","pushed_at":"2015-11-29T13:52:19Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":114590,"stargazers_count":6371,"watchers_count":6371,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1418,"mirror_url":null,"open_issues_count":1516,"forks":1418,"open_issues":1516,"watchers":6371,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/14142"},"html":{"href":"https://github.com/JuliaLang/julia/pull/14142"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/14142"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/14142/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/14142/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/14142/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/cdfd617309413af93b7ce55b20ff762a4180068d"}}}}