{"action":"created","comment":{"url":"https://api.github.com/repos/scipy/scipy/pulls/comments/127973831","pull_request_review_id":50608341,"id":127973831,"diff_hunk":"@@ -1146,9 +1146,16 @@ def test_astype(self):\n         S = self.spmatrix(D)\n \n         for x in supported_dtypes:\n-            assert_equal(S.astype(x).dtype, D.astype(x).dtype)  # correct type\n-            assert_equal(S.astype(x).toarray(), D.astype(x))        # correct values\n-            assert_equal(S.astype(x).format, S.format)           # format preserved\n+            # Check correct casted\n+            D_casted = D.astype(x)\n+            for copy in (True, False):\n+                S_casted = S.astype(x, copy=copy)\n+                assert_equal(S_casted.dtype, D_casted.dtype)  # correct type\n+                assert_equal(S_casted.toarray(), D_casted)    # correct values\n+                assert_equal(S_casted.format, S.format)       # format preserved\n+            # Check correct copied\n+            assert S_casted.astype(x, copy=False) is S_casted\n+            assert S_casted.astype(x, copy=True) is not S_casted","path":"scipy/sparse/tests/test_base.py","position":16,"original_position":16,"commit_id":"59ce7a47cc625a2780126de277da306f849ae6f1","original_commit_id":"59ce7a47cc625a2780126de277da306f849ae6f1","user":{"login":"perimosocordiae","id":82855,"avatar_url":"https://avatars3.githubusercontent.com/u/82855?v=4","gravatar_id":"","url":"https://api.github.com/users/perimosocordiae","html_url":"https://github.com/perimosocordiae","followers_url":"https://api.github.com/users/perimosocordiae/followers","following_url":"https://api.github.com/users/perimosocordiae/following{/other_user}","gists_url":"https://api.github.com/users/perimosocordiae/gists{/gist_id}","starred_url":"https://api.github.com/users/perimosocordiae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/perimosocordiae/subscriptions","organizations_url":"https://api.github.com/users/perimosocordiae/orgs","repos_url":"https://api.github.com/users/perimosocordiae/repos","events_url":"https://api.github.com/users/perimosocordiae/events{/privacy}","received_events_url":"https://api.github.com/users/perimosocordiae/received_events","type":"User","site_admin":false},"body":"This doesn't necessarily catch the indices-sharing bug: the sparse matrix objects may be distinct but still share memory for some or all member arrays. To be absolutely sure, we could do something like:\r\n```python\r\nA = self.spmatrix(D)\r\nB = A.astype(float, copy=True)  #  A.dtype is complex, so this must cast\r\nassert_array_equal(A.indices, B.indices)\r\nA.indices[0] += 1\r\nassert_(A.indices[0] != B.indices[0])\r\n```","created_at":"2017-07-18T13:27:22Z","updated_at":"2017-07-18T13:27:22Z","html_url":"https://github.com/scipy/scipy/pull/7619#discussion_r127973831","pull_request_url":"https://api.github.com/repos/scipy/scipy/pulls/7619","_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments/127973831"},"html":{"href":"https://github.com/scipy/scipy/pull/7619#discussion_r127973831"},"pull_request":{"href":"https://api.github.com/repos/scipy/scipy/pulls/7619"}}},"pull_request":{"url":"https://api.github.com/repos/scipy/scipy/pulls/7619","id":130814592,"html_url":"https://github.com/scipy/scipy/pull/7619","diff_url":"https://github.com/scipy/scipy/pull/7619.diff","patch_url":"https://github.com/scipy/scipy/pull/7619.patch","issue_url":"https://api.github.com/repos/scipy/scipy/issues/7619","number":7619,"state":"open","locked":false,"title":"ENH: scipy.sparse.spmatrix.astype: casting and copy parameter added","user":{"login":"jor-","id":2393560,"avatar_url":"https://avatars3.githubusercontent.com/u/2393560?v=4","gravatar_id":"","url":"https://api.github.com/users/jor-","html_url":"https://github.com/jor-","followers_url":"https://api.github.com/users/jor-/followers","following_url":"https://api.github.com/users/jor-/following{/other_user}","gists_url":"https://api.github.com/users/jor-/gists{/gist_id}","starred_url":"https://api.github.com/users/jor-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jor-/subscriptions","organizations_url":"https://api.github.com/users/jor-/orgs","repos_url":"https://api.github.com/users/jor-/repos","events_url":"https://api.github.com/users/jor-/events{/privacy}","received_events_url":"https://api.github.com/users/jor-/received_events","type":"User","site_admin":false},"body":"I would like to add `casting` and `copy` parameters to the `astype` method of the sparse matrices in `scipy.sparse` analogous to NumPys `astype` method for arrays.","created_at":"2017-07-17T09:31:46Z","updated_at":"2017-07-18T13:27:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fe04633778a81b50a3b8526fa67e5b7bc3257bc8","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/scipy/scipy/pulls/7619/commits","review_comments_url":"https://api.github.com/repos/scipy/scipy/pulls/7619/comments","review_comment_url":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/7619/comments","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/59ce7a47cc625a2780126de277da306f849ae6f1","head":{"label":"jor-:ENH__scipy.sparse.spmatrix.astype__with_copy_argument","ref":"ENH__scipy.sparse.spmatrix.astype__with_copy_argument","sha":"59ce7a47cc625a2780126de277da306f849ae6f1","user":{"login":"jor-","id":2393560,"avatar_url":"https://avatars3.githubusercontent.com/u/2393560?v=4","gravatar_id":"","url":"https://api.github.com/users/jor-","html_url":"https://github.com/jor-","followers_url":"https://api.github.com/users/jor-/followers","following_url":"https://api.github.com/users/jor-/following{/other_user}","gists_url":"https://api.github.com/users/jor-/gists{/gist_id}","starred_url":"https://api.github.com/users/jor-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jor-/subscriptions","organizations_url":"https://api.github.com/users/jor-/orgs","repos_url":"https://api.github.com/users/jor-/repos","events_url":"https://api.github.com/users/jor-/events{/privacy}","received_events_url":"https://api.github.com/users/jor-/received_events","type":"User","site_admin":false},"repo":{"id":80020050,"name":"scipy","full_name":"jor-/scipy","owner":{"login":"jor-","id":2393560,"avatar_url":"https://avatars3.githubusercontent.com/u/2393560?v=4","gravatar_id":"","url":"https://api.github.com/users/jor-","html_url":"https://github.com/jor-","followers_url":"https://api.github.com/users/jor-/followers","following_url":"https://api.github.com/users/jor-/following{/other_user}","gists_url":"https://api.github.com/users/jor-/gists{/gist_id}","starred_url":"https://api.github.com/users/jor-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jor-/subscriptions","organizations_url":"https://api.github.com/users/jor-/orgs","repos_url":"https://api.github.com/users/jor-/repos","events_url":"https://api.github.com/users/jor-/events{/privacy}","received_events_url":"https://api.github.com/users/jor-/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jor-/scipy","description":"Scipy library main repository","fork":true,"url":"https://api.github.com/repos/jor-/scipy","forks_url":"https://api.github.com/repos/jor-/scipy/forks","keys_url":"https://api.github.com/repos/jor-/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jor-/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jor-/scipy/teams","hooks_url":"https://api.github.com/repos/jor-/scipy/hooks","issue_events_url":"https://api.github.com/repos/jor-/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/jor-/scipy/events","assignees_url":"https://api.github.com/repos/jor-/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/jor-/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/jor-/scipy/tags","blobs_url":"https://api.github.com/repos/jor-/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jor-/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jor-/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/jor-/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jor-/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/jor-/scipy/languages","stargazers_url":"https://api.github.com/repos/jor-/scipy/stargazers","contributors_url":"https://api.github.com/repos/jor-/scipy/contributors","subscribers_url":"https://api.github.com/repos/jor-/scipy/subscribers","subscription_url":"https://api.github.com/repos/jor-/scipy/subscription","commits_url":"https://api.github.com/repos/jor-/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/jor-/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/jor-/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/jor-/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/jor-/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/jor-/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jor-/scipy/merges","archive_url":"https://api.github.com/repos/jor-/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jor-/scipy/downloads","issues_url":"https://api.github.com/repos/jor-/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/jor-/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/jor-/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/jor-/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jor-/scipy/labels{/name}","releases_url":"https://api.github.com/repos/jor-/scipy/releases{/id}","deployments_url":"https://api.github.com/repos/jor-/scipy/deployments","created_at":"2017-01-25T14:07:12Z","updated_at":"2017-01-25T14:07:23Z","pushed_at":"2017-07-18T12:31:52Z","git_url":"git://github.com/jor-/scipy.git","ssh_url":"git@github.com:jor-/scipy.git","clone_url":"https://github.com/jor-/scipy.git","svn_url":"https://github.com/jor-/scipy","homepage":"http://scipy.org/scipylib/","size":65904,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"scipy:master","ref":"master","sha":"24156f1ffc154fffcb1ccf251cfcb074d4ebaf7f","user":{"login":"scipy","id":288277,"avatar_url":"https://avatars2.githubusercontent.com/u/288277?v=4","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"repo":{"id":1460385,"name":"scipy","full_name":"scipy/scipy","owner":{"login":"scipy","id":288277,"avatar_url":"https://avatars2.githubusercontent.com/u/288277?v=4","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scipy/scipy","description":"Scipy library main repository","fork":false,"url":"https://api.github.com/repos/scipy/scipy","forks_url":"https://api.github.com/repos/scipy/scipy/forks","keys_url":"https://api.github.com/repos/scipy/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scipy/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scipy/scipy/teams","hooks_url":"https://api.github.com/repos/scipy/scipy/hooks","issue_events_url":"https://api.github.com/repos/scipy/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/scipy/scipy/events","assignees_url":"https://api.github.com/repos/scipy/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/scipy/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/scipy/scipy/tags","blobs_url":"https://api.github.com/repos/scipy/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scipy/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scipy/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/scipy/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/scipy/scipy/languages","stargazers_url":"https://api.github.com/repos/scipy/scipy/stargazers","contributors_url":"https://api.github.com/repos/scipy/scipy/contributors","subscribers_url":"https://api.github.com/repos/scipy/scipy/subscribers","subscription_url":"https://api.github.com/repos/scipy/scipy/subscription","commits_url":"https://api.github.com/repos/scipy/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/scipy/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/scipy/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/scipy/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/scipy/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/scipy/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scipy/scipy/merges","archive_url":"https://api.github.com/repos/scipy/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scipy/scipy/downloads","issues_url":"https://api.github.com/repos/scipy/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/scipy/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/scipy/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/scipy/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scipy/scipy/labels{/name}","releases_url":"https://api.github.com/repos/scipy/scipy/releases{/id}","deployments_url":"https://api.github.com/repos/scipy/scipy/deployments","created_at":"2011-03-09T18:52:03Z","updated_at":"2017-07-18T09:03:02Z","pushed_at":"2017-07-18T13:26:35Z","git_url":"git://github.com/scipy/scipy.git","ssh_url":"git@github.com:scipy/scipy.git","clone_url":"https://github.com/scipy/scipy.git","svn_url":"https://github.com/scipy/scipy","homepage":"http://scipy.org/scipylib/","size":68030,"stargazers_count":3256,"watchers_count":3256,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1878,"mirror_url":null,"open_issues_count":1115,"forks":1878,"open_issues":1115,"watchers":3256,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/7619"},"html":{"href":"https://github.com/scipy/scipy/pull/7619"},"issue":{"href":"https://api.github.com/repos/scipy/scipy/issues/7619"},"comments":{"href":"https://api.github.com/repos/scipy/scipy/issues/7619/comments"},"review_comments":{"href":"https://api.github.com/repos/scipy/scipy/pulls/7619/comments"},"review_comment":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scipy/scipy/pulls/7619/commits"},"statuses":{"href":"https://api.github.com/repos/scipy/scipy/statuses/59ce7a47cc625a2780126de277da306f849ae6f1"}}}}
{"actor":{"display_login":"perimosocordiae"}}