{"action":"opened","number":734,"pull_request":{"url":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734","id":29856085,"html_url":"https://github.com/mdtraj/mdtraj/pull/734","diff_url":"https://github.com/mdtraj/mdtraj/pull/734.diff","patch_url":"https://github.com/mdtraj/mdtraj/pull/734.patch","issue_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/734","number":734,"state":"open","locked":false,"title":"[ENH] Faster histogram","user":{"login":"ctk3b","id":3527431,"avatar_url":"https://avatars.githubusercontent.com/u/3527431?v=3","gravatar_id":"","url":"https://api.github.com/users/ctk3b","html_url":"https://github.com/ctk3b","followers_url":"https://api.github.com/users/ctk3b/followers","following_url":"https://api.github.com/users/ctk3b/following{/other_user}","gists_url":"https://api.github.com/users/ctk3b/gists{/gist_id}","starred_url":"https://api.github.com/users/ctk3b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctk3b/subscriptions","organizations_url":"https://api.github.com/users/ctk3b/orgs","repos_url":"https://api.github.com/users/ctk3b/repos","events_url":"https://api.github.com/users/ctk3b/events{/privacy}","received_events_url":"https://api.github.com/users/ctk3b/received_events","type":"User","site_admin":false},"body":"The current RDF code spends ~80% of its time in the histogram on my laptop so I figured I'd try my hand at writing a faster one (is this surprising/suspicious or is your distance code just that awesome?).\r\n\r\nFrom some quick timings, this histogram is a ~10x faster for the RDF use case:\r\n```python\r\nIn [8]: a = np.random.rand(10000000)\r\n\r\nIn [9]:  %timeit np.histogram(a, bins=100)\r\n1 loops, best of 3: 928 ms per loop\r\n\r\nIn [10]: %timeit _numericutils._histogram(a, bins=100)\r\n10 loops, best of 3: 83.6 ms per loop\r\n\r\nIn [11]: a = np.random.rand(100000000)\r\n\r\nIn [12]:  %timeit np.histogram(a, bins=100)\r\n1 loops, best of 3: 8.91 s per loop\r\n\r\nIn [13]: %timeit _numericutils._histogram(a, bins=100)\r\n1 loops, best of 3: 975 ms per loop\r\n```\r\n\r\nThat being said, this is my first time dabbling with cython and I don't write a lot of C/C++ so I've got a few questions:\r\n* First and foremost, do you want something like this in your code base?\r\n* If yes, do my file structure and function names make sense to you? Any conventions that I'm doing a terrible injustice to?\r\n* I've tried to reproduce the behavior of the numpy histogram with the exception of renaming the `range` arg to `bin_range`. The PR also includes all of the unit tests that numpy uses but modified to also check that the results are equal to those produced by numpy. Any objections to this approach and/or that particular change?\r\n\r\nOther notes/TODO's:\r\n* In `test_f32_rounding()` There is a slight difference (out to ~4-5 decimals) in the returned edges as compared to numpy. Still need to identify where this is coming from and fix it. The actual values in the histogram appear to be consistent, however, for the tests I've run so far.\r\n* I have yet to implement the numpy functionality provided by the args `normed`, `weights` and `density` because there wasn't an immediate need.\r\n* The current code could easily just be regular cython without further wrapping but I figured it may be worthwhile to keep the option open for some kind of SIMD acceleration (which is a bit [tricky for histograms](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.80.9041&rep=rep1&type=pdf)). Might also make it easier to add some OpenMP threading to accumulate sub-histograms but that can be done in cython too (some potential [code](https://github.com/kif/pyFAI/blob/master/src/histogram_omp.pyx) to borrow from).","created_at":"2015-02-23T23:16:19Z","updated_at":"2015-02-23T23:16:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734/commits","review_comments_url":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734/comments","review_comment_url":"https://api.github.com/repos/mdtraj/mdtraj/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/734/comments","statuses_url":"https://api.github.com/repos/mdtraj/mdtraj/statuses/83c37d2be515d1f90d34c5e12579ada7e0b89d25","head":{"label":"ctk3b:fast_histogram","ref":"fast_histogram","sha":"83c37d2be515d1f90d34c5e12579ada7e0b89d25","user":{"login":"ctk3b","id":3527431,"avatar_url":"https://avatars.githubusercontent.com/u/3527431?v=3","gravatar_id":"","url":"https://api.github.com/users/ctk3b","html_url":"https://github.com/ctk3b","followers_url":"https://api.github.com/users/ctk3b/followers","following_url":"https://api.github.com/users/ctk3b/following{/other_user}","gists_url":"https://api.github.com/users/ctk3b/gists{/gist_id}","starred_url":"https://api.github.com/users/ctk3b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctk3b/subscriptions","organizations_url":"https://api.github.com/users/ctk3b/orgs","repos_url":"https://api.github.com/users/ctk3b/repos","events_url":"https://api.github.com/users/ctk3b/events{/privacy}","received_events_url":"https://api.github.com/users/ctk3b/received_events","type":"User","site_admin":false},"repo":{"id":30364279,"name":"mdtraj","full_name":"ctk3b/mdtraj","owner":{"login":"ctk3b","id":3527431,"avatar_url":"https://avatars.githubusercontent.com/u/3527431?v=3","gravatar_id":"","url":"https://api.github.com/users/ctk3b","html_url":"https://github.com/ctk3b","followers_url":"https://api.github.com/users/ctk3b/followers","following_url":"https://api.github.com/users/ctk3b/following{/other_user}","gists_url":"https://api.github.com/users/ctk3b/gists{/gist_id}","starred_url":"https://api.github.com/users/ctk3b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctk3b/subscriptions","organizations_url":"https://api.github.com/users/ctk3b/orgs","repos_url":"https://api.github.com/users/ctk3b/repos","events_url":"https://api.github.com/users/ctk3b/events{/privacy}","received_events_url":"https://api.github.com/users/ctk3b/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ctk3b/mdtraj","description":"A modern, open library for the analysis of molecular dynamics trajectories","fork":true,"url":"https://api.github.com/repos/ctk3b/mdtraj","forks_url":"https://api.github.com/repos/ctk3b/mdtraj/forks","keys_url":"https://api.github.com/repos/ctk3b/mdtraj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ctk3b/mdtraj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ctk3b/mdtraj/teams","hooks_url":"https://api.github.com/repos/ctk3b/mdtraj/hooks","issue_events_url":"https://api.github.com/repos/ctk3b/mdtraj/issues/events{/number}","events_url":"https://api.github.com/repos/ctk3b/mdtraj/events","assignees_url":"https://api.github.com/repos/ctk3b/mdtraj/assignees{/user}","branches_url":"https://api.github.com/repos/ctk3b/mdtraj/branches{/branch}","tags_url":"https://api.github.com/repos/ctk3b/mdtraj/tags","blobs_url":"https://api.github.com/repos/ctk3b/mdtraj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ctk3b/mdtraj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ctk3b/mdtraj/git/refs{/sha}","trees_url":"https://api.github.com/repos/ctk3b/mdtraj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ctk3b/mdtraj/statuses/{sha}","languages_url":"https://api.github.com/repos/ctk3b/mdtraj/languages","stargazers_url":"https://api.github.com/repos/ctk3b/mdtraj/stargazers","contributors_url":"https://api.github.com/repos/ctk3b/mdtraj/contributors","subscribers_url":"https://api.github.com/repos/ctk3b/mdtraj/subscribers","subscription_url":"https://api.github.com/repos/ctk3b/mdtraj/subscription","commits_url":"https://api.github.com/repos/ctk3b/mdtraj/commits{/sha}","git_commits_url":"https://api.github.com/repos/ctk3b/mdtraj/git/commits{/sha}","comments_url":"https://api.github.com/repos/ctk3b/mdtraj/comments{/number}","issue_comment_url":"https://api.github.com/repos/ctk3b/mdtraj/issues/comments{/number}","contents_url":"https://api.github.com/repos/ctk3b/mdtraj/contents/{+path}","compare_url":"https://api.github.com/repos/ctk3b/mdtraj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ctk3b/mdtraj/merges","archive_url":"https://api.github.com/repos/ctk3b/mdtraj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ctk3b/mdtraj/downloads","issues_url":"https://api.github.com/repos/ctk3b/mdtraj/issues{/number}","pulls_url":"https://api.github.com/repos/ctk3b/mdtraj/pulls{/number}","milestones_url":"https://api.github.com/repos/ctk3b/mdtraj/milestones{/number}","notifications_url":"https://api.github.com/repos/ctk3b/mdtraj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ctk3b/mdtraj/labels{/name}","releases_url":"https://api.github.com/repos/ctk3b/mdtraj/releases{/id}","created_at":"2015-02-05T16:03:11Z","updated_at":"2015-02-23T13:18:52Z","pushed_at":"2015-02-23T23:13:04Z","git_url":"git://github.com/ctk3b/mdtraj.git","ssh_url":"git@github.com:ctk3b/mdtraj.git","clone_url":"https://github.com/ctk3b/mdtraj.git","svn_url":"https://github.com/ctk3b/mdtraj","homepage":"www.mdtraj.org","size":29355,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mdtraj:master","ref":"master","sha":"e463d6728d66d90edf05ab792e6578983e372b8a","user":{"login":"mdtraj","id":9259532,"avatar_url":"https://avatars.githubusercontent.com/u/9259532?v=3","gravatar_id":"","url":"https://api.github.com/users/mdtraj","html_url":"https://github.com/mdtraj","followers_url":"https://api.github.com/users/mdtraj/followers","following_url":"https://api.github.com/users/mdtraj/following{/other_user}","gists_url":"https://api.github.com/users/mdtraj/gists{/gist_id}","starred_url":"https://api.github.com/users/mdtraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdtraj/subscriptions","organizations_url":"https://api.github.com/users/mdtraj/orgs","repos_url":"https://api.github.com/users/mdtraj/repos","events_url":"https://api.github.com/users/mdtraj/events{/privacy}","received_events_url":"https://api.github.com/users/mdtraj/received_events","type":"Organization","site_admin":false},"repo":{"id":6604361,"name":"mdtraj","full_name":"mdtraj/mdtraj","owner":{"login":"mdtraj","id":9259532,"avatar_url":"https://avatars.githubusercontent.com/u/9259532?v=3","gravatar_id":"","url":"https://api.github.com/users/mdtraj","html_url":"https://github.com/mdtraj","followers_url":"https://api.github.com/users/mdtraj/followers","following_url":"https://api.github.com/users/mdtraj/following{/other_user}","gists_url":"https://api.github.com/users/mdtraj/gists{/gist_id}","starred_url":"https://api.github.com/users/mdtraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdtraj/subscriptions","organizations_url":"https://api.github.com/users/mdtraj/orgs","repos_url":"https://api.github.com/users/mdtraj/repos","events_url":"https://api.github.com/users/mdtraj/events{/privacy}","received_events_url":"https://api.github.com/users/mdtraj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mdtraj/mdtraj","description":"A modern, open library for the analysis of molecular dynamics trajectories","fork":false,"url":"https://api.github.com/repos/mdtraj/mdtraj","forks_url":"https://api.github.com/repos/mdtraj/mdtraj/forks","keys_url":"https://api.github.com/repos/mdtraj/mdtraj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdtraj/mdtraj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdtraj/mdtraj/teams","hooks_url":"https://api.github.com/repos/mdtraj/mdtraj/hooks","issue_events_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/events{/number}","events_url":"https://api.github.com/repos/mdtraj/mdtraj/events","assignees_url":"https://api.github.com/repos/mdtraj/mdtraj/assignees{/user}","branches_url":"https://api.github.com/repos/mdtraj/mdtraj/branches{/branch}","tags_url":"https://api.github.com/repos/mdtraj/mdtraj/tags","blobs_url":"https://api.github.com/repos/mdtraj/mdtraj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdtraj/mdtraj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdtraj/mdtraj/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdtraj/mdtraj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdtraj/mdtraj/statuses/{sha}","languages_url":"https://api.github.com/repos/mdtraj/mdtraj/languages","stargazers_url":"https://api.github.com/repos/mdtraj/mdtraj/stargazers","contributors_url":"https://api.github.com/repos/mdtraj/mdtraj/contributors","subscribers_url":"https://api.github.com/repos/mdtraj/mdtraj/subscribers","subscription_url":"https://api.github.com/repos/mdtraj/mdtraj/subscription","commits_url":"https://api.github.com/repos/mdtraj/mdtraj/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdtraj/mdtraj/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdtraj/mdtraj/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdtraj/mdtraj/contents/{+path}","compare_url":"https://api.github.com/repos/mdtraj/mdtraj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdtraj/mdtraj/merges","archive_url":"https://api.github.com/repos/mdtraj/mdtraj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdtraj/mdtraj/downloads","issues_url":"https://api.github.com/repos/mdtraj/mdtraj/issues{/number}","pulls_url":"https://api.github.com/repos/mdtraj/mdtraj/pulls{/number}","milestones_url":"https://api.github.com/repos/mdtraj/mdtraj/milestones{/number}","notifications_url":"https://api.github.com/repos/mdtraj/mdtraj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdtraj/mdtraj/labels{/name}","releases_url":"https://api.github.com/repos/mdtraj/mdtraj/releases{/id}","created_at":"2012-11-08T22:01:24Z","updated_at":"2015-02-23T20:24:45Z","pushed_at":"2015-02-23T20:24:46Z","git_url":"git://github.com/mdtraj/mdtraj.git","ssh_url":"git@github.com:mdtraj/mdtraj.git","clone_url":"https://github.com/mdtraj/mdtraj.git","svn_url":"https://github.com/mdtraj/mdtraj","homepage":"www.mdtraj.org","size":34321,"stargazers_count":42,"watchers_count":42,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":36,"mirror_url":null,"open_issues_count":52,"forks":36,"open_issues":52,"watchers":42,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734"},"html":{"href":"https://github.com/mdtraj/mdtraj/pull/734"},"issue":{"href":"https://api.github.com/repos/mdtraj/mdtraj/issues/734"},"comments":{"href":"https://api.github.com/repos/mdtraj/mdtraj/issues/734/comments"},"review_comments":{"href":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734/comments"},"review_comment":{"href":"https://api.github.com/repos/mdtraj/mdtraj/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mdtraj/mdtraj/pulls/734/commits"},"statuses":{"href":"https://api.github.com/repos/mdtraj/mdtraj/statuses/83c37d2be515d1f90d34c5e12579ada7e0b89d25"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":7,"additions":525,"deletions":5,"changed_files":7}}