{"action":"opened","number":411,"pull_request":{"url":"https://api.github.com/repos/non/spire/pulls/411","id":31647451,"html_url":"https://github.com/non/spire/pull/411","diff_url":"https://github.com/non/spire/pull/411.diff","patch_url":"https://github.com/non/spire/pull/411.patch","issue_url":"https://api.github.com/repos/non/spire/issues/411","number":411,"state":"open","locked":false,"title":"Unify and fix Polynomial's equals and hashCode methods.","user":{"login":"non","id":218045,"avatar_url":"https://avatars.githubusercontent.com/u/218045?v=3","gravatar_id":"","url":"https://api.github.com/users/non","html_url":"https://github.com/non","followers_url":"https://api.github.com/users/non/followers","following_url":"https://api.github.com/users/non/following{/other_user}","gists_url":"https://api.github.com/users/non/gists{/gist_id}","starred_url":"https://api.github.com/users/non/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/non/subscriptions","organizations_url":"https://api.github.com/users/non/orgs","repos_url":"https://api.github.com/users/non/repos","events_url":"https://api.github.com/users/non/events{/privacy}","received_events_url":"https://api.github.com/users/non/received_events","type":"User","site_admin":false},"body":"This commit adds a termsIterator method to Polynomial. This method\r\nreturns an Iterator[Term[C]] for all non-zero coefficients in the\r\npolynomial, from smallest-exponent to largest. This iterator is\r\nused to implement equality and hashCode in a standardized way that\r\nworks for dense and sparse polynomials.\r\n\r\nThe hashing formula used is essentially:\r\n\r\n  val it: Iterator[Term[C]] = p.termsIterator\r\n  val ns: Iterator[Int] = it.map(t => (0xfeed1257 * t.exp) ^ t.coeff.##)\r\n  val hashCode: Int = ns.foldLeft(0)(_ ^ _)\r\n\r\nOne useful side-effect is that if the terms iterator is empty\r\n(i.e. the polynomial is zero) the hash code is 0. Also, if p\r\nconsists of a single term whose exponent is zero, the overall\r\nhashCode will be identical to the hash code of the term's\r\ncofficient.\r\n\r\nOne gotcha with the termsIterator method is that it uses a\r\n(_ == 0) test to filter out terms whose coefficient is zero.\r\nThis necessary in order to support universal equality, and is\r\ndocumented in the method's ScalaDoc comment. We could choose\r\nto make this method private to Spire if it is deemed to be\r\n\"too dangerous\".\r\n\r\nFixes #410.\r\n\r\nReview by @tixxit and @rklaehn.","created_at":"2015-03-20T20:08:02Z","updated_at":"2015-03-20T20:08:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/non/spire/pulls/411/commits","review_comments_url":"https://api.github.com/repos/non/spire/pulls/411/comments","review_comment_url":"https://api.github.com/repos/non/spire/pulls/comments{/number}","comments_url":"https://api.github.com/repos/non/spire/issues/411/comments","statuses_url":"https://api.github.com/repos/non/spire/statuses/88bc77b03f71a78d2298baf996c0af0379068702","head":{"label":"non:bug/polynomial-equals-hashcode","ref":"bug/polynomial-equals-hashcode","sha":"88bc77b03f71a78d2298baf996c0af0379068702","user":{"login":"non","id":218045,"avatar_url":"https://avatars.githubusercontent.com/u/218045?v=3","gravatar_id":"","url":"https://api.github.com/users/non","html_url":"https://github.com/non","followers_url":"https://api.github.com/users/non/followers","following_url":"https://api.github.com/users/non/following{/other_user}","gists_url":"https://api.github.com/users/non/gists{/gist_id}","starred_url":"https://api.github.com/users/non/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/non/subscriptions","organizations_url":"https://api.github.com/users/non/orgs","repos_url":"https://api.github.com/users/non/repos","events_url":"https://api.github.com/users/non/events{/privacy}","received_events_url":"https://api.github.com/users/non/received_events","type":"User","site_admin":false},"repo":{"id":2705076,"name":"spire","full_name":"non/spire","owner":{"login":"non","id":218045,"avatar_url":"https://avatars.githubusercontent.com/u/218045?v=3","gravatar_id":"","url":"https://api.github.com/users/non","html_url":"https://github.com/non","followers_url":"https://api.github.com/users/non/followers","following_url":"https://api.github.com/users/non/following{/other_user}","gists_url":"https://api.github.com/users/non/gists{/gist_id}","starred_url":"https://api.github.com/users/non/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/non/subscriptions","organizations_url":"https://api.github.com/users/non/orgs","repos_url":"https://api.github.com/users/non/repos","events_url":"https://api.github.com/users/non/events{/privacy}","received_events_url":"https://api.github.com/users/non/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/non/spire","description":"Powerful new number types and numeric abstractions for Scala.","fork":false,"url":"https://api.github.com/repos/non/spire","forks_url":"https://api.github.com/repos/non/spire/forks","keys_url":"https://api.github.com/repos/non/spire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/non/spire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/non/spire/teams","hooks_url":"https://api.github.com/repos/non/spire/hooks","issue_events_url":"https://api.github.com/repos/non/spire/issues/events{/number}","events_url":"https://api.github.com/repos/non/spire/events","assignees_url":"https://api.github.com/repos/non/spire/assignees{/user}","branches_url":"https://api.github.com/repos/non/spire/branches{/branch}","tags_url":"https://api.github.com/repos/non/spire/tags","blobs_url":"https://api.github.com/repos/non/spire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/non/spire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/non/spire/git/refs{/sha}","trees_url":"https://api.github.com/repos/non/spire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/non/spire/statuses/{sha}","languages_url":"https://api.github.com/repos/non/spire/languages","stargazers_url":"https://api.github.com/repos/non/spire/stargazers","contributors_url":"https://api.github.com/repos/non/spire/contributors","subscribers_url":"https://api.github.com/repos/non/spire/subscribers","subscription_url":"https://api.github.com/repos/non/spire/subscription","commits_url":"https://api.github.com/repos/non/spire/commits{/sha}","git_commits_url":"https://api.github.com/repos/non/spire/git/commits{/sha}","comments_url":"https://api.github.com/repos/non/spire/comments{/number}","issue_comment_url":"https://api.github.com/repos/non/spire/issues/comments{/number}","contents_url":"https://api.github.com/repos/non/spire/contents/{+path}","compare_url":"https://api.github.com/repos/non/spire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/non/spire/merges","archive_url":"https://api.github.com/repos/non/spire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/non/spire/downloads","issues_url":"https://api.github.com/repos/non/spire/issues{/number}","pulls_url":"https://api.github.com/repos/non/spire/pulls{/number}","milestones_url":"https://api.github.com/repos/non/spire/milestones{/number}","notifications_url":"https://api.github.com/repos/non/spire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/non/spire/labels{/name}","releases_url":"https://api.github.com/repos/non/spire/releases{/id}","created_at":"2011-11-03T20:52:53Z","updated_at":"2015-03-20T17:21:45Z","pushed_at":"2015-03-20T20:08:02Z","git_url":"git://github.com/non/spire.git","ssh_url":"git@github.com:non/spire.git","clone_url":"https://github.com/non/spire.git","svn_url":"https://github.com/non/spire","homepage":"","size":7806,"stargazers_count":653,"watchers_count":653,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":105,"forks":86,"open_issues":105,"watchers":653,"default_branch":"master"}},"base":{"label":"non:master","ref":"master","sha":"0e2cc826e02e74236415fbd588f9730e3ec189f6","user":{"login":"non","id":218045,"avatar_url":"https://avatars.githubusercontent.com/u/218045?v=3","gravatar_id":"","url":"https://api.github.com/users/non","html_url":"https://github.com/non","followers_url":"https://api.github.com/users/non/followers","following_url":"https://api.github.com/users/non/following{/other_user}","gists_url":"https://api.github.com/users/non/gists{/gist_id}","starred_url":"https://api.github.com/users/non/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/non/subscriptions","organizations_url":"https://api.github.com/users/non/orgs","repos_url":"https://api.github.com/users/non/repos","events_url":"https://api.github.com/users/non/events{/privacy}","received_events_url":"https://api.github.com/users/non/received_events","type":"User","site_admin":false},"repo":{"id":2705076,"name":"spire","full_name":"non/spire","owner":{"login":"non","id":218045,"avatar_url":"https://avatars.githubusercontent.com/u/218045?v=3","gravatar_id":"","url":"https://api.github.com/users/non","html_url":"https://github.com/non","followers_url":"https://api.github.com/users/non/followers","following_url":"https://api.github.com/users/non/following{/other_user}","gists_url":"https://api.github.com/users/non/gists{/gist_id}","starred_url":"https://api.github.com/users/non/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/non/subscriptions","organizations_url":"https://api.github.com/users/non/orgs","repos_url":"https://api.github.com/users/non/repos","events_url":"https://api.github.com/users/non/events{/privacy}","received_events_url":"https://api.github.com/users/non/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/non/spire","description":"Powerful new number types and numeric abstractions for Scala.","fork":false,"url":"https://api.github.com/repos/non/spire","forks_url":"https://api.github.com/repos/non/spire/forks","keys_url":"https://api.github.com/repos/non/spire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/non/spire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/non/spire/teams","hooks_url":"https://api.github.com/repos/non/spire/hooks","issue_events_url":"https://api.github.com/repos/non/spire/issues/events{/number}","events_url":"https://api.github.com/repos/non/spire/events","assignees_url":"https://api.github.com/repos/non/spire/assignees{/user}","branches_url":"https://api.github.com/repos/non/spire/branches{/branch}","tags_url":"https://api.github.com/repos/non/spire/tags","blobs_url":"https://api.github.com/repos/non/spire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/non/spire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/non/spire/git/refs{/sha}","trees_url":"https://api.github.com/repos/non/spire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/non/spire/statuses/{sha}","languages_url":"https://api.github.com/repos/non/spire/languages","stargazers_url":"https://api.github.com/repos/non/spire/stargazers","contributors_url":"https://api.github.com/repos/non/spire/contributors","subscribers_url":"https://api.github.com/repos/non/spire/subscribers","subscription_url":"https://api.github.com/repos/non/spire/subscription","commits_url":"https://api.github.com/repos/non/spire/commits{/sha}","git_commits_url":"https://api.github.com/repos/non/spire/git/commits{/sha}","comments_url":"https://api.github.com/repos/non/spire/comments{/number}","issue_comment_url":"https://api.github.com/repos/non/spire/issues/comments{/number}","contents_url":"https://api.github.com/repos/non/spire/contents/{+path}","compare_url":"https://api.github.com/repos/non/spire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/non/spire/merges","archive_url":"https://api.github.com/repos/non/spire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/non/spire/downloads","issues_url":"https://api.github.com/repos/non/spire/issues{/number}","pulls_url":"https://api.github.com/repos/non/spire/pulls{/number}","milestones_url":"https://api.github.com/repos/non/spire/milestones{/number}","notifications_url":"https://api.github.com/repos/non/spire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/non/spire/labels{/name}","releases_url":"https://api.github.com/repos/non/spire/releases{/id}","created_at":"2011-11-03T20:52:53Z","updated_at":"2015-03-20T17:21:45Z","pushed_at":"2015-03-20T20:08:02Z","git_url":"git://github.com/non/spire.git","ssh_url":"git@github.com:non/spire.git","clone_url":"https://github.com/non/spire.git","svn_url":"https://github.com/non/spire","homepage":"","size":7806,"stargazers_count":653,"watchers_count":653,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":105,"forks":86,"open_issues":105,"watchers":653,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/non/spire/pulls/411"},"html":{"href":"https://github.com/non/spire/pull/411"},"issue":{"href":"https://api.github.com/repos/non/spire/issues/411"},"comments":{"href":"https://api.github.com/repos/non/spire/issues/411/comments"},"review_comments":{"href":"https://api.github.com/repos/non/spire/pulls/411/comments"},"review_comment":{"href":"https://api.github.com/repos/non/spire/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/non/spire/pulls/411/commits"},"statuses":{"href":"https://api.github.com/repos/non/spire/statuses/88bc77b03f71a78d2298baf996c0af0379068702"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":88,"deletions":19,"changed_files":4}}