{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/89247281","pull_request_review_id":9794502,"id":89247281,"diff_hunk":"@@ -1095,55 +1095,76 @@ end\n \n ## cat: general case\n \n-function cat(catdims, X...)\n-    T = promote_type(map(x->isa(x,AbstractArray) ? eltype(x) : typeof(x), X)...)\n-    cat_t(catdims, T, X...)\n-end\n-\n-function cat_t(catdims, typeC::Type, X...)\n-    catdims = collect(catdims)\n-    nargs = length(X)\n-    ndimsX = Int[isa(a,AbstractArray) ? ndims(a) : 0 for a in X]\n-    ndimsC = max(maximum(ndimsX), maximum(catdims))\n-    catsizes = zeros(Int,(nargs,length(catdims)))\n-    dims2cat = zeros(Int,ndimsC)\n-    for k = 1:length(catdims)\n-        dims2cat[catdims[k]]=k\n-    end\n-\n-    dimsC = Int[d <= ndimsX[1] ? size(X[1],d) : 1 for d=1:ndimsC]\n-    for k = 1:length(catdims)\n-        catsizes[1,k] = dimsC[catdims[k]]\n-    end\n-    for i = 2:nargs\n-        for d = 1:ndimsC\n-            currentdim = (d <= ndimsX[i] ? size(X[i],d) : 1)\n-            if dims2cat[d] != 0\n-                dimsC[d] += currentdim\n-                catsizes[i,dims2cat[d]] = currentdim\n-            elseif dimsC[d] != currentdim\n-                throw(DimensionMismatch(string(\"mismatch in dimension \",d,\n-                                               \" (expected \",dimsC[d],\n-                                               \" got \",currentdim,\")\")))\n+# helper functions\n+cat_size(A) = (1,)\n+cat_size(A::AbstractArray) = size(A)\n+cat_size(A, d) = 1\n+cat_size(A::AbstractArray, d) = size(A, d)\n+\n+cat_indices(A, d) = OneTo(1)\n+cat_indices(A::AbstractArray, d) = indices(A, d)\n+\n+cat_similar(A, T, shape) = Array{T}(shape)\n+cat_similar(A::AbstractArray, T, shape) = similar(A, T, shape)\n+\n+cat_shape(sifter, n, shape::Tuple) = shape\n+@inline cat_shape(sifter, n, shape::Tuple, nshape::Tuple, shapes::Tuple...) =\n+    cat_shape(sifter, n, _cshp(sifter, n, (), shape, nshape), shapes...)\n+\n+_cshp(::Tuple{}, n, out, ::Tuple{}, ::Tuple{}) = out\n+_cshp(sifter, n, out, ::Tuple{}, ::Tuple{}) = (out..., map(b->(b ? n : 1), sifter)...)\n+_cshp(::Tuple{}, n, out, shape, ::Tuple{}) = (out..., shape...)\n+_cshp(::Tuple{}, n, out, ::Tuple{}, nshape) = (out..., nshape...)\n+@inline _cshp(sifter, n, out, shape, ::Tuple{}) =\n+    _cshp(tail(sifter), n, (out..., shape[1]), tail(shape), ())\n+@inline _cshp(sifter, n, out, ::Tuple{}, nshape) =\n+    _cshp(tail(sifter), n, (out..., nshape[1]), (), tail(nshape))\n+@inline function _cshp(::Tuple{}, n, out, shape, nshape)\n+    next = _cs(length(out) + 1, false, shape[1], nshape[1])\n+    _cshp((), n, (out..., next), tail(shape), tail(nshape))\n+end\n+@inline function _cshp(sifter, n, out, shape, nshape)\n+    next = _cs(length(out) + 1, sifter[1], shape[1], nshape[1])\n+    _cshp(tail(sifter), n, (out..., next), tail(shape), tail(nshape))\n+end\n+\n+_cs(d, concat, a, b) = concat ? (a + b) : (a == b ? a : throw(DimensionMismatch(string(\"mismatch in dimension \", d, \" (expected \", a, \" got \", b, \")\"))))\n+\n+dims2sift{n}(::Type{Val{n}}) = ntuple(i -> (i == n), Val{n})\n+dims2sift(dims) = ntuple(i -> (i in dims), maximum(dims))\n+\n+cat(dims, X...) = cat_t(dims, promote_eltype(X...), X...)\n+\n+function cat_t(dims, T::Type, X...)\n+    sifter = dims2sift(dims)\n+    shape = cat_shape(sifter, length(X), (), map(cat_size, X)...)\n+    return _cat(T, shape, sifter, X...)\n+end\n+\n+function _cat(T::Type, shape, sifter, X...)\n+    N = length(shape)\n+    A = cat_similar(X[1], T, shape)","path":"base/abstractarray.jl","position":82,"original_position":82,"commit_id":"a261a76f7a288df9017bbeeaeacc01c5c3469c51","original_commit_id":"4c1e8b536480603331c0c0259d092a8e53854fc1","user":{"login":"pabloferz","id":8410335,"avatar_url":"https://avatars.githubusercontent.com/u/8410335?v=3","gravatar_id":"","url":"https://api.github.com/users/pabloferz","html_url":"https://github.com/pabloferz","followers_url":"https://api.github.com/users/pabloferz/followers","following_url":"https://api.github.com/users/pabloferz/following{/other_user}","gists_url":"https://api.github.com/users/pabloferz/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloferz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloferz/subscriptions","organizations_url":"https://api.github.com/users/pabloferz/orgs","repos_url":"https://api.github.com/users/pabloferz/repos","events_url":"https://api.github.com/users/pabloferz/events{/privacy}","received_events_url":"https://api.github.com/users/pabloferz/received_events","type":"User","site_admin":false},"body":"I'd like to handle that somehow, but I'd say that it would have to be addressed elsewhere. For one I have some ideas that would require the new sub-typing algorithm in place.","created_at":"2016-11-23T02:02:35Z","updated_at":"2016-11-23T02:02:35Z","html_url":"https://github.com/JuliaLang/julia/pull/19387#discussion_r89247281","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/19387","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/89247281"},"html":{"href":"https://github.com/JuliaLang/julia/pull/19387#discussion_r89247281"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/19387"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/19387","id":94871186,"html_url":"https://github.com/JuliaLang/julia/pull/19387","diff_url":"https://github.com/JuliaLang/julia/pull/19387.diff","patch_url":"https://github.com/JuliaLang/julia/pull/19387.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/19387","number":19387,"state":"open","locked":false,"title":"WIP: Type-stabilizing array concatenations","user":{"login":"pabloferz","id":8410335,"avatar_url":"https://avatars.githubusercontent.com/u/8410335?v=3","gravatar_id":"","url":"https://api.github.com/users/pabloferz","html_url":"https://github.com/pabloferz","followers_url":"https://api.github.com/users/pabloferz/followers","following_url":"https://api.github.com/users/pabloferz/following{/other_user}","gists_url":"https://api.github.com/users/pabloferz/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloferz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloferz/subscriptions","organizations_url":"https://api.github.com/users/pabloferz/orgs","repos_url":"https://api.github.com/users/pabloferz/repos","events_url":"https://api.github.com/users/pabloferz/events{/privacy}","received_events_url":"https://api.github.com/users/pabloferz/received_events","type":"User","site_admin":false},"body":"This is a rewriting of the some of the array concatenation methods to make them type stable. The PR adds a type stable version of `cat` (`cat{n}(::Type{Val{n}}, X...)`) while preserving the existing API (which cannot be made inferable, but should be just a bit faster than before anyway).\r\n\r\nI believe this could also be backported to 0.5.\r\n\r\nFixes #19038","created_at":"2016-11-22T18:27:54Z","updated_at":"2016-11-23T02:02:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"478195ec68e2524344674234dbb012565d8ae5de","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/19387/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/19387/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/19387/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/a261a76f7a288df9017bbeeaeacc01c5c3469c51","head":{"label":"pabloferz:pz/typestablecat","ref":"pz/typestablecat","sha":"a261a76f7a288df9017bbeeaeacc01c5c3469c51","user":{"login":"pabloferz","id":8410335,"avatar_url":"https://avatars.githubusercontent.com/u/8410335?v=3","gravatar_id":"","url":"https://api.github.com/users/pabloferz","html_url":"https://github.com/pabloferz","followers_url":"https://api.github.com/users/pabloferz/followers","following_url":"https://api.github.com/users/pabloferz/following{/other_user}","gists_url":"https://api.github.com/users/pabloferz/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloferz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloferz/subscriptions","organizations_url":"https://api.github.com/users/pabloferz/orgs","repos_url":"https://api.github.com/users/pabloferz/repos","events_url":"https://api.github.com/users/pabloferz/events{/privacy}","received_events_url":"https://api.github.com/users/pabloferz/received_events","type":"User","site_admin":false},"repo":{"id":36888587,"name":"julia","full_name":"pabloferz/julia","owner":{"login":"pabloferz","id":8410335,"avatar_url":"https://avatars.githubusercontent.com/u/8410335?v=3","gravatar_id":"","url":"https://api.github.com/users/pabloferz","html_url":"https://github.com/pabloferz","followers_url":"https://api.github.com/users/pabloferz/followers","following_url":"https://api.github.com/users/pabloferz/following{/other_user}","gists_url":"https://api.github.com/users/pabloferz/gists{/gist_id}","starred_url":"https://api.github.com/users/pabloferz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pabloferz/subscriptions","organizations_url":"https://api.github.com/users/pabloferz/orgs","repos_url":"https://api.github.com/users/pabloferz/repos","events_url":"https://api.github.com/users/pabloferz/events{/privacy}","received_events_url":"https://api.github.com/users/pabloferz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pabloferz/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/pabloferz/julia","forks_url":"https://api.github.com/repos/pabloferz/julia/forks","keys_url":"https://api.github.com/repos/pabloferz/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pabloferz/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pabloferz/julia/teams","hooks_url":"https://api.github.com/repos/pabloferz/julia/hooks","issue_events_url":"https://api.github.com/repos/pabloferz/julia/issues/events{/number}","events_url":"https://api.github.com/repos/pabloferz/julia/events","assignees_url":"https://api.github.com/repos/pabloferz/julia/assignees{/user}","branches_url":"https://api.github.com/repos/pabloferz/julia/branches{/branch}","tags_url":"https://api.github.com/repos/pabloferz/julia/tags","blobs_url":"https://api.github.com/repos/pabloferz/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pabloferz/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pabloferz/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/pabloferz/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pabloferz/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/pabloferz/julia/languages","stargazers_url":"https://api.github.com/repos/pabloferz/julia/stargazers","contributors_url":"https://api.github.com/repos/pabloferz/julia/contributors","subscribers_url":"https://api.github.com/repos/pabloferz/julia/subscribers","subscription_url":"https://api.github.com/repos/pabloferz/julia/subscription","commits_url":"https://api.github.com/repos/pabloferz/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/pabloferz/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/pabloferz/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/pabloferz/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/pabloferz/julia/contents/{+path}","compare_url":"https://api.github.com/repos/pabloferz/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pabloferz/julia/merges","archive_url":"https://api.github.com/repos/pabloferz/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pabloferz/julia/downloads","issues_url":"https://api.github.com/repos/pabloferz/julia/issues{/number}","pulls_url":"https://api.github.com/repos/pabloferz/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/pabloferz/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/pabloferz/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pabloferz/julia/labels{/name}","releases_url":"https://api.github.com/repos/pabloferz/julia/releases{/id}","deployments_url":"https://api.github.com/repos/pabloferz/julia/deployments","created_at":"2015-06-04T18:40:41Z","updated_at":"2016-01-12T10:40:47Z","pushed_at":"2016-11-23T01:38:46Z","git_url":"git://github.com/pabloferz/julia.git","ssh_url":"git@github.com:pabloferz/julia.git","clone_url":"https://github.com/pabloferz/julia.git","svn_url":"https://github.com/pabloferz/julia","homepage":"http://julialang.org/","size":98744,"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":"2a4b68adfd21d7fc21ff7a15629ffbb672651c56","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}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-11-23T01:39:58Z","pushed_at":"2016-11-23T01:38:49Z","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":431291,"stargazers_count":7832,"watchers_count":7832,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1838,"mirror_url":null,"open_issues_count":2195,"forks":1838,"open_issues":2195,"watchers":7832,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/19387"},"html":{"href":"https://github.com/JuliaLang/julia/pull/19387"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/19387"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/19387/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/19387/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/19387/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/a261a76f7a288df9017bbeeaeacc01c5c3469c51"}}}}
{"actor":{"display_login":"pabloferz"}}