{"action":"created","comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/25569653","id":25569653,"diff_hunk":"@@ -3619,12 +3640,57 @@ PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, npy_intp count)\n         }\n         PyArray_DIMS(ret)[0] = i + 1;\n \n-        if (((item = index2ptr(ret, i)) == NULL) ||\n-                (PyArray_DESCR(ret)->f->setitem(value, item, ret) == -1)) {\n-            Py_DECREF(value);\n-            goto done;\n+        if (ndim == 1) {\n+            if (((item = index2ptr(ret, i)) == NULL) ||\n+                    (PyArray_DESCR(ret)->f->setitem(value, item, ret) == -1)) {\n+                Py_DECREF(value);\n+                goto done;\n+            }\n+        }\n+        else {\n+            iter2 = PyObject_GetIter(value);","path":"numpy/core/src/multiarray/ctors.c","position":86,"original_position":86,"commit_id":"613caf7c75e5ce29187686b79e5cfc83eee98d33","original_commit_id":"613caf7c75e5ce29187686b79e5cfc83eee98d33","user":{"login":"charris","id":77272,"avatar_url":"https://avatars.githubusercontent.com/u/77272?v=3","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"body":"Is this what we want, or should we be checking for sequence types here also, and not just the first value? I'd almost prefer two separate loops, one for `ndim == 1` and the other for `ndim == 2`. Putting everything into one loop somewhat obfuscates the code.","created_at":"2015-03-01T18:24:01Z","updated_at":"2015-03-01T18:24:01Z","html_url":"https://github.com/numpy/numpy/pull/5340#discussion_r25569653","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/5340","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/25569653"},"html":{"href":"https://github.com/numpy/numpy/pull/5340#discussion_r25569653"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/5340"}}},"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/5340","id":25366216,"html_url":"https://github.com/numpy/numpy/pull/5340","diff_url":"https://github.com/numpy/numpy/pull/5340.diff","patch_url":"https://github.com/numpy/numpy/pull/5340.patch","issue_url":"https://api.github.com/repos/numpy/numpy/issues/5340","number":5340,"state":"open","locked":false,"title":"ENH: Make fromiter() accept iterators of sequences","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"body":"Tests were added.\r\n\r\nFixes #4791.\r\n\r\nThe example from http://mail.scipy.org/pipermail/numpy-discussion/2006-November/024747.html now works:\r\n```\r\n>>> from numpy import fromiter\r\n>>> fromiter(([x, x // 2, x+5] for x in range(1000)), dtype=int)\r\narray([[   0,    0,    5],\r\n       [   1,    0,    6],\r\n       [   2,    1,    7],\r\n       ..., \r\n       [ 997,  498, 1002],\r\n       [ 998,  499, 1003],\r\n       [ 999,  499, 1004]])\r\n>>> _.shape\r\n(1000, 3)\r\n```\r\n\r\nTODO:\r\n* [x] Go very carefully over the whole patch and make sure there are no memory leaks\r\n* [x] Add tests for corner cases, when the sequence lengths are not all the same in the iterator (it should raise an exception)","created_at":"2014-12-02T19:11:08Z","updated_at":"2015-03-01T18:24:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38a56075a5c41ca3b8eba55480bbee5de85c1182","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/numpy/numpy/pulls/5340/commits","review_comments_url":"https://api.github.com/repos/numpy/numpy/pulls/5340/comments","review_comment_url":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/5340/comments","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/613caf7c75e5ce29187686b79e5cfc83eee98d33","head":{"label":"certik:fromiter","ref":"fromiter","sha":"613caf7c75e5ce29187686b79e5cfc83eee98d33","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"repo":{"id":1379791,"name":"numpy","full_name":"certik/numpy","owner":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/certik/numpy","description":"Numpy main repository","fork":true,"url":"https://api.github.com/repos/certik/numpy","forks_url":"https://api.github.com/repos/certik/numpy/forks","keys_url":"https://api.github.com/repos/certik/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/certik/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/certik/numpy/teams","hooks_url":"https://api.github.com/repos/certik/numpy/hooks","issue_events_url":"https://api.github.com/repos/certik/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/certik/numpy/events","assignees_url":"https://api.github.com/repos/certik/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/certik/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/certik/numpy/tags","blobs_url":"https://api.github.com/repos/certik/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/certik/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/certik/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/certik/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/certik/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/certik/numpy/languages","stargazers_url":"https://api.github.com/repos/certik/numpy/stargazers","contributors_url":"https://api.github.com/repos/certik/numpy/contributors","subscribers_url":"https://api.github.com/repos/certik/numpy/subscribers","subscription_url":"https://api.github.com/repos/certik/numpy/subscription","commits_url":"https://api.github.com/repos/certik/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/certik/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/certik/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/certik/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/certik/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/certik/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/certik/numpy/merges","archive_url":"https://api.github.com/repos/certik/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/certik/numpy/downloads","issues_url":"https://api.github.com/repos/certik/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/certik/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/certik/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/certik/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/certik/numpy/labels{/name}","releases_url":"https://api.github.com/repos/certik/numpy/releases{/id}","created_at":"2011-02-17T20:48:41Z","updated_at":"2014-12-02T05:37:40Z","pushed_at":"2014-12-18T23:15:22Z","git_url":"git://github.com/certik/numpy.git","ssh_url":"git@github.com:certik/numpy.git","clone_url":"https://github.com/certik/numpy.git","svn_url":"https://github.com/certik/numpy","homepage":"http://www.numpy.org/","size":35369,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"numpy:master","ref":"master","sha":"a6b0917f180999293fdebbce4ae1728b4e3f45ff","user":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"repo":{"id":908607,"name":"numpy","full_name":"numpy/numpy","owner":{"login":"numpy","id":288276,"avatar_url":"https://avatars.githubusercontent.com/u/288276?v=3","gravatar_id":"","url":"https://api.github.com/users/numpy","html_url":"https://github.com/numpy","followers_url":"https://api.github.com/users/numpy/followers","following_url":"https://api.github.com/users/numpy/following{/other_user}","gists_url":"https://api.github.com/users/numpy/gists{/gist_id}","starred_url":"https://api.github.com/users/numpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/numpy/subscriptions","organizations_url":"https://api.github.com/users/numpy/orgs","repos_url":"https://api.github.com/users/numpy/repos","events_url":"https://api.github.com/users/numpy/events{/privacy}","received_events_url":"https://api.github.com/users/numpy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/numpy/numpy","description":"Numpy main repository","fork":false,"url":"https://api.github.com/repos/numpy/numpy","forks_url":"https://api.github.com/repos/numpy/numpy/forks","keys_url":"https://api.github.com/repos/numpy/numpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/numpy/numpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/numpy/numpy/teams","hooks_url":"https://api.github.com/repos/numpy/numpy/hooks","issue_events_url":"https://api.github.com/repos/numpy/numpy/issues/events{/number}","events_url":"https://api.github.com/repos/numpy/numpy/events","assignees_url":"https://api.github.com/repos/numpy/numpy/assignees{/user}","branches_url":"https://api.github.com/repos/numpy/numpy/branches{/branch}","tags_url":"https://api.github.com/repos/numpy/numpy/tags","blobs_url":"https://api.github.com/repos/numpy/numpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/numpy/numpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/numpy/numpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/numpy/numpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/numpy/numpy/statuses/{sha}","languages_url":"https://api.github.com/repos/numpy/numpy/languages","stargazers_url":"https://api.github.com/repos/numpy/numpy/stargazers","contributors_url":"https://api.github.com/repos/numpy/numpy/contributors","subscribers_url":"https://api.github.com/repos/numpy/numpy/subscribers","subscription_url":"https://api.github.com/repos/numpy/numpy/subscription","commits_url":"https://api.github.com/repos/numpy/numpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/numpy/numpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/numpy/numpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/numpy/numpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/numpy/numpy/contents/{+path}","compare_url":"https://api.github.com/repos/numpy/numpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/numpy/numpy/merges","archive_url":"https://api.github.com/repos/numpy/numpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/numpy/numpy/downloads","issues_url":"https://api.github.com/repos/numpy/numpy/issues{/number}","pulls_url":"https://api.github.com/repos/numpy/numpy/pulls{/number}","milestones_url":"https://api.github.com/repos/numpy/numpy/milestones{/number}","notifications_url":"https://api.github.com/repos/numpy/numpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/numpy/numpy/labels{/name}","releases_url":"https://api.github.com/repos/numpy/numpy/releases{/id}","created_at":"2010-09-13T23:02:39Z","updated_at":"2015-03-01T12:31:35Z","pushed_at":"2015-03-01T13:33:46Z","git_url":"git://github.com/numpy/numpy.git","ssh_url":"git@github.com:numpy/numpy.git","clone_url":"https://github.com/numpy/numpy.git","svn_url":"https://github.com/numpy/numpy","homepage":"http://www.numpy.org/","size":61440,"stargazers_count":1785,"watchers_count":1785,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":889,"mirror_url":null,"open_issues_count":797,"forks":889,"open_issues":797,"watchers":1785,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/5340"},"html":{"href":"https://github.com/numpy/numpy/pull/5340"},"issue":{"href":"https://api.github.com/repos/numpy/numpy/issues/5340"},"comments":{"href":"https://api.github.com/repos/numpy/numpy/issues/5340/comments"},"review_comments":{"href":"https://api.github.com/repos/numpy/numpy/pulls/5340/comments"},"review_comment":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/numpy/numpy/pulls/5340/commits"},"statuses":{"href":"https://api.github.com/repos/numpy/numpy/statuses/613caf7c75e5ce29187686b79e5cfc83eee98d33"}}}}