{"action":"created","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/4157","labels_url":"https://api.github.com/repos/scipy/scipy/issues/4157/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/4157/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/4157/events","html_url":"https://github.com/scipy/scipy/issues/4157","id":49096177,"number":4157,"title":"Are scipy.sparse matrices supposed to be sequences?","user":{"login":"mgeier","id":705404,"avatar_url":"https://avatars.githubusercontent.com/u/705404?v=3","gravatar_id":"","url":"https://api.github.com/users/mgeier","html_url":"https://github.com/mgeier","followers_url":"https://api.github.com/users/mgeier/followers","following_url":"https://api.github.com/users/mgeier/following{/other_user}","gists_url":"https://api.github.com/users/mgeier/gists{/gist_id}","starred_url":"https://api.github.com/users/mgeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgeier/subscriptions","organizations_url":"https://api.github.com/users/mgeier/orgs","repos_url":"https://api.github.com/users/mgeier/repos","events_url":"https://api.github.com/users/mgeier/events{/privacy}","received_events_url":"https://api.github.com/users/mgeier/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2014-11-17T14:32:58Z","updated_at":"2015-09-17T09:37:25Z","closed_at":"2014-11-17T19:23:29Z","body":"I wanted to assign a `scipy.sparse` matrix (any storage type) to a NumPy array slice, but this didn't work because `PySequence_Check()` didn't recognize the sparse matrix as a sequence.\r\n\r\nIs this intentional?\r\n\r\nIMO sparse matrices are sequences and they can easily be used as such by means of `__getitem__()` and `__len__()`.\r\n\r\nSee also my related question on stackoverflow: http://stackoverflow.com/q/26934349/500098.\r\n\r\nI know that using sparse matrices as sequences might be slow in some cases, but it would allow writing more generic code.\r\n\r\nIt would especially allow `numpy.array(s)` and `numpy.asarray(s)` with `s` being a sparse matrix."},"comment":{"url":"https://api.github.com/repos/scipy/scipy/issues/comments/141024092","html_url":"https://github.com/scipy/scipy/issues/4157#issuecomment-141024092","issue_url":"https://api.github.com/repos/scipy/scipy/issues/4157","id":141024092,"user":{"login":"larsmans","id":335383,"avatar_url":"https://avatars.githubusercontent.com/u/335383?v=3","gravatar_id":"","url":"https://api.github.com/users/larsmans","html_url":"https://github.com/larsmans","followers_url":"https://api.github.com/users/larsmans/followers","following_url":"https://api.github.com/users/larsmans/following{/other_user}","gists_url":"https://api.github.com/users/larsmans/gists{/gist_id}","starred_url":"https://api.github.com/users/larsmans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsmans/subscriptions","organizations_url":"https://api.github.com/users/larsmans/orgs","repos_url":"https://api.github.com/users/larsmans/repos","events_url":"https://api.github.com/users/larsmans/events{/privacy}","received_events_url":"https://api.github.com/users/larsmans/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T09:37:25Z","updated_at":"2015-09-17T09:37:25Z","body":"> I think that disagrees with the Python mantra \"we're all consenting adult here\".\r\n\r\nConsenting adults is about being able to access private members and method. This is a case of \"explicit is better than implicit\" (and \"sparse is better than dense\", in a bit of [eisegesis](https://en.wikipedia.org/wiki/Eisegesis) ;). In my problems, matrices tend to grow have size (n,O(√n)) with O(n) non-zeros, so an implicit conversion would cause a superlinear memory blowup. I find that unacceptable."}}