{"action":"created","comment":{"url":"https://api.github.com/repos/ContinuumIO/dask/pulls/comments/35062141","id":35062141,"diff_hunk":"@@ -11,6 +11,64 @@ def test_ones():\n     x = np.array(a)\n     assert (x == np.ones((10, 10), 'i4')).all()\n \n+def test_histogram():\n+    # Test for normal, flattened input\n+    n = 100\n+    v = da.random.random(n, chunks=10)\n+    \n+    bins = np.arange(0, 1.01, 0.01)\n+    (a1, b1) = da.histogram(v, bins=bins)\n+    (a2, b2) = np.histogram(v, bins=bins)\n+    \n+    def cmp_hist(a1, a2):\n+        # Check length is the same\n+        assert len(a1) == len(a2)\n+        assert len(b1) == len(b2)\n+        # Compare the arrays produced by dask and numpy\n+        assert (np.asarray(a1) == a2).all()\n+        assert (b1 == b2).all()\n+    \n+    # Check if the sum of the bins equals the number of samples\n+    assert a2.sum(axis=0) == n\n+    assert a1.sum(axis=0) == n\n+    cmp_hist(a1, a2)\n+    \n+    # Other input\n+    (a1, b1) = da.histogram(v, bins=10, range=(0, 1))\n+    (a2, b2) = np.histogram(v, bins=10, range=(0, 1))\n+    cmp_hist(a1, a2)\n+    \n+    # Check if return type is same as hist\n+    bins = np.arange(0, 11, 1, dtype='i4')\n+    (a1, b1) = da.histogram(v * 10, bins=bins)\n+    (a2, b2) = np.histogram(v * 10, bins=bins)\n+    cmp_hist(a1, a2)\n+    assert a1.dtype == a2.dtype\n+    \n+    # Check for extra args and shapes\n+    data = [(v, bins, ones(n, chunks=v.chunks) * 5),\n+            (da.random.random((50, 50), chunks=10), bins, ones((50, 50), chunks=10) * 5)]\n+    \n+    for v, bins, w in data:\n+        # density\n+        (a1, b1) = da.histogram(v, bins=bins, normed=True)\n+        (a2, b2) = np.histogram(v, bins=bins, normed=True)\n+        cmp_hist(a1, a2)\n+        \n+        # normed\n+        (a1, b1) = da.histogram(v, bins=bins, density=True)\n+        (a2, b2) = np.histogram(v, bins=bins, density=True)\n+        cmp_hist(a1, a2)\n+        \n+        # weights\n+        (a1, b1) = da.histogram(v, bins=bins, weights=w)\n+        (a2, b2) = np.histogram(v, bins=bins, weights=w)\n+        cmp_hist(a1, a2)\n+    \n+        (a1, b1) = da.histogram(v, bins=bins, weights=w, density=True)\n+        (a2, b2) = da.histogram(v, bins=bins, weights=w, density=True)\n+        cmp_hist(a1, a2)","path":"dask/array/tests/test_wrap.py","position":60,"original_position":60,"commit_id":"755455680a9c028ca00778650374ebdb3be6b08c","original_commit_id":"755455680a9c028ca00778650374ebdb3be6b08c","user":{"login":"mrocklin","id":306380,"avatar_url":"https://avatars.githubusercontent.com/u/306380?v=3","gravatar_id":"","url":"https://api.github.com/users/mrocklin","html_url":"https://github.com/mrocklin","followers_url":"https://api.github.com/users/mrocklin/followers","following_url":"https://api.github.com/users/mrocklin/following{/other_user}","gists_url":"https://api.github.com/users/mrocklin/gists{/gist_id}","starred_url":"https://api.github.com/users/mrocklin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrocklin/subscriptions","organizations_url":"https://api.github.com/users/mrocklin/orgs","repos_url":"https://api.github.com/users/mrocklin/repos","events_url":"https://api.github.com/users/mrocklin/events{/privacy}","received_events_url":"https://api.github.com/users/mrocklin/received_events","type":"User","site_admin":false},"body":"I suggest putting this in `dask.array.core` and using the `eq` function in `dask/array/test_array_core.py`, which does many of the same things as `cmp_hist`.","created_at":"2015-07-21T01:15:21Z","updated_at":"2015-07-21T01:15:21Z","html_url":"https://github.com/ContinuumIO/dask/pull/448#discussion_r35062141","pull_request_url":"https://api.github.com/repos/ContinuumIO/dask/pulls/448","_links":{"self":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/comments/35062141"},"html":{"href":"https://github.com/ContinuumIO/dask/pull/448#discussion_r35062141"},"pull_request":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/448"}}},"pull_request":{"url":"https://api.github.com/repos/ContinuumIO/dask/pulls/448","id":40412190,"html_url":"https://github.com/ContinuumIO/dask/pull/448","diff_url":"https://github.com/ContinuumIO/dask/pull/448.diff","patch_url":"https://github.com/ContinuumIO/dask/pull/448.patch","issue_url":"https://api.github.com/repos/ContinuumIO/dask/issues/448","number":448,"state":"open","locked":false,"title":"Adding a blocked version of numpy.histogram","user":{"login":"gabrielelanaro","id":239875,"avatar_url":"https://avatars.githubusercontent.com/u/239875?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrielelanaro","html_url":"https://github.com/gabrielelanaro","followers_url":"https://api.github.com/users/gabrielelanaro/followers","following_url":"https://api.github.com/users/gabrielelanaro/following{/other_user}","gists_url":"https://api.github.com/users/gabrielelanaro/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielelanaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielelanaro/subscriptions","organizations_url":"https://api.github.com/users/gabrielelanaro/orgs","repos_url":"https://api.github.com/users/gabrielelanaro/repos","events_url":"https://api.github.com/users/gabrielelanaro/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielelanaro/received_events","type":"User","site_admin":false},"body":"This follow the conversation from issue #431 ","created_at":"2015-07-21T00:33:44Z","updated_at":"2015-07-21T01:15:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34e66f544ffbe2e312258e8e1b58c2f59be11d10","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ContinuumIO/dask/pulls/448/commits","review_comments_url":"https://api.github.com/repos/ContinuumIO/dask/pulls/448/comments","review_comment_url":"https://api.github.com/repos/ContinuumIO/dask/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ContinuumIO/dask/issues/448/comments","statuses_url":"https://api.github.com/repos/ContinuumIO/dask/statuses/755455680a9c028ca00778650374ebdb3be6b08c","head":{"label":"gabrielelanaro:feature-hist","ref":"feature-hist","sha":"755455680a9c028ca00778650374ebdb3be6b08c","user":{"login":"gabrielelanaro","id":239875,"avatar_url":"https://avatars.githubusercontent.com/u/239875?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrielelanaro","html_url":"https://github.com/gabrielelanaro","followers_url":"https://api.github.com/users/gabrielelanaro/followers","following_url":"https://api.github.com/users/gabrielelanaro/following{/other_user}","gists_url":"https://api.github.com/users/gabrielelanaro/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielelanaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielelanaro/subscriptions","organizations_url":"https://api.github.com/users/gabrielelanaro/orgs","repos_url":"https://api.github.com/users/gabrielelanaro/repos","events_url":"https://api.github.com/users/gabrielelanaro/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielelanaro/received_events","type":"User","site_admin":false},"repo":{"id":39409703,"name":"dask","full_name":"gabrielelanaro/dask","owner":{"login":"gabrielelanaro","id":239875,"avatar_url":"https://avatars.githubusercontent.com/u/239875?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrielelanaro","html_url":"https://github.com/gabrielelanaro","followers_url":"https://api.github.com/users/gabrielelanaro/followers","following_url":"https://api.github.com/users/gabrielelanaro/following{/other_user}","gists_url":"https://api.github.com/users/gabrielelanaro/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielelanaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielelanaro/subscriptions","organizations_url":"https://api.github.com/users/gabrielelanaro/orgs","repos_url":"https://api.github.com/users/gabrielelanaro/repos","events_url":"https://api.github.com/users/gabrielelanaro/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielelanaro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gabrielelanaro/dask","description":"Task scheduling and blocked algorithms for parallel processing","fork":true,"url":"https://api.github.com/repos/gabrielelanaro/dask","forks_url":"https://api.github.com/repos/gabrielelanaro/dask/forks","keys_url":"https://api.github.com/repos/gabrielelanaro/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gabrielelanaro/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gabrielelanaro/dask/teams","hooks_url":"https://api.github.com/repos/gabrielelanaro/dask/hooks","issue_events_url":"https://api.github.com/repos/gabrielelanaro/dask/issues/events{/number}","events_url":"https://api.github.com/repos/gabrielelanaro/dask/events","assignees_url":"https://api.github.com/repos/gabrielelanaro/dask/assignees{/user}","branches_url":"https://api.github.com/repos/gabrielelanaro/dask/branches{/branch}","tags_url":"https://api.github.com/repos/gabrielelanaro/dask/tags","blobs_url":"https://api.github.com/repos/gabrielelanaro/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gabrielelanaro/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gabrielelanaro/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/gabrielelanaro/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gabrielelanaro/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/gabrielelanaro/dask/languages","stargazers_url":"https://api.github.com/repos/gabrielelanaro/dask/stargazers","contributors_url":"https://api.github.com/repos/gabrielelanaro/dask/contributors","subscribers_url":"https://api.github.com/repos/gabrielelanaro/dask/subscribers","subscription_url":"https://api.github.com/repos/gabrielelanaro/dask/subscription","commits_url":"https://api.github.com/repos/gabrielelanaro/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/gabrielelanaro/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/gabrielelanaro/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/gabrielelanaro/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/gabrielelanaro/dask/contents/{+path}","compare_url":"https://api.github.com/repos/gabrielelanaro/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gabrielelanaro/dask/merges","archive_url":"https://api.github.com/repos/gabrielelanaro/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gabrielelanaro/dask/downloads","issues_url":"https://api.github.com/repos/gabrielelanaro/dask/issues{/number}","pulls_url":"https://api.github.com/repos/gabrielelanaro/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/gabrielelanaro/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/gabrielelanaro/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gabrielelanaro/dask/labels{/name}","releases_url":"https://api.github.com/repos/gabrielelanaro/dask/releases{/id}","created_at":"2015-07-20T21:37:20Z","updated_at":"2015-07-20T21:37:21Z","pushed_at":"2015-07-21T00:40:41Z","git_url":"git://github.com/gabrielelanaro/dask.git","ssh_url":"git@github.com:gabrielelanaro/dask.git","clone_url":"https://github.com/gabrielelanaro/dask.git","svn_url":"https://github.com/gabrielelanaro/dask","homepage":"http://dask.pydata.org","size":10338,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"ContinuumIO:master","ref":"master","sha":"b5827ec358adfe5ec5b72be732aecc10e4b08da6","user":{"login":"ContinuumIO","id":1158637,"avatar_url":"https://avatars.githubusercontent.com/u/1158637?v=3","gravatar_id":"","url":"https://api.github.com/users/ContinuumIO","html_url":"https://github.com/ContinuumIO","followers_url":"https://api.github.com/users/ContinuumIO/followers","following_url":"https://api.github.com/users/ContinuumIO/following{/other_user}","gists_url":"https://api.github.com/users/ContinuumIO/gists{/gist_id}","starred_url":"https://api.github.com/users/ContinuumIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ContinuumIO/subscriptions","organizations_url":"https://api.github.com/users/ContinuumIO/orgs","repos_url":"https://api.github.com/users/ContinuumIO/repos","events_url":"https://api.github.com/users/ContinuumIO/events{/privacy}","received_events_url":"https://api.github.com/users/ContinuumIO/received_events","type":"Organization","site_admin":false},"repo":{"id":28782747,"name":"dask","full_name":"ContinuumIO/dask","owner":{"login":"ContinuumIO","id":1158637,"avatar_url":"https://avatars.githubusercontent.com/u/1158637?v=3","gravatar_id":"","url":"https://api.github.com/users/ContinuumIO","html_url":"https://github.com/ContinuumIO","followers_url":"https://api.github.com/users/ContinuumIO/followers","following_url":"https://api.github.com/users/ContinuumIO/following{/other_user}","gists_url":"https://api.github.com/users/ContinuumIO/gists{/gist_id}","starred_url":"https://api.github.com/users/ContinuumIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ContinuumIO/subscriptions","organizations_url":"https://api.github.com/users/ContinuumIO/orgs","repos_url":"https://api.github.com/users/ContinuumIO/repos","events_url":"https://api.github.com/users/ContinuumIO/events{/privacy}","received_events_url":"https://api.github.com/users/ContinuumIO/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ContinuumIO/dask","description":"Task scheduling and blocked algorithms for parallel processing","fork":false,"url":"https://api.github.com/repos/ContinuumIO/dask","forks_url":"https://api.github.com/repos/ContinuumIO/dask/forks","keys_url":"https://api.github.com/repos/ContinuumIO/dask/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ContinuumIO/dask/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ContinuumIO/dask/teams","hooks_url":"https://api.github.com/repos/ContinuumIO/dask/hooks","issue_events_url":"https://api.github.com/repos/ContinuumIO/dask/issues/events{/number}","events_url":"https://api.github.com/repos/ContinuumIO/dask/events","assignees_url":"https://api.github.com/repos/ContinuumIO/dask/assignees{/user}","branches_url":"https://api.github.com/repos/ContinuumIO/dask/branches{/branch}","tags_url":"https://api.github.com/repos/ContinuumIO/dask/tags","blobs_url":"https://api.github.com/repos/ContinuumIO/dask/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ContinuumIO/dask/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ContinuumIO/dask/git/refs{/sha}","trees_url":"https://api.github.com/repos/ContinuumIO/dask/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ContinuumIO/dask/statuses/{sha}","languages_url":"https://api.github.com/repos/ContinuumIO/dask/languages","stargazers_url":"https://api.github.com/repos/ContinuumIO/dask/stargazers","contributors_url":"https://api.github.com/repos/ContinuumIO/dask/contributors","subscribers_url":"https://api.github.com/repos/ContinuumIO/dask/subscribers","subscription_url":"https://api.github.com/repos/ContinuumIO/dask/subscription","commits_url":"https://api.github.com/repos/ContinuumIO/dask/commits{/sha}","git_commits_url":"https://api.github.com/repos/ContinuumIO/dask/git/commits{/sha}","comments_url":"https://api.github.com/repos/ContinuumIO/dask/comments{/number}","issue_comment_url":"https://api.github.com/repos/ContinuumIO/dask/issues/comments{/number}","contents_url":"https://api.github.com/repos/ContinuumIO/dask/contents/{+path}","compare_url":"https://api.github.com/repos/ContinuumIO/dask/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ContinuumIO/dask/merges","archive_url":"https://api.github.com/repos/ContinuumIO/dask/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ContinuumIO/dask/downloads","issues_url":"https://api.github.com/repos/ContinuumIO/dask/issues{/number}","pulls_url":"https://api.github.com/repos/ContinuumIO/dask/pulls{/number}","milestones_url":"https://api.github.com/repos/ContinuumIO/dask/milestones{/number}","notifications_url":"https://api.github.com/repos/ContinuumIO/dask/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ContinuumIO/dask/labels{/name}","releases_url":"https://api.github.com/repos/ContinuumIO/dask/releases{/id}","created_at":"2015-01-04T18:50:00Z","updated_at":"2015-07-20T21:47:21Z","pushed_at":"2015-07-21T00:40:41Z","git_url":"git://github.com/ContinuumIO/dask.git","ssh_url":"git@github.com:ContinuumIO/dask.git","clone_url":"https://github.com/ContinuumIO/dask.git","svn_url":"https://github.com/ContinuumIO/dask","homepage":"http://dask.pydata.org","size":10338,"stargazers_count":218,"watchers_count":218,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":68,"forks":40,"open_issues":68,"watchers":218,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/448"},"html":{"href":"https://github.com/ContinuumIO/dask/pull/448"},"issue":{"href":"https://api.github.com/repos/ContinuumIO/dask/issues/448"},"comments":{"href":"https://api.github.com/repos/ContinuumIO/dask/issues/448/comments"},"review_comments":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/448/comments"},"review_comment":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ContinuumIO/dask/pulls/448/commits"},"statuses":{"href":"https://api.github.com/repos/ContinuumIO/dask/statuses/755455680a9c028ca00778650374ebdb3be6b08c"}}}}