{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/17660","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/17660/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17660/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/17660/events","html_url":"https://github.com/JuliaLang/julia/pull/17660","id":168011081,"number":17660,"title":"Remove `full` from `similar(full(X), T, dims)` calls in generic concatenation methods","user":{"login":"Sacha0","id":5799177,"avatar_url":"https://avatars.githubusercontent.com/u/5799177?v=3","gravatar_id":"","url":"https://api.github.com/users/Sacha0","html_url":"https://github.com/Sacha0","followers_url":"https://api.github.com/users/Sacha0/followers","following_url":"https://api.github.com/users/Sacha0/following{/other_user}","gists_url":"https://api.github.com/users/Sacha0/gists{/gist_id}","starred_url":"https://api.github.com/users/Sacha0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sacha0/subscriptions","organizations_url":"https://api.github.com/users/Sacha0/orgs","repos_url":"https://api.github.com/users/Sacha0/repos","events_url":"https://api.github.com/users/Sacha0/events{/privacy}","received_events_url":"https://api.github.com/users/Sacha0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/sparse","name":"sparse","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-28T04:21:16Z","updated_at":"2016-07-28T07:01:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/17660","html_url":"https://github.com/JuliaLang/julia/pull/17660","diff_url":"https://github.com/JuliaLang/julia/pull/17660.diff","patch_url":"https://github.com/JuliaLang/julia/pull/17660.patch"},"body":"Towards reintroducing #17079, this pull request removes `full` from `similar(full(X), T, dims)` calls in the generic concatenation methods.\r\n\r\nFor an explanation of those `full` calls' purpose, see the first paragraph of https://github.com/JuliaLang/julia/pull/17079#issuecomment-234658313. See the preceding comments in that thread to understand why displacing those `full` calls is necessary to reintroduce #17079 .\r\n\r\nContrary to the expectation I expressed in that comment, removing those `full` calls appears to *improve* the degree to which the generic concatenation methods preserve structure:\r\n\r\n**\\<details\\>**The code in [this gist](https://gist.github.com/Sacha0/e7fdbb3dc61840e8df9c339cdc28f0a1#file-typemapconcat-jl) determines, for all pairwise combinations of dense vectors, dense matrices, sparse vectors, sparse matrices, special matrices, and triangular, symmetric, and hermitian annotations of both dense and sparse matrices, the return type of prototypical `vcat`, `hcat`, `hvcat`, and `cat` calls, and prints the mappings `catmeth(typeA, typeB) -> typeRet`. [This gist](https://gist.github.com/Sacha0/e7fdbb3dc61840e8df9c339cdc28f0a1#file-master-concattypemap-jl) provides the output of that code on master, and [this gist](https://gist.github.com/Sacha0/e7fdbb3dc61840e8df9c339cdc28f0a1#file-defull-concattypemap-jl) the same with this PR. [This gist](https://gist.github.com/Sacha0/e7fdbb3dc61840e8df9c339cdc28f0a1#file-diff-concattypemap-diff) provides the diff. **\\</details\\>**\r\n\r\n**tl;dr of details** To sum up the diff: When a sparse matrix or vector appears as the first argument in a concatenation call for which there exists no specialized method, on master the result is an `Array`, whereas with this PR the result remains sparse. Otherwise the results are identical.\r\n\r\nThis change makes #2326 more apparent in that, for example, `hcat(SparseMatrixCSC, Bidiagonal)` would now produce a sparse matrix whereas `hcat(Bidiagonal, SparseMatrixCSC)` would still produce a dense matrix. Modifying the `Union`s in [this and the accompanying method definitions](https://github.com/JuliaLang/julia/blob/e717ded47a55d3526a10207d8d75ae5c9ab9646f/base/sparse/sparsematrix.jl#L3234) to include special matrix types would resolve that issue for special matrix types. But the same cannot be done for the annotation types. And absent the ability to write methods with `Vararg`s in positions other than last, I do not immediately see a way to resolve that issue for annotation types. Making the change necessary to handle special matrix types while punting to #2326 on annotation types seems attractive. Other solutions? Thanks!"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/235815691","html_url":"https://github.com/JuliaLang/julia/pull/17660#issuecomment-235815691","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/17660","id":235815691,"user":{"login":"martinholters","id":15785210,"avatar_url":"https://avatars.githubusercontent.com/u/15785210?v=3","gravatar_id":"","url":"https://api.github.com/users/martinholters","html_url":"https://github.com/martinholters","followers_url":"https://api.github.com/users/martinholters/followers","following_url":"https://api.github.com/users/martinholters/following{/other_user}","gists_url":"https://api.github.com/users/martinholters/gists{/gist_id}","starred_url":"https://api.github.com/users/martinholters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinholters/subscriptions","organizations_url":"https://api.github.com/users/martinholters/orgs","repos_url":"https://api.github.com/users/martinholters/repos","events_url":"https://api.github.com/users/martinholters/events{/privacy}","received_events_url":"https://api.github.com/users/martinholters/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T07:01:37Z","updated_at":"2016-07-28T07:01:37Z","body":"I'd also like to point at #16740 (once I get to working on that again), see especially https://github.com/JuliaLang/julia/pull/16740#issuecomment-230715239, where `hcat` (and friends) basically just decide the desired return type and then forward to `typed_hcat` (or similar). Hopefully that simplifies writing specializations to pick the correct return type, and if that still fails, allows the caller to override it as needed."}}
{"actor":{"display_login":"martinholters"}}