{"action":"created","comment":{"url":"https://api.github.com/repos/opesci/devito/pulls/comments/92982411","pull_request_review_id":13502829,"id":92982411,"diff_hunk":"@@ -0,0 +1,175 @@\n+from devito.interfaces import SymbolicData\n+from devito.logger import warning\n+\n+from devito.dse.extended_sympy import Add, Mul\n+\n+import numpy as np\n+from sympy import (Indexed, Function, S, Symbol,\n+                   count_ops, flatten, lambdify, preorder_traversal)\n+\n+__all__ = ['indexify', 'retrieve_dimensions', 'retrieve_dtype', 'retrieve_symbols',\n+           'terminals', 'tolambda']\n+\n+\n+def free_terms(expr):\n+    \"\"\"\n+    Find the free terms in an expression.\n+    \"\"\"\n+    found = []\n+\n+    for term in expr.args:\n+        if isinstance(term, Indexed):\n+            found.append(term)\n+        else:\n+            found += free_terms(term)\n+\n+    return found\n+\n+\n+def terminals(expr, discard_indexed=False):\n+    indexed = list(expr.find(Indexed))\n+\n+    # To be discarded\n+    junk = flatten(i.atoms() for i in indexed)\n+\n+    symbols = list(expr.find(Symbol))\n+    symbols = [i for i in symbols if i not in junk]\n+\n+    if discard_indexed:\n+        return set(symbols)\n+    else:\n+        return set(indexed + symbols)\n+\n+\n+def estimate_cost(handle):\n+    try:\n+        # Is it a plain SymPy object ?\n+        iter(handle)\n+    except TypeError:\n+        handle = [handle]\n+    try:\n+        # Is it a dict ?\n+        handle = handle.values()\n+    except AttributeError:\n+        try:\n+            # Must be a list of dicts then\n+            handle = flatten(i.values() for i in handle)\n+        except AttributeError:\n+            pass\n+    try:\n+        # At this point it must be a list of SymPy objects\n+        # We don't count non floating point operations\n+        handle = [i.rhs if i.is_Equality else i for i in handle]\n+        total_ops = sum(count_ops(i.args) for i in handle)\n+        non_flops = sum(count_ops(i.find(Indexed)) for i in handle)\n+        return total_ops - non_flops\n+    except:\n+        warning(\"Cannot estimate cost of %s\" % str(handle))\n+\n+\n+def unevaluate_arithmetic(expr):\n+    \"\"\"\n+    Reconstruct ``expr`` turning all :class:`sympy.Mul` and :class:`sympy.Add`\n+    into, respectively, :class:`devito.Mul` and :class:`devito.Add`.\n+    \"\"\"\n+    if expr.is_Float:\n+        return expr.func(*expr.atoms())\n+    elif isinstance(expr, Indexed):\n+        return expr.func(*expr.args)\n+    elif expr.is_Symbol:\n+        return expr.func(expr.name)\n+    elif expr in [S.Zero, S.One, S.NegativeOne, S.Half]:\n+        return expr.func()\n+    elif expr.is_Atom:\n+        return expr.func(*expr.atoms())\n+    if expr.is_Add:","path":"devito/dse/inspection.py","position":85,"original_position":85,"commit_id":"8b37f4087eb05fdfe7826390321eb4057d39a28e","original_commit_id":"8b37f4087eb05fdfe7826390321eb4057d39a28e","user":{"login":"FabioLuporini","id":478143,"avatar_url":"https://avatars.githubusercontent.com/u/478143?v=3","gravatar_id":"","url":"https://api.github.com/users/FabioLuporini","html_url":"https://github.com/FabioLuporini","followers_url":"https://api.github.com/users/FabioLuporini/followers","following_url":"https://api.github.com/users/FabioLuporini/following{/other_user}","gists_url":"https://api.github.com/users/FabioLuporini/gists{/gist_id}","starred_url":"https://api.github.com/users/FabioLuporini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FabioLuporini/subscriptions","organizations_url":"https://api.github.com/users/FabioLuporini/orgs","repos_url":"https://api.github.com/users/FabioLuporini/repos","events_url":"https://api.github.com/users/FabioLuporini/events{/privacy}","received_events_url":"https://api.github.com/users/FabioLuporini/received_events","type":"User","site_admin":false},"body":"good spot","created_at":"2016-12-19T07:55:24Z","updated_at":"2016-12-19T07:55:24Z","html_url":"https://github.com/opesci/devito/pull/162#discussion_r92982411","pull_request_url":"https://api.github.com/repos/opesci/devito/pulls/162","_links":{"self":{"href":"https://api.github.com/repos/opesci/devito/pulls/comments/92982411"},"html":{"href":"https://github.com/opesci/devito/pull/162#discussion_r92982411"},"pull_request":{"href":"https://api.github.com/repos/opesci/devito/pulls/162"}}},"pull_request":{"url":"https://api.github.com/repos/opesci/devito/pulls/162","id":96968884,"html_url":"https://github.com/opesci/devito/pull/162","diff_url":"https://github.com/opesci/devito/pull/162.diff","patch_url":"https://github.com/opesci/devito/pull/162.patch","issue_url":"https://api.github.com/repos/opesci/devito/issues/162","number":162,"state":"open","locked":false,"title":"DSE restructuring and improvements","user":{"login":"FabioLuporini","id":478143,"avatar_url":"https://avatars.githubusercontent.com/u/478143?v=3","gravatar_id":"","url":"https://api.github.com/users/FabioLuporini","html_url":"https://github.com/FabioLuporini","followers_url":"https://api.github.com/users/FabioLuporini/followers","following_url":"https://api.github.com/users/FabioLuporini/following{/other_user}","gists_url":"https://api.github.com/users/FabioLuporini/gists{/gist_id}","starred_url":"https://api.github.com/users/FabioLuporini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FabioLuporini/subscriptions","organizations_url":"https://api.github.com/users/FabioLuporini/orgs","repos_url":"https://api.github.com/users/FabioLuporini/repos","events_url":"https://api.github.com/users/FabioLuporini/events{/privacy}","received_events_url":"https://api.github.com/users/FabioLuporini/received_events","type":"User","site_admin":false},"body":"You'll see lots of edits in this PR, but no worries: it's mostly just moving stuff around and dropping useless functionalities.\r\n\r\nNow the DSE has its own subdirectory ``dse``, and its components are split over multiple files.\r\n\r\nThe Bhaskara polynomials approximation is now applicable by the DSE; as such, it's been removed from TTI.\r\n\r\nA few more things:\r\n- Now we always print the compilation time\r\n- The ``factorized`` attribute has finally been dropped \r\n- Added basic infrastructure for creating ``temporaries graphs``, which will be used in subsequent versions of the DSE\r\n\r\nAll new functionalities are properly tested\r\n\r\nI'm happy to rebase if #161 lands first","created_at":"2016-12-07T17:22:44Z","updated_at":"2016-12-19T07:55:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82af63f9699c144d95430012cdfb1ac0441368f9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/opesci/devito/pulls/162/commits","review_comments_url":"https://api.github.com/repos/opesci/devito/pulls/162/comments","review_comment_url":"https://api.github.com/repos/opesci/devito/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opesci/devito/issues/162/comments","statuses_url":"https://api.github.com/repos/opesci/devito/statuses/8b37f4087eb05fdfe7826390321eb4057d39a28e","head":{"label":"opesci:better-dse","ref":"better-dse","sha":"8b37f4087eb05fdfe7826390321eb4057d39a28e","user":{"login":"opesci","id":10018551,"avatar_url":"https://avatars.githubusercontent.com/u/10018551?v=3","gravatar_id":"","url":"https://api.github.com/users/opesci","html_url":"https://github.com/opesci","followers_url":"https://api.github.com/users/opesci/followers","following_url":"https://api.github.com/users/opesci/following{/other_user}","gists_url":"https://api.github.com/users/opesci/gists{/gist_id}","starred_url":"https://api.github.com/users/opesci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opesci/subscriptions","organizations_url":"https://api.github.com/users/opesci/orgs","repos_url":"https://api.github.com/users/opesci/repos","events_url":"https://api.github.com/users/opesci/events{/privacy}","received_events_url":"https://api.github.com/users/opesci/received_events","type":"Organization","site_admin":false},"repo":{"id":54585666,"name":"devito","full_name":"opesci/devito","owner":{"login":"opesci","id":10018551,"avatar_url":"https://avatars.githubusercontent.com/u/10018551?v=3","gravatar_id":"","url":"https://api.github.com/users/opesci","html_url":"https://github.com/opesci","followers_url":"https://api.github.com/users/opesci/followers","following_url":"https://api.github.com/users/opesci/following{/other_user}","gists_url":"https://api.github.com/users/opesci/gists{/gist_id}","starred_url":"https://api.github.com/users/opesci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opesci/subscriptions","organizations_url":"https://api.github.com/users/opesci/orgs","repos_url":"https://api.github.com/users/opesci/repos","events_url":"https://api.github.com/users/opesci/events{/privacy}","received_events_url":"https://api.github.com/users/opesci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opesci/devito","description":"Code generation for the inversion workflow","fork":false,"url":"https://api.github.com/repos/opesci/devito","forks_url":"https://api.github.com/repos/opesci/devito/forks","keys_url":"https://api.github.com/repos/opesci/devito/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opesci/devito/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opesci/devito/teams","hooks_url":"https://api.github.com/repos/opesci/devito/hooks","issue_events_url":"https://api.github.com/repos/opesci/devito/issues/events{/number}","events_url":"https://api.github.com/repos/opesci/devito/events","assignees_url":"https://api.github.com/repos/opesci/devito/assignees{/user}","branches_url":"https://api.github.com/repos/opesci/devito/branches{/branch}","tags_url":"https://api.github.com/repos/opesci/devito/tags","blobs_url":"https://api.github.com/repos/opesci/devito/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opesci/devito/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opesci/devito/git/refs{/sha}","trees_url":"https://api.github.com/repos/opesci/devito/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opesci/devito/statuses/{sha}","languages_url":"https://api.github.com/repos/opesci/devito/languages","stargazers_url":"https://api.github.com/repos/opesci/devito/stargazers","contributors_url":"https://api.github.com/repos/opesci/devito/contributors","subscribers_url":"https://api.github.com/repos/opesci/devito/subscribers","subscription_url":"https://api.github.com/repos/opesci/devito/subscription","commits_url":"https://api.github.com/repos/opesci/devito/commits{/sha}","git_commits_url":"https://api.github.com/repos/opesci/devito/git/commits{/sha}","comments_url":"https://api.github.com/repos/opesci/devito/comments{/number}","issue_comment_url":"https://api.github.com/repos/opesci/devito/issues/comments{/number}","contents_url":"https://api.github.com/repos/opesci/devito/contents/{+path}","compare_url":"https://api.github.com/repos/opesci/devito/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opesci/devito/merges","archive_url":"https://api.github.com/repos/opesci/devito/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opesci/devito/downloads","issues_url":"https://api.github.com/repos/opesci/devito/issues{/number}","pulls_url":"https://api.github.com/repos/opesci/devito/pulls{/number}","milestones_url":"https://api.github.com/repos/opesci/devito/milestones{/number}","notifications_url":"https://api.github.com/repos/opesci/devito/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opesci/devito/labels{/name}","releases_url":"https://api.github.com/repos/opesci/devito/releases{/id}","deployments_url":"https://api.github.com/repos/opesci/devito/deployments","created_at":"2016-03-23T18:59:49Z","updated_at":"2016-12-07T10:07:37Z","pushed_at":"2016-12-15T01:06:06Z","git_url":"git://github.com/opesci/devito.git","ssh_url":"git@github.com:opesci/devito.git","clone_url":"https://github.com/opesci/devito.git","svn_url":"https://github.com/opesci/devito","homepage":null,"size":21691,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":7,"default_branch":"master"}},"base":{"label":"opesci:master","ref":"master","sha":"7c6cf41b26aface41b4885b42a5f1fdbbbbcd96e","user":{"login":"opesci","id":10018551,"avatar_url":"https://avatars.githubusercontent.com/u/10018551?v=3","gravatar_id":"","url":"https://api.github.com/users/opesci","html_url":"https://github.com/opesci","followers_url":"https://api.github.com/users/opesci/followers","following_url":"https://api.github.com/users/opesci/following{/other_user}","gists_url":"https://api.github.com/users/opesci/gists{/gist_id}","starred_url":"https://api.github.com/users/opesci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opesci/subscriptions","organizations_url":"https://api.github.com/users/opesci/orgs","repos_url":"https://api.github.com/users/opesci/repos","events_url":"https://api.github.com/users/opesci/events{/privacy}","received_events_url":"https://api.github.com/users/opesci/received_events","type":"Organization","site_admin":false},"repo":{"id":54585666,"name":"devito","full_name":"opesci/devito","owner":{"login":"opesci","id":10018551,"avatar_url":"https://avatars.githubusercontent.com/u/10018551?v=3","gravatar_id":"","url":"https://api.github.com/users/opesci","html_url":"https://github.com/opesci","followers_url":"https://api.github.com/users/opesci/followers","following_url":"https://api.github.com/users/opesci/following{/other_user}","gists_url":"https://api.github.com/users/opesci/gists{/gist_id}","starred_url":"https://api.github.com/users/opesci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opesci/subscriptions","organizations_url":"https://api.github.com/users/opesci/orgs","repos_url":"https://api.github.com/users/opesci/repos","events_url":"https://api.github.com/users/opesci/events{/privacy}","received_events_url":"https://api.github.com/users/opesci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opesci/devito","description":"Code generation for the inversion workflow","fork":false,"url":"https://api.github.com/repos/opesci/devito","forks_url":"https://api.github.com/repos/opesci/devito/forks","keys_url":"https://api.github.com/repos/opesci/devito/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opesci/devito/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opesci/devito/teams","hooks_url":"https://api.github.com/repos/opesci/devito/hooks","issue_events_url":"https://api.github.com/repos/opesci/devito/issues/events{/number}","events_url":"https://api.github.com/repos/opesci/devito/events","assignees_url":"https://api.github.com/repos/opesci/devito/assignees{/user}","branches_url":"https://api.github.com/repos/opesci/devito/branches{/branch}","tags_url":"https://api.github.com/repos/opesci/devito/tags","blobs_url":"https://api.github.com/repos/opesci/devito/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opesci/devito/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opesci/devito/git/refs{/sha}","trees_url":"https://api.github.com/repos/opesci/devito/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opesci/devito/statuses/{sha}","languages_url":"https://api.github.com/repos/opesci/devito/languages","stargazers_url":"https://api.github.com/repos/opesci/devito/stargazers","contributors_url":"https://api.github.com/repos/opesci/devito/contributors","subscribers_url":"https://api.github.com/repos/opesci/devito/subscribers","subscription_url":"https://api.github.com/repos/opesci/devito/subscription","commits_url":"https://api.github.com/repos/opesci/devito/commits{/sha}","git_commits_url":"https://api.github.com/repos/opesci/devito/git/commits{/sha}","comments_url":"https://api.github.com/repos/opesci/devito/comments{/number}","issue_comment_url":"https://api.github.com/repos/opesci/devito/issues/comments{/number}","contents_url":"https://api.github.com/repos/opesci/devito/contents/{+path}","compare_url":"https://api.github.com/repos/opesci/devito/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opesci/devito/merges","archive_url":"https://api.github.com/repos/opesci/devito/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opesci/devito/downloads","issues_url":"https://api.github.com/repos/opesci/devito/issues{/number}","pulls_url":"https://api.github.com/repos/opesci/devito/pulls{/number}","milestones_url":"https://api.github.com/repos/opesci/devito/milestones{/number}","notifications_url":"https://api.github.com/repos/opesci/devito/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opesci/devito/labels{/name}","releases_url":"https://api.github.com/repos/opesci/devito/releases{/id}","deployments_url":"https://api.github.com/repos/opesci/devito/deployments","created_at":"2016-03-23T18:59:49Z","updated_at":"2016-12-07T10:07:37Z","pushed_at":"2016-12-15T01:06:06Z","git_url":"git://github.com/opesci/devito.git","ssh_url":"git@github.com:opesci/devito.git","clone_url":"https://github.com/opesci/devito.git","svn_url":"https://github.com/opesci/devito","homepage":null,"size":21691,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opesci/devito/pulls/162"},"html":{"href":"https://github.com/opesci/devito/pull/162"},"issue":{"href":"https://api.github.com/repos/opesci/devito/issues/162"},"comments":{"href":"https://api.github.com/repos/opesci/devito/issues/162/comments"},"review_comments":{"href":"https://api.github.com/repos/opesci/devito/pulls/162/comments"},"review_comment":{"href":"https://api.github.com/repos/opesci/devito/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opesci/devito/pulls/162/commits"},"statuses":{"href":"https://api.github.com/repos/opesci/devito/statuses/8b37f4087eb05fdfe7826390321eb4057d39a28e"}}}}
{"actor":{"display_login":"FabioLuporini"}}