{"action":"created","comment":{"url":"https://api.github.com/repos/scipy/scipy/pulls/comments/80189378","id":80189378,"diff_hunk":"@@ -112,36 +134,48 @@ def newton(func, x0, fprime=None, args=(), tol=1.48e-8, maxiter=50,\n     -----\n     The convergence rate of the Newton-Raphson method is quadratic,\n     the Halley method is cubic, and the secant method is\n-    sub-quadratic.  This means that if the function is well behaved\n-    the actual error in the estimated zero is approximately the square\n-    (cube for Halley) of the requested tolerance up to roundoff\n-    error. However, the stopping criterion used here is the step size\n-    and there is no guarantee that a zero has been found. Consequently\n-    the result should be verified. Safer algorithms are brentq,\n-    brenth, ridder, and bisect, but they all require that the root\n-    first be bracketed in an interval where the function changes\n-    sign. The brentq algorithm is recommended for general use in one\n-    dimensional problems when such an interval has been found.\n+    sub-quadratic. This means that if the function is well behaved the\n+    actual error in the estimated zero is approximately the square\n+    (cube for Halley) of the requested tolerance up to roundoff error.\n+\n+    If `halt` is 'astep' or 'rstep', then the halting condition is\n+    absolute or relative step size, and in this case there is no\n+    guarantee that a zero has been found and the result should be\n+    verified. If `halt` is changed to 'afval' or 'rfval' then the\n+    absolute value of `func` or the relative size of `func` versus the\n+    current iterate is used as a stopping criterion instead and an\n+    error is raised if a root is not found. If the function is not\n+    sufficiently well behaved, convergence to a root is still not\n+    guaranteed.\n+\n+    Safer algorithms are `brentq`, `brenth`, `ridder`, and `bisect`,\n+    but they all require that the root first be bracketed in an\n+    interval where the function changes sign. The brentq algorithm is\n+    recommended for general use in one dimensional problems when such\n+    an interval has been found.\n \n     \"\"\"\n+    if halt not in ['astep', 'rstep', 'afval', 'rfval']:\n+        raise ValueError(\"invalid halting condition\")\n     if tol <= 0:\n         raise ValueError(\"tol too small (%g <= 0)\" % tol)\n     if maxiter < 1:\n         raise ValueError(\"maxiter must be greater than 0\")\n+\n     if fprime is not None:\n-        # Newton-Rapheson method\n-        # Multiply by 1.0 to convert to floating point.  We don't use float(x0)\n+        # Newton-Raphson method\n+        # Multiply by 1.0 to convert to floating point. We don't use float(x0)\n         # so it still works if x0 is complex.\n         p0 = 1.0 * x0\n+        myargs = (p0,) + args\n+        fval = func(*myargs)","path":"scipy/optimize/zeros.py","position":104,"original_position":104,"commit_id":"24506c6838e25396aaee57c483c079a2d1ec1102","original_commit_id":"24506c6838e25396aaee57c483c079a2d1ec1102","user":{"login":"dlax","id":1046124,"avatar_url":"https://avatars.githubusercontent.com/u/1046124?v=3","gravatar_id":"","url":"https://api.github.com/users/dlax","html_url":"https://github.com/dlax","followers_url":"https://api.github.com/users/dlax/followers","following_url":"https://api.github.com/users/dlax/following{/other_user}","gists_url":"https://api.github.com/users/dlax/gists{/gist_id}","starred_url":"https://api.github.com/users/dlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlax/subscriptions","organizations_url":"https://api.github.com/users/dlax/orgs","repos_url":"https://api.github.com/users/dlax/repos","events_url":"https://api.github.com/users/dlax/events{/privacy}","received_events_url":"https://api.github.com/users/dlax/received_events","type":"User","site_admin":false},"body":"Ok. Wouldn't `compute function -> check halting condition -> take a step` work then?","created_at":"2016-09-23T06:46:45Z","updated_at":"2016-09-23T06:46:45Z","html_url":"https://github.com/scipy/scipy/pull/6380#discussion_r80189378","pull_request_url":"https://api.github.com/repos/scipy/scipy/pulls/6380","_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments/80189378"},"html":{"href":"https://github.com/scipy/scipy/pull/6380#discussion_r80189378"},"pull_request":{"href":"https://api.github.com/repos/scipy/scipy/pulls/6380"}}},"pull_request":{"url":"https://api.github.com/repos/scipy/scipy/pulls/6380","id":77686580,"html_url":"https://github.com/scipy/scipy/pull/6380","diff_url":"https://github.com/scipy/scipy/pull/6380.diff","patch_url":"https://github.com/scipy/scipy/pull/6380.patch","issue_url":"https://api.github.com/repos/scipy/scipy/issues/6380","number":6380,"state":"open","locked":false,"title":"MAINT: optimize: let user choose convergence criterion in `newton`","user":{"login":"person142","id":15134881,"avatar_url":"https://avatars.githubusercontent.com/u/15134881?v=3","gravatar_id":"","url":"https://api.github.com/users/person142","html_url":"https://github.com/person142","followers_url":"https://api.github.com/users/person142/followers","following_url":"https://api.github.com/users/person142/following{/other_user}","gists_url":"https://api.github.com/users/person142/gists{/gist_id}","starred_url":"https://api.github.com/users/person142/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/person142/subscriptions","organizations_url":"https://api.github.com/users/person142/orgs","repos_url":"https://api.github.com/users/person142/repos","events_url":"https://api.github.com/users/person142/events{/privacy}","received_events_url":"https://api.github.com/users/person142/received_events","type":"User","site_admin":false},"body":"**Edit**:  before `newton` could only use absolute step size for its convergence\r\ncriterion; this lets it also use relative step size, absolute size of\r\nthe function value, or relative size of the function value.\r\n\r\n~~Before `newton` used step size for its convergence criterion; now it\r\nuses the absolute value of the objective function.~~ Closes gh-6379.\r\n","created_at":"2016-07-15T22:20:07Z","updated_at":"2016-09-23T06:46:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"003690e1379a0719803cef607f41bc7ac629de27","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scipy/scipy/pulls/6380/commits","review_comments_url":"https://api.github.com/repos/scipy/scipy/pulls/6380/comments","review_comment_url":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/6380/comments","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/24506c6838e25396aaee57c483c079a2d1ec1102","head":{"label":"person142:gh-6379","ref":"gh-6379","sha":"24506c6838e25396aaee57c483c079a2d1ec1102","user":{"login":"person142","id":15134881,"avatar_url":"https://avatars.githubusercontent.com/u/15134881?v=3","gravatar_id":"","url":"https://api.github.com/users/person142","html_url":"https://github.com/person142","followers_url":"https://api.github.com/users/person142/followers","following_url":"https://api.github.com/users/person142/following{/other_user}","gists_url":"https://api.github.com/users/person142/gists{/gist_id}","starred_url":"https://api.github.com/users/person142/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/person142/subscriptions","organizations_url":"https://api.github.com/users/person142/orgs","repos_url":"https://api.github.com/users/person142/repos","events_url":"https://api.github.com/users/person142/events{/privacy}","received_events_url":"https://api.github.com/users/person142/received_events","type":"User","site_admin":false},"repo":{"id":44291149,"name":"scipy","full_name":"person142/scipy","owner":{"login":"person142","id":15134881,"avatar_url":"https://avatars.githubusercontent.com/u/15134881?v=3","gravatar_id":"","url":"https://api.github.com/users/person142","html_url":"https://github.com/person142","followers_url":"https://api.github.com/users/person142/followers","following_url":"https://api.github.com/users/person142/following{/other_user}","gists_url":"https://api.github.com/users/person142/gists{/gist_id}","starred_url":"https://api.github.com/users/person142/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/person142/subscriptions","organizations_url":"https://api.github.com/users/person142/orgs","repos_url":"https://api.github.com/users/person142/repos","events_url":"https://api.github.com/users/person142/events{/privacy}","received_events_url":"https://api.github.com/users/person142/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/person142/scipy","description":"Scipy library main repository","fork":true,"url":"https://api.github.com/repos/person142/scipy","forks_url":"https://api.github.com/repos/person142/scipy/forks","keys_url":"https://api.github.com/repos/person142/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/person142/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/person142/scipy/teams","hooks_url":"https://api.github.com/repos/person142/scipy/hooks","issue_events_url":"https://api.github.com/repos/person142/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/person142/scipy/events","assignees_url":"https://api.github.com/repos/person142/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/person142/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/person142/scipy/tags","blobs_url":"https://api.github.com/repos/person142/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/person142/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/person142/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/person142/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/person142/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/person142/scipy/languages","stargazers_url":"https://api.github.com/repos/person142/scipy/stargazers","contributors_url":"https://api.github.com/repos/person142/scipy/contributors","subscribers_url":"https://api.github.com/repos/person142/scipy/subscribers","subscription_url":"https://api.github.com/repos/person142/scipy/subscription","commits_url":"https://api.github.com/repos/person142/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/person142/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/person142/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/person142/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/person142/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/person142/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/person142/scipy/merges","archive_url":"https://api.github.com/repos/person142/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/person142/scipy/downloads","issues_url":"https://api.github.com/repos/person142/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/person142/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/person142/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/person142/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/person142/scipy/labels{/name}","releases_url":"https://api.github.com/repos/person142/scipy/releases{/id}","deployments_url":"https://api.github.com/repos/person142/scipy/deployments","created_at":"2015-10-15T03:18:27Z","updated_at":"2016-03-06T16:12:54Z","pushed_at":"2016-09-22T21:39:26Z","git_url":"git://github.com/person142/scipy.git","ssh_url":"git@github.com:person142/scipy.git","clone_url":"https://github.com/person142/scipy.git","svn_url":"https://github.com/person142/scipy","homepage":"http://scipy.org/scipylib/","size":60095,"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":"scipy:master","ref":"master","sha":"deb275242171a62f03c4ca761a779f0c1f5f6513","user":{"login":"scipy","id":288277,"avatar_url":"https://avatars.githubusercontent.com/u/288277?v=3","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"repo":{"id":1460385,"name":"scipy","full_name":"scipy/scipy","owner":{"login":"scipy","id":288277,"avatar_url":"https://avatars.githubusercontent.com/u/288277?v=3","gravatar_id":"","url":"https://api.github.com/users/scipy","html_url":"https://github.com/scipy","followers_url":"https://api.github.com/users/scipy/followers","following_url":"https://api.github.com/users/scipy/following{/other_user}","gists_url":"https://api.github.com/users/scipy/gists{/gist_id}","starred_url":"https://api.github.com/users/scipy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scipy/subscriptions","organizations_url":"https://api.github.com/users/scipy/orgs","repos_url":"https://api.github.com/users/scipy/repos","events_url":"https://api.github.com/users/scipy/events{/privacy}","received_events_url":"https://api.github.com/users/scipy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scipy/scipy","description":"Scipy library main repository","fork":false,"url":"https://api.github.com/repos/scipy/scipy","forks_url":"https://api.github.com/repos/scipy/scipy/forks","keys_url":"https://api.github.com/repos/scipy/scipy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scipy/scipy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scipy/scipy/teams","hooks_url":"https://api.github.com/repos/scipy/scipy/hooks","issue_events_url":"https://api.github.com/repos/scipy/scipy/issues/events{/number}","events_url":"https://api.github.com/repos/scipy/scipy/events","assignees_url":"https://api.github.com/repos/scipy/scipy/assignees{/user}","branches_url":"https://api.github.com/repos/scipy/scipy/branches{/branch}","tags_url":"https://api.github.com/repos/scipy/scipy/tags","blobs_url":"https://api.github.com/repos/scipy/scipy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scipy/scipy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scipy/scipy/git/refs{/sha}","trees_url":"https://api.github.com/repos/scipy/scipy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scipy/scipy/statuses/{sha}","languages_url":"https://api.github.com/repos/scipy/scipy/languages","stargazers_url":"https://api.github.com/repos/scipy/scipy/stargazers","contributors_url":"https://api.github.com/repos/scipy/scipy/contributors","subscribers_url":"https://api.github.com/repos/scipy/scipy/subscribers","subscription_url":"https://api.github.com/repos/scipy/scipy/subscription","commits_url":"https://api.github.com/repos/scipy/scipy/commits{/sha}","git_commits_url":"https://api.github.com/repos/scipy/scipy/git/commits{/sha}","comments_url":"https://api.github.com/repos/scipy/scipy/comments{/number}","issue_comment_url":"https://api.github.com/repos/scipy/scipy/issues/comments{/number}","contents_url":"https://api.github.com/repos/scipy/scipy/contents/{+path}","compare_url":"https://api.github.com/repos/scipy/scipy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scipy/scipy/merges","archive_url":"https://api.github.com/repos/scipy/scipy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scipy/scipy/downloads","issues_url":"https://api.github.com/repos/scipy/scipy/issues{/number}","pulls_url":"https://api.github.com/repos/scipy/scipy/pulls{/number}","milestones_url":"https://api.github.com/repos/scipy/scipy/milestones{/number}","notifications_url":"https://api.github.com/repos/scipy/scipy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scipy/scipy/labels{/name}","releases_url":"https://api.github.com/repos/scipy/scipy/releases{/id}","deployments_url":"https://api.github.com/repos/scipy/scipy/deployments","created_at":"2011-03-09T18:52:03Z","updated_at":"2016-09-22T15:12:29Z","pushed_at":"2016-09-22T23:45:33Z","git_url":"git://github.com/scipy/scipy.git","ssh_url":"git@github.com:scipy/scipy.git","clone_url":"https://github.com/scipy/scipy.git","svn_url":"https://github.com/scipy/scipy","homepage":"http://scipy.org/scipylib/","size":77229,"stargazers_count":2593,"watchers_count":2593,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1511,"mirror_url":null,"open_issues_count":956,"forks":1511,"open_issues":956,"watchers":2593,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scipy/scipy/pulls/6380"},"html":{"href":"https://github.com/scipy/scipy/pull/6380"},"issue":{"href":"https://api.github.com/repos/scipy/scipy/issues/6380"},"comments":{"href":"https://api.github.com/repos/scipy/scipy/issues/6380/comments"},"review_comments":{"href":"https://api.github.com/repos/scipy/scipy/pulls/6380/comments"},"review_comment":{"href":"https://api.github.com/repos/scipy/scipy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scipy/scipy/pulls/6380/commits"},"statuses":{"href":"https://api.github.com/repos/scipy/scipy/statuses/24506c6838e25396aaee57c483c079a2d1ec1102"}}}}
{"actor":{"display_login":"dlax"}}