{"action":"created","comment":{"url":"https://api.github.com/repos/pybind/pybind11/pulls/comments/114960395","pull_request_review_id":36466197,"id":114960395,"diff_hunk":"@@ -70,6 +70,13 @@ struct StringStruct {\n     std::array<char, 3> b;\n };\n \n+struct ArrayStruct {\n+    char a[3][4];","path":"tests/test_numpy_dtypes.cpp","position":5,"original_position":5,"commit_id":"eb0e17947a88bf16206bbaa84d0c57288fa5ce7f","original_commit_id":"eb0e17947a88bf16206bbaa84d0c57288fa5ce7f","user":{"login":"bmerry","id":1963944,"avatar_url":"https://avatars2.githubusercontent.com/u/1963944?v=3","gravatar_id":"","url":"https://api.github.com/users/bmerry","html_url":"https://github.com/bmerry","followers_url":"https://api.github.com/users/bmerry/followers","following_url":"https://api.github.com/users/bmerry/following{/other_user}","gists_url":"https://api.github.com/users/bmerry/gists{/gist_id}","starred_url":"https://api.github.com/users/bmerry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmerry/subscriptions","organizations_url":"https://api.github.com/users/bmerry/orgs","repos_url":"https://api.github.com/users/bmerry/repos","events_url":"https://api.github.com/users/bmerry/events{/privacy}","received_events_url":"https://api.github.com/users/bmerry/received_events","type":"User","site_admin":false},"body":"Zero-sized built-in arrays are illegal in C++ (GCC and Clang accept them, but std::is_array is false for them, so they can't easily be supported).\r\n\r\nstd::array<T, 0> is legal (C++ says so explicitly) and I've started writing some extra code to support them, but I now think they should be disallowed because they're causing all kinds of problems with numpy. `_dtype_from_pep3118` is *non-deterministic* with zero-sized arrays (I'm guessing because offsets are not unique so do not sort consistently). Given `^T{f:d:(0)I:empty:4x}`, it sometimes gives\r\n```\r\n[('d', '<f4'), ('empty', '<u4', (1,)), ('', 'V4')]\r\n```\r\nand sometimes gives\r\n```\r\n{'names':['d','pad0',''], 'formats':['<f4','V4',('<u4', (0,))], 'offsets':[0,4,4], 'itemsize':8}\r\n```\r\nIn the latter case, the dtype match sanity check fails, presumably because the padding is now named `pad0`.","created_at":"2017-05-05T09:30:40Z","updated_at":"2017-05-05T09:30:40Z","html_url":"https://github.com/pybind/pybind11/pull/832#discussion_r114960395","pull_request_url":"https://api.github.com/repos/pybind/pybind11/pulls/832","_links":{"self":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/comments/114960395"},"html":{"href":"https://github.com/pybind/pybind11/pull/832#discussion_r114960395"},"pull_request":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/832"}}},"pull_request":{"url":"https://api.github.com/repos/pybind/pybind11/pulls/832","id":118975768,"html_url":"https://github.com/pybind/pybind11/pull/832","diff_url":"https://github.com/pybind/pybind11/pull/832.diff","patch_url":"https://github.com/pybind/pybind11/pull/832.patch","issue_url":"https://api.github.com/repos/pybind/pybind11/issues/832","number":832,"state":"open","locked":false,"title":"Support arrays inside PYBIND11_NUMPY_DTYPE","user":{"login":"bmerry","id":1963944,"avatar_url":"https://avatars2.githubusercontent.com/u/1963944?v=3","gravatar_id":"","url":"https://api.github.com/users/bmerry","html_url":"https://github.com/bmerry","followers_url":"https://api.github.com/users/bmerry/followers","following_url":"https://api.github.com/users/bmerry/following{/other_user}","gists_url":"https://api.github.com/users/bmerry/gists{/gist_id}","starred_url":"https://api.github.com/users/bmerry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmerry/subscriptions","organizations_url":"https://api.github.com/users/bmerry/orgs","repos_url":"https://api.github.com/users/bmerry/repos","events_url":"https://api.github.com/users/bmerry/events{/privacy}","received_events_url":"https://api.github.com/users/bmerry/received_events","type":"User","site_admin":false},"body":"This implements pybind/pybind11#800.\r\n\r\nBoth C++ arrays and std::array are supported, including mixtures like\r\nstd::array<int, 2>[4]. In a multi-dimensional array of char, the last\r\ndimension is used to construct a numpy string type.\r\n\r\nThere are some things I'm not sure about:\r\n- Is there a better name for array_info? The \"array\" could easily be\r\n  misinterpreted as referring to py::array rather than std::array.\r\n- Should array_info be split into separate classes for the different\r\n  traits, or is it okay to have this uber traits class?\r\n- When constructing the dtype, the shape should really be a tuple rather\r\n  than a list, but I'm not sure how to dynamically construct a tuple (or\r\n  how to convert the list to a tuple). numpy seems to accept a list.\r\n- Should the array dtypes be registered in some way? At present two\r\n  structures embedding the same array type will each construct a\r\n  separate dtype object to represent that array type. That's already the\r\n  case for char[N] though.\r\n- Should I add tests to use an array type directly e.g.\r\n  py::array_t<int[2]>?","created_at":"2017-05-04T13:42:29Z","updated_at":"2017-05-05T09:30:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"715d69f6ddd42ff2ee1aa5e84a2516de3f36d97c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pybind/pybind11/pulls/832/commits","review_comments_url":"https://api.github.com/repos/pybind/pybind11/pulls/832/comments","review_comment_url":"https://api.github.com/repos/pybind/pybind11/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pybind/pybind11/issues/832/comments","statuses_url":"https://api.github.com/repos/pybind/pybind11/statuses/eb0e17947a88bf16206bbaa84d0c57288fa5ce7f","head":{"label":"bmerry:arrays-in-struct","ref":"arrays-in-struct","sha":"eb0e17947a88bf16206bbaa84d0c57288fa5ce7f","user":{"login":"bmerry","id":1963944,"avatar_url":"https://avatars2.githubusercontent.com/u/1963944?v=3","gravatar_id":"","url":"https://api.github.com/users/bmerry","html_url":"https://github.com/bmerry","followers_url":"https://api.github.com/users/bmerry/followers","following_url":"https://api.github.com/users/bmerry/following{/other_user}","gists_url":"https://api.github.com/users/bmerry/gists{/gist_id}","starred_url":"https://api.github.com/users/bmerry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmerry/subscriptions","organizations_url":"https://api.github.com/users/bmerry/orgs","repos_url":"https://api.github.com/users/bmerry/repos","events_url":"https://api.github.com/users/bmerry/events{/privacy}","received_events_url":"https://api.github.com/users/bmerry/received_events","type":"User","site_admin":false},"repo":{"id":90241139,"name":"pybind11","full_name":"bmerry/pybind11","owner":{"login":"bmerry","id":1963944,"avatar_url":"https://avatars2.githubusercontent.com/u/1963944?v=3","gravatar_id":"","url":"https://api.github.com/users/bmerry","html_url":"https://github.com/bmerry","followers_url":"https://api.github.com/users/bmerry/followers","following_url":"https://api.github.com/users/bmerry/following{/other_user}","gists_url":"https://api.github.com/users/bmerry/gists{/gist_id}","starred_url":"https://api.github.com/users/bmerry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmerry/subscriptions","organizations_url":"https://api.github.com/users/bmerry/orgs","repos_url":"https://api.github.com/users/bmerry/repos","events_url":"https://api.github.com/users/bmerry/events{/privacy}","received_events_url":"https://api.github.com/users/bmerry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bmerry/pybind11","description":"Seamless operability between C++11 and Python","fork":true,"url":"https://api.github.com/repos/bmerry/pybind11","forks_url":"https://api.github.com/repos/bmerry/pybind11/forks","keys_url":"https://api.github.com/repos/bmerry/pybind11/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bmerry/pybind11/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bmerry/pybind11/teams","hooks_url":"https://api.github.com/repos/bmerry/pybind11/hooks","issue_events_url":"https://api.github.com/repos/bmerry/pybind11/issues/events{/number}","events_url":"https://api.github.com/repos/bmerry/pybind11/events","assignees_url":"https://api.github.com/repos/bmerry/pybind11/assignees{/user}","branches_url":"https://api.github.com/repos/bmerry/pybind11/branches{/branch}","tags_url":"https://api.github.com/repos/bmerry/pybind11/tags","blobs_url":"https://api.github.com/repos/bmerry/pybind11/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bmerry/pybind11/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bmerry/pybind11/git/refs{/sha}","trees_url":"https://api.github.com/repos/bmerry/pybind11/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bmerry/pybind11/statuses/{sha}","languages_url":"https://api.github.com/repos/bmerry/pybind11/languages","stargazers_url":"https://api.github.com/repos/bmerry/pybind11/stargazers","contributors_url":"https://api.github.com/repos/bmerry/pybind11/contributors","subscribers_url":"https://api.github.com/repos/bmerry/pybind11/subscribers","subscription_url":"https://api.github.com/repos/bmerry/pybind11/subscription","commits_url":"https://api.github.com/repos/bmerry/pybind11/commits{/sha}","git_commits_url":"https://api.github.com/repos/bmerry/pybind11/git/commits{/sha}","comments_url":"https://api.github.com/repos/bmerry/pybind11/comments{/number}","issue_comment_url":"https://api.github.com/repos/bmerry/pybind11/issues/comments{/number}","contents_url":"https://api.github.com/repos/bmerry/pybind11/contents/{+path}","compare_url":"https://api.github.com/repos/bmerry/pybind11/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bmerry/pybind11/merges","archive_url":"https://api.github.com/repos/bmerry/pybind11/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bmerry/pybind11/downloads","issues_url":"https://api.github.com/repos/bmerry/pybind11/issues{/number}","pulls_url":"https://api.github.com/repos/bmerry/pybind11/pulls{/number}","milestones_url":"https://api.github.com/repos/bmerry/pybind11/milestones{/number}","notifications_url":"https://api.github.com/repos/bmerry/pybind11/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bmerry/pybind11/labels{/name}","releases_url":"https://api.github.com/repos/bmerry/pybind11/releases{/id}","deployments_url":"https://api.github.com/repos/bmerry/pybind11/deployments","created_at":"2017-05-04T08:43:50Z","updated_at":"2017-05-04T08:43:52Z","pushed_at":"2017-05-04T16:37:14Z","git_url":"git://github.com/bmerry/pybind11.git","ssh_url":"git@github.com:bmerry/pybind11.git","clone_url":"https://github.com/bmerry/pybind11.git","svn_url":"https://github.com/bmerry/pybind11","homepage":"","size":2740,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"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":"pybind:master","ref":"master","sha":"271b27ff1869d71e39f2e93af26ef4b941554f3d","user":{"login":"pybind","id":17565521,"avatar_url":"https://avatars1.githubusercontent.com/u/17565521?v=3","gravatar_id":"","url":"https://api.github.com/users/pybind","html_url":"https://github.com/pybind","followers_url":"https://api.github.com/users/pybind/followers","following_url":"https://api.github.com/users/pybind/following{/other_user}","gists_url":"https://api.github.com/users/pybind/gists{/gist_id}","starred_url":"https://api.github.com/users/pybind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pybind/subscriptions","organizations_url":"https://api.github.com/users/pybind/orgs","repos_url":"https://api.github.com/users/pybind/repos","events_url":"https://api.github.com/users/pybind/events{/privacy}","received_events_url":"https://api.github.com/users/pybind/received_events","type":"Organization","site_admin":false},"repo":{"id":38581626,"name":"pybind11","full_name":"pybind/pybind11","owner":{"login":"pybind","id":17565521,"avatar_url":"https://avatars1.githubusercontent.com/u/17565521?v=3","gravatar_id":"","url":"https://api.github.com/users/pybind","html_url":"https://github.com/pybind","followers_url":"https://api.github.com/users/pybind/followers","following_url":"https://api.github.com/users/pybind/following{/other_user}","gists_url":"https://api.github.com/users/pybind/gists{/gist_id}","starred_url":"https://api.github.com/users/pybind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pybind/subscriptions","organizations_url":"https://api.github.com/users/pybind/orgs","repos_url":"https://api.github.com/users/pybind/repos","events_url":"https://api.github.com/users/pybind/events{/privacy}","received_events_url":"https://api.github.com/users/pybind/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pybind/pybind11","description":"Seamless operability between C++11 and Python","fork":false,"url":"https://api.github.com/repos/pybind/pybind11","forks_url":"https://api.github.com/repos/pybind/pybind11/forks","keys_url":"https://api.github.com/repos/pybind/pybind11/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pybind/pybind11/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pybind/pybind11/teams","hooks_url":"https://api.github.com/repos/pybind/pybind11/hooks","issue_events_url":"https://api.github.com/repos/pybind/pybind11/issues/events{/number}","events_url":"https://api.github.com/repos/pybind/pybind11/events","assignees_url":"https://api.github.com/repos/pybind/pybind11/assignees{/user}","branches_url":"https://api.github.com/repos/pybind/pybind11/branches{/branch}","tags_url":"https://api.github.com/repos/pybind/pybind11/tags","blobs_url":"https://api.github.com/repos/pybind/pybind11/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pybind/pybind11/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pybind/pybind11/git/refs{/sha}","trees_url":"https://api.github.com/repos/pybind/pybind11/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pybind/pybind11/statuses/{sha}","languages_url":"https://api.github.com/repos/pybind/pybind11/languages","stargazers_url":"https://api.github.com/repos/pybind/pybind11/stargazers","contributors_url":"https://api.github.com/repos/pybind/pybind11/contributors","subscribers_url":"https://api.github.com/repos/pybind/pybind11/subscribers","subscription_url":"https://api.github.com/repos/pybind/pybind11/subscription","commits_url":"https://api.github.com/repos/pybind/pybind11/commits{/sha}","git_commits_url":"https://api.github.com/repos/pybind/pybind11/git/commits{/sha}","comments_url":"https://api.github.com/repos/pybind/pybind11/comments{/number}","issue_comment_url":"https://api.github.com/repos/pybind/pybind11/issues/comments{/number}","contents_url":"https://api.github.com/repos/pybind/pybind11/contents/{+path}","compare_url":"https://api.github.com/repos/pybind/pybind11/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pybind/pybind11/merges","archive_url":"https://api.github.com/repos/pybind/pybind11/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pybind/pybind11/downloads","issues_url":"https://api.github.com/repos/pybind/pybind11/issues{/number}","pulls_url":"https://api.github.com/repos/pybind/pybind11/pulls{/number}","milestones_url":"https://api.github.com/repos/pybind/pybind11/milestones{/number}","notifications_url":"https://api.github.com/repos/pybind/pybind11/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pybind/pybind11/labels{/name}","releases_url":"https://api.github.com/repos/pybind/pybind11/releases{/id}","deployments_url":"https://api.github.com/repos/pybind/pybind11/deployments","created_at":"2015-07-05T19:46:48Z","updated_at":"2017-05-05T06:04:42Z","pushed_at":"2017-05-04T16:37:16Z","git_url":"git://github.com/pybind/pybind11.git","ssh_url":"git@github.com:pybind/pybind11.git","clone_url":"https://github.com/pybind/pybind11.git","svn_url":"https://github.com/pybind/pybind11","homepage":"","size":2719,"stargazers_count":1976,"watchers_count":1976,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":230,"mirror_url":null,"open_issues_count":42,"forks":230,"open_issues":42,"watchers":1976,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/832"},"html":{"href":"https://github.com/pybind/pybind11/pull/832"},"issue":{"href":"https://api.github.com/repos/pybind/pybind11/issues/832"},"comments":{"href":"https://api.github.com/repos/pybind/pybind11/issues/832/comments"},"review_comments":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/832/comments"},"review_comment":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pybind/pybind11/pulls/832/commits"},"statuses":{"href":"https://api.github.com/repos/pybind/pybind11/statuses/eb0e17947a88bf16206bbaa84d0c57288fa5ce7f"}}}}
{"actor":{"display_login":"bmerry"}}