{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/135117141","pull_request_review_id":58494539,"id":135117141,"diff_hunk":"@@ -552,21 +568,58 @@ def routine(self, name, expr, argument_sequence, global_vars):\n \n         \"\"\"\n \n+        if self.cse:\n+            from sympy.simplify.cse_main import cse\n+\n+            if is_sequence(expr) and not isinstance(expr, (MatrixBase, MatrixExpr)):\n+                if not expr:\n+                    raise ValueError(\"No expression given\")\n+                for e in expr:\n+                    if not e.is_Equality:\n+                        raise CodeGenError(\"Lists of expressions must all be Equalities. {} is not.\".format(e))","path":"sympy/utilities/codegen.py","position":89,"original_position":89,"commit_id":"c3232a562117e4810ba64431ea41ed4d8933d55a","original_commit_id":"c3232a562117e4810ba64431ea41ed4d8933d55a","user":{"login":"peabody124","id":618346,"avatar_url":"https://avatars1.githubusercontent.com/u/618346?v=4","gravatar_id":"","url":"https://api.github.com/users/peabody124","html_url":"https://github.com/peabody124","followers_url":"https://api.github.com/users/peabody124/followers","following_url":"https://api.github.com/users/peabody124/following{/other_user}","gists_url":"https://api.github.com/users/peabody124/gists{/gist_id}","starred_url":"https://api.github.com/users/peabody124/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peabody124/subscriptions","organizations_url":"https://api.github.com/users/peabody124/orgs","repos_url":"https://api.github.com/users/peabody124/repos","events_url":"https://api.github.com/users/peabody124/events{/privacy}","received_events_url":"https://api.github.com/users/peabody124/received_events","type":"User","site_admin":false},"body":"tested:\r\n\r\n```\r\nIn [34]: generator = CCodeGen(cse=True)\r\n\r\nIn [35]: generator.routine(\"test\", [Eq(a,c),Eq(b,c)])\r\nOut[35]: Routine('test', [InputArgument(c), OutputArgument(a, c, a), OutputArgument(b, c, b)], [], set(), set())\r\n\r\nIn [36]: generator.routine(\"test\", [a,b])\r\n---------------------------------------------------------------------------\r\nCodeGenError                              Traceback (most recent call last)\r\n<ipython-input-36-b8d01875f704> in <module>()\r\n----> 1 generator.routine(\"test\", [a,b])\r\n\r\n~/python/sympy/sympy/utilities/codegen.py in routine(self, name, expr, argument_sequence, global_vars)\r\n    577                 for e in expr:\r\n    578                     if not e.is_Equality:\r\n--> 579                         raise CodeGenError(\"Lists of expressions must all be Equalities. {} is not.\".format(e))\r\n    580                 lhs = [e.lhs for e in expr]\r\n    581 \r\n\r\nCodeGenError: Lists of expressions must all be Equalities. a is not.\r\n```","created_at":"2017-08-24T20:07:45Z","updated_at":"2017-08-24T20:07:45Z","html_url":"https://github.com/sympy/sympy/pull/13184#discussion_r135117141","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/13184","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/135117141"},"html":{"href":"https://github.com/sympy/sympy/pull/13184#discussion_r135117141"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13184"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/13184","id":137341218,"html_url":"https://github.com/sympy/sympy/pull/13184","diff_url":"https://github.com/sympy/sympy/pull/13184.diff","patch_url":"https://github.com/sympy/sympy/pull/13184.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/13184","number":13184,"state":"open","locked":false,"title":"Codegen support common subexpression replacement","user":{"login":"peabody124","id":618346,"avatar_url":"https://avatars1.githubusercontent.com/u/618346?v=4","gravatar_id":"","url":"https://api.github.com/users/peabody124","html_url":"https://github.com/peabody124","followers_url":"https://api.github.com/users/peabody124/followers","following_url":"https://api.github.com/users/peabody124/following{/other_user}","gists_url":"https://api.github.com/users/peabody124/gists{/gist_id}","starred_url":"https://api.github.com/users/peabody124/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peabody124/subscriptions","organizations_url":"https://api.github.com/users/peabody124/orgs","repos_url":"https://api.github.com/users/peabody124/repos","events_url":"https://api.github.com/users/peabody124/events{/privacy}","received_events_url":"https://api.github.com/users/peabody124/received_events","type":"User","site_admin":false},"body":"This makes an extension to the Routine class in codegen to allow adding Result\r\nobjects to the local_vars field. These are then output as C assignments in the\r\nCCodeGen class in the _declare_locals method. This allows defining routines with\r\nlocal variable calculations and writing them correctly.\r\n\r\nNext, it extends the CCodeGen object so that if the cse field is True, it will perform\r\nCSE on the expressions passed in. It keeps the correct set of input and output\r\narguments while doing this. It correctly handles the case of MatrixSymbol input and\r\noutput arguments.\r\n\r\nProvides some work towards #11038","created_at":"2017-08-23T23:41:26Z","updated_at":"2017-08-24T20:07:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ec3d527e4629d94a22af790c126c8d7b1e29925","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/13184/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/13184/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/13184/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/c3232a562117e4810ba64431ea41ed4d8933d55a","head":{"label":"peabody124:codegen_cse","ref":"codegen_cse","sha":"c3232a562117e4810ba64431ea41ed4d8933d55a","user":{"login":"peabody124","id":618346,"avatar_url":"https://avatars1.githubusercontent.com/u/618346?v=4","gravatar_id":"","url":"https://api.github.com/users/peabody124","html_url":"https://github.com/peabody124","followers_url":"https://api.github.com/users/peabody124/followers","following_url":"https://api.github.com/users/peabody124/following{/other_user}","gists_url":"https://api.github.com/users/peabody124/gists{/gist_id}","starred_url":"https://api.github.com/users/peabody124/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peabody124/subscriptions","organizations_url":"https://api.github.com/users/peabody124/orgs","repos_url":"https://api.github.com/users/peabody124/repos","events_url":"https://api.github.com/users/peabody124/events{/privacy}","received_events_url":"https://api.github.com/users/peabody124/received_events","type":"User","site_admin":false},"repo":{"id":101233747,"name":"sympy","full_name":"peabody124/sympy","owner":{"login":"peabody124","id":618346,"avatar_url":"https://avatars1.githubusercontent.com/u/618346?v=4","gravatar_id":"","url":"https://api.github.com/users/peabody124","html_url":"https://github.com/peabody124","followers_url":"https://api.github.com/users/peabody124/followers","following_url":"https://api.github.com/users/peabody124/following{/other_user}","gists_url":"https://api.github.com/users/peabody124/gists{/gist_id}","starred_url":"https://api.github.com/users/peabody124/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peabody124/subscriptions","organizations_url":"https://api.github.com/users/peabody124/orgs","repos_url":"https://api.github.com/users/peabody124/repos","events_url":"https://api.github.com/users/peabody124/events{/privacy}","received_events_url":"https://api.github.com/users/peabody124/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peabody124/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/peabody124/sympy","forks_url":"https://api.github.com/repos/peabody124/sympy/forks","keys_url":"https://api.github.com/repos/peabody124/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peabody124/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peabody124/sympy/teams","hooks_url":"https://api.github.com/repos/peabody124/sympy/hooks","issue_events_url":"https://api.github.com/repos/peabody124/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/peabody124/sympy/events","assignees_url":"https://api.github.com/repos/peabody124/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/peabody124/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/peabody124/sympy/tags","blobs_url":"https://api.github.com/repos/peabody124/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peabody124/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peabody124/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/peabody124/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peabody124/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/peabody124/sympy/languages","stargazers_url":"https://api.github.com/repos/peabody124/sympy/stargazers","contributors_url":"https://api.github.com/repos/peabody124/sympy/contributors","subscribers_url":"https://api.github.com/repos/peabody124/sympy/subscribers","subscription_url":"https://api.github.com/repos/peabody124/sympy/subscription","commits_url":"https://api.github.com/repos/peabody124/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/peabody124/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/peabody124/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/peabody124/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/peabody124/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/peabody124/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peabody124/sympy/merges","archive_url":"https://api.github.com/repos/peabody124/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peabody124/sympy/downloads","issues_url":"https://api.github.com/repos/peabody124/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/peabody124/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/peabody124/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/peabody124/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peabody124/sympy/labels{/name}","releases_url":"https://api.github.com/repos/peabody124/sympy/releases{/id}","deployments_url":"https://api.github.com/repos/peabody124/sympy/deployments","created_at":"2017-08-23T23:36:16Z","updated_at":"2017-08-23T23:36:24Z","pushed_at":"2017-08-24T20:07:08Z","git_url":"git://github.com/peabody124/sympy.git","ssh_url":"git@github.com:peabody124/sympy.git","clone_url":"https://github.com/peabody124/sympy.git","svn_url":"https://github.com/peabody124/sympy","homepage":"http://sympy.org/","size":81462,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"sympy:master","ref":"master","sha":"837a67d74781a026e31e461ff4684ce2c949b92d","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars1.githubusercontent.com/u/260832?v=4","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":640534,"name":"sympy","full_name":"sympy/sympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars1.githubusercontent.com/u/260832?v=4","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/sympy","description":"A computer algebra system written in pure Python","fork":false,"url":"https://api.github.com/repos/sympy/sympy","forks_url":"https://api.github.com/repos/sympy/sympy/forks","keys_url":"https://api.github.com/repos/sympy/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/sympy/teams","hooks_url":"https://api.github.com/repos/sympy/sympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/sympy/events","assignees_url":"https://api.github.com/repos/sympy/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/sympy/tags","blobs_url":"https://api.github.com/repos/sympy/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/sympy/languages","stargazers_url":"https://api.github.com/repos/sympy/sympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/sympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/sympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/sympy/subscription","commits_url":"https://api.github.com/repos/sympy/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/sympy/merges","archive_url":"https://api.github.com/repos/sympy/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/sympy/downloads","issues_url":"https://api.github.com/repos/sympy/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/sympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/sympy/releases{/id}","deployments_url":"https://api.github.com/repos/sympy/sympy/deployments","created_at":"2010-04-30T20:37:14Z","updated_at":"2017-08-24T13:59:54Z","pushed_at":"2017-08-24T20:07:12Z","git_url":"git://github.com/sympy/sympy.git","ssh_url":"git@github.com:sympy/sympy.git","clone_url":"https://github.com/sympy/sympy.git","svn_url":"https://github.com/sympy/sympy","homepage":"http://sympy.org/","size":81430,"stargazers_count":4095,"watchers_count":4095,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1995,"mirror_url":null,"open_issues_count":3028,"forks":1995,"open_issues":3028,"watchers":4095,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13184"},"html":{"href":"https://github.com/sympy/sympy/pull/13184"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/13184"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/13184/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13184/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13184/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/c3232a562117e4810ba64431ea41ed4d8933d55a"}}}}
{"actor":{"display_login":"peabody124"}}