{"action":"created","comment":{"url":"https://api.github.com/repos/quiltdata/quilt/pulls/comments/198975884","pull_request_review_id":133005266,"id":198975884,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODk3NTg4NA==","diff_hunk":"@@ -0,0 +1,85 @@\n+# Copyright 2018, Quilt Data Inc.\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#    http://www.apache.org/licenses/LICENSE-2.0\n+\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+\"\"\"Convenience functions for displaying images in Jupyter notebooks.\n+\n+`pip install quilt[img]`\n+\n+Or, in development:\n+`pip install -e ./[img]`\n+\"\"\"\n+\n+from math import ceil, floor, sqrt\n+from six import string_types\n+\n+#from PIL import Image\n+import matplotlib.pyplot as plt\n+import matplotlib.image as mpimg\n+\n+from quilt.nodes import DataNode, GroupNode\n+from quilt.tools.build import splitext_no_dot\n+\n+def plot(figsize=(10, 10), formats=None, limit=100, titlelen=10, **kwargs):\n+    \"\"\"Display an image [in a Jupyter Notebook] from a Quilt fragment path.\n+    Intended for use with `%matplotlib inline`.\n+\n+    Convenience method for looping over supblots that call\n+    `plt.imshow(image.imread(FILE_PATH))`.\n+\n+    Keyword arguments\n+    * figsize=(10, 10) # (HEIGHT_INCHES, WIDTH_INCHES)\n+    * formats=None # only display images with these extensions\n+    * limit=100 # maximum number of images to display\n+    * titlelen=10 # max number of characters in subplot title\n+    * **kwargs - all remaining kwargs are passed to plt.subplots;\n+      see https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots.html\n+    \"\"\"\n+    # pylint: disable=protected-access\n+    def _plot(node, paths):\n+        # assume DataNode with one path; doesn't work with multi-fragment images\n+        display = [('', paths[0], node._meta)]\n+        # for GroupNodes display all DataNode children\n+        if isinstance(node, GroupNode):\n+            datanodes = [(x, y) for (x, y) in node._items() if isinstance(y, DataNode)]\n+            display = [(x, y._data(), y._meta) for (x, y) in datanodes]\n+            if len(display) > limit:\n+                print('Displaying {} of {} images...'.format(limit, len(display)))\n+                display = display[:limit]\n+        # display can be empty e.g. if no DataNode children\n+        if not len(display):\n+            return\n+        # cast to int to avoid downstream complaints of\n+        # 'float' object cannot be interpreted as an index\n+        floatlen = float(len(display)) # so we can ceil\n+        cols = int(floor(sqrt(floatlen)))\n+        rows = int(ceil(floatlen/cols))\n+        plt.tight_layout()\n+        plt.subplots(rows, cols, figsize=figsize, **kwargs)\n+\n+        for i, (name, file, meta) in enumerate(display):\n+            filepath = meta.get('_system', {}).get('filepath', None)\n+            # don't try to read DataFrames as images\n+            if isinstance(file, string_types) and filepath:\n+                path, ext = splitext_no_dot(filepath) # pylint: disable=unused-variable\n+                if formats and ext.lower() not in [x.lower() for x in formats]:","path":"compiler/quilt/asa/img.py","position":73,"original_position":73,"commit_id":"be0475dc0716a4ff971fc806404ac5dfe9787d3f","original_commit_id":"be0475dc0716a4ff971fc806404ac5dfe9787d3f","user":{"login":"dimaryaz","id":4365877,"node_id":"MDQ6VXNlcjQzNjU4Nzc=","avatar_url":"https://avatars3.githubusercontent.com/u/4365877?v=4","gravatar_id":"","url":"https://api.github.com/users/dimaryaz","html_url":"https://github.com/dimaryaz","followers_url":"https://api.github.com/users/dimaryaz/followers","following_url":"https://api.github.com/users/dimaryaz/following{/other_user}","gists_url":"https://api.github.com/users/dimaryaz/gists{/gist_id}","starred_url":"https://api.github.com/users/dimaryaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimaryaz/subscriptions","organizations_url":"https://api.github.com/users/dimaryaz/orgs","repos_url":"https://api.github.com/users/dimaryaz/repos","events_url":"https://api.github.com/users/dimaryaz/events{/privacy}","received_events_url":"https://api.github.com/users/dimaryaz/received_events","type":"User","site_admin":false},"body":"Use parens - i.e., `(x.lower() ...)` - to avoid creating a list unnecessarily","created_at":"2018-06-28T20:31:23Z","updated_at":"2018-06-28T20:32:24Z","html_url":"https://github.com/quiltdata/quilt/pull/663#discussion_r198975884","pull_request_url":"https://api.github.com/repos/quiltdata/quilt/pulls/663","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/comments/198975884"},"html":{"href":"https://github.com/quiltdata/quilt/pull/663#discussion_r198975884"},"pull_request":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/663"}}},"pull_request":{"url":"https://api.github.com/repos/quiltdata/quilt/pulls/663","id":195703275,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1NzAzMjc1","html_url":"https://github.com/quiltdata/quilt/pull/663","diff_url":"https://github.com/quiltdata/quilt/pull/663.diff","patch_url":"https://github.com/quiltdata/quilt/pull/663.patch","issue_url":"https://api.github.com/repos/quiltdata/quilt/issues/663","number":663,"state":"open","locked":false,"title":"Convenience `asa.plot` to display images from packages","user":{"login":"akarve","id":1322715,"node_id":"MDQ6VXNlcjEzMjI3MTU=","avatar_url":"https://avatars0.githubusercontent.com/u/1322715?v=4","gravatar_id":"","url":"https://api.github.com/users/akarve","html_url":"https://github.com/akarve","followers_url":"https://api.github.com/users/akarve/followers","following_url":"https://api.github.com/users/akarve/following{/other_user}","gists_url":"https://api.github.com/users/akarve/gists{/gist_id}","starred_url":"https://api.github.com/users/akarve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akarve/subscriptions","organizations_url":"https://api.github.com/users/akarve/orgs","repos_url":"https://api.github.com/users/akarve/repos","events_url":"https://api.github.com/users/akarve/events{/privacy}","received_events_url":"https://api.github.com/users/akarve/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-19T03:32:48Z","updated_at":"2018-06-28T20:32:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ad08adc9b7f10b1292528637ddadca79a1f4174","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/quiltdata/quilt/pulls/663/commits","review_comments_url":"https://api.github.com/repos/quiltdata/quilt/pulls/663/comments","review_comment_url":"https://api.github.com/repos/quiltdata/quilt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quiltdata/quilt/issues/663/comments","statuses_url":"https://api.github.com/repos/quiltdata/quilt/statuses/be0475dc0716a4ff971fc806404ac5dfe9787d3f","head":{"label":"quiltdata:asaplot","ref":"asaplot","sha":"be0475dc0716a4ff971fc806404ac5dfe9787d3f","user":{"login":"quiltdata","id":17112125,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MTEyMTI1","avatar_url":"https://avatars3.githubusercontent.com/u/17112125?v=4","gravatar_id":"","url":"https://api.github.com/users/quiltdata","html_url":"https://github.com/quiltdata","followers_url":"https://api.github.com/users/quiltdata/followers","following_url":"https://api.github.com/users/quiltdata/following{/other_user}","gists_url":"https://api.github.com/users/quiltdata/gists{/gist_id}","starred_url":"https://api.github.com/users/quiltdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quiltdata/subscriptions","organizations_url":"https://api.github.com/users/quiltdata/orgs","repos_url":"https://api.github.com/users/quiltdata/repos","events_url":"https://api.github.com/users/quiltdata/events{/privacy}","received_events_url":"https://api.github.com/users/quiltdata/received_events","type":"Organization","site_admin":false},"repo":{"id":81518954,"node_id":"MDEwOlJlcG9zaXRvcnk4MTUxODk1NA==","name":"quilt","full_name":"quiltdata/quilt","owner":{"login":"quiltdata","id":17112125,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MTEyMTI1","avatar_url":"https://avatars3.githubusercontent.com/u/17112125?v=4","gravatar_id":"","url":"https://api.github.com/users/quiltdata","html_url":"https://github.com/quiltdata","followers_url":"https://api.github.com/users/quiltdata/followers","following_url":"https://api.github.com/users/quiltdata/following{/other_user}","gists_url":"https://api.github.com/users/quiltdata/gists{/gist_id}","starred_url":"https://api.github.com/users/quiltdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quiltdata/subscriptions","organizations_url":"https://api.github.com/users/quiltdata/orgs","repos_url":"https://api.github.com/users/quiltdata/repos","events_url":"https://api.github.com/users/quiltdata/events{/privacy}","received_events_url":"https://api.github.com/users/quiltdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quiltdata/quilt","description":"Quilt versions and deploys data","fork":false,"url":"https://api.github.com/repos/quiltdata/quilt","forks_url":"https://api.github.com/repos/quiltdata/quilt/forks","keys_url":"https://api.github.com/repos/quiltdata/quilt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quiltdata/quilt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quiltdata/quilt/teams","hooks_url":"https://api.github.com/repos/quiltdata/quilt/hooks","issue_events_url":"https://api.github.com/repos/quiltdata/quilt/issues/events{/number}","events_url":"https://api.github.com/repos/quiltdata/quilt/events","assignees_url":"https://api.github.com/repos/quiltdata/quilt/assignees{/user}","branches_url":"https://api.github.com/repos/quiltdata/quilt/branches{/branch}","tags_url":"https://api.github.com/repos/quiltdata/quilt/tags","blobs_url":"https://api.github.com/repos/quiltdata/quilt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quiltdata/quilt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quiltdata/quilt/git/refs{/sha}","trees_url":"https://api.github.com/repos/quiltdata/quilt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quiltdata/quilt/statuses/{sha}","languages_url":"https://api.github.com/repos/quiltdata/quilt/languages","stargazers_url":"https://api.github.com/repos/quiltdata/quilt/stargazers","contributors_url":"https://api.github.com/repos/quiltdata/quilt/contributors","subscribers_url":"https://api.github.com/repos/quiltdata/quilt/subscribers","subscription_url":"https://api.github.com/repos/quiltdata/quilt/subscription","commits_url":"https://api.github.com/repos/quiltdata/quilt/commits{/sha}","git_commits_url":"https://api.github.com/repos/quiltdata/quilt/git/commits{/sha}","comments_url":"https://api.github.com/repos/quiltdata/quilt/comments{/number}","issue_comment_url":"https://api.github.com/repos/quiltdata/quilt/issues/comments{/number}","contents_url":"https://api.github.com/repos/quiltdata/quilt/contents/{+path}","compare_url":"https://api.github.com/repos/quiltdata/quilt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quiltdata/quilt/merges","archive_url":"https://api.github.com/repos/quiltdata/quilt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quiltdata/quilt/downloads","issues_url":"https://api.github.com/repos/quiltdata/quilt/issues{/number}","pulls_url":"https://api.github.com/repos/quiltdata/quilt/pulls{/number}","milestones_url":"https://api.github.com/repos/quiltdata/quilt/milestones{/number}","notifications_url":"https://api.github.com/repos/quiltdata/quilt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quiltdata/quilt/labels{/name}","releases_url":"https://api.github.com/repos/quiltdata/quilt/releases{/id}","deployments_url":"https://api.github.com/repos/quiltdata/quilt/deployments","created_at":"2017-02-10T02:46:03Z","updated_at":"2018-06-28T00:26:48Z","pushed_at":"2018-06-28T18:59:50Z","git_url":"git://github.com/quiltdata/quilt.git","ssh_url":"git@github.com:quiltdata/quilt.git","clone_url":"https://github.com/quiltdata/quilt.git","svn_url":"https://github.com/quiltdata/quilt","homepage":"https://quiltdata.com","size":10245,"stargazers_count":539,"watchers_count":539,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":26,"open_issues":32,"watchers":539,"default_branch":"master"}},"base":{"label":"quiltdata:master","ref":"master","sha":"d40eabbb382a88e622f75b6f50c8b6752eae133a","user":{"login":"quiltdata","id":17112125,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MTEyMTI1","avatar_url":"https://avatars3.githubusercontent.com/u/17112125?v=4","gravatar_id":"","url":"https://api.github.com/users/quiltdata","html_url":"https://github.com/quiltdata","followers_url":"https://api.github.com/users/quiltdata/followers","following_url":"https://api.github.com/users/quiltdata/following{/other_user}","gists_url":"https://api.github.com/users/quiltdata/gists{/gist_id}","starred_url":"https://api.github.com/users/quiltdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quiltdata/subscriptions","organizations_url":"https://api.github.com/users/quiltdata/orgs","repos_url":"https://api.github.com/users/quiltdata/repos","events_url":"https://api.github.com/users/quiltdata/events{/privacy}","received_events_url":"https://api.github.com/users/quiltdata/received_events","type":"Organization","site_admin":false},"repo":{"id":81518954,"node_id":"MDEwOlJlcG9zaXRvcnk4MTUxODk1NA==","name":"quilt","full_name":"quiltdata/quilt","owner":{"login":"quiltdata","id":17112125,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3MTEyMTI1","avatar_url":"https://avatars3.githubusercontent.com/u/17112125?v=4","gravatar_id":"","url":"https://api.github.com/users/quiltdata","html_url":"https://github.com/quiltdata","followers_url":"https://api.github.com/users/quiltdata/followers","following_url":"https://api.github.com/users/quiltdata/following{/other_user}","gists_url":"https://api.github.com/users/quiltdata/gists{/gist_id}","starred_url":"https://api.github.com/users/quiltdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quiltdata/subscriptions","organizations_url":"https://api.github.com/users/quiltdata/orgs","repos_url":"https://api.github.com/users/quiltdata/repos","events_url":"https://api.github.com/users/quiltdata/events{/privacy}","received_events_url":"https://api.github.com/users/quiltdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quiltdata/quilt","description":"Quilt versions and deploys data","fork":false,"url":"https://api.github.com/repos/quiltdata/quilt","forks_url":"https://api.github.com/repos/quiltdata/quilt/forks","keys_url":"https://api.github.com/repos/quiltdata/quilt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quiltdata/quilt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quiltdata/quilt/teams","hooks_url":"https://api.github.com/repos/quiltdata/quilt/hooks","issue_events_url":"https://api.github.com/repos/quiltdata/quilt/issues/events{/number}","events_url":"https://api.github.com/repos/quiltdata/quilt/events","assignees_url":"https://api.github.com/repos/quiltdata/quilt/assignees{/user}","branches_url":"https://api.github.com/repos/quiltdata/quilt/branches{/branch}","tags_url":"https://api.github.com/repos/quiltdata/quilt/tags","blobs_url":"https://api.github.com/repos/quiltdata/quilt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quiltdata/quilt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quiltdata/quilt/git/refs{/sha}","trees_url":"https://api.github.com/repos/quiltdata/quilt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quiltdata/quilt/statuses/{sha}","languages_url":"https://api.github.com/repos/quiltdata/quilt/languages","stargazers_url":"https://api.github.com/repos/quiltdata/quilt/stargazers","contributors_url":"https://api.github.com/repos/quiltdata/quilt/contributors","subscribers_url":"https://api.github.com/repos/quiltdata/quilt/subscribers","subscription_url":"https://api.github.com/repos/quiltdata/quilt/subscription","commits_url":"https://api.github.com/repos/quiltdata/quilt/commits{/sha}","git_commits_url":"https://api.github.com/repos/quiltdata/quilt/git/commits{/sha}","comments_url":"https://api.github.com/repos/quiltdata/quilt/comments{/number}","issue_comment_url":"https://api.github.com/repos/quiltdata/quilt/issues/comments{/number}","contents_url":"https://api.github.com/repos/quiltdata/quilt/contents/{+path}","compare_url":"https://api.github.com/repos/quiltdata/quilt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quiltdata/quilt/merges","archive_url":"https://api.github.com/repos/quiltdata/quilt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quiltdata/quilt/downloads","issues_url":"https://api.github.com/repos/quiltdata/quilt/issues{/number}","pulls_url":"https://api.github.com/repos/quiltdata/quilt/pulls{/number}","milestones_url":"https://api.github.com/repos/quiltdata/quilt/milestones{/number}","notifications_url":"https://api.github.com/repos/quiltdata/quilt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quiltdata/quilt/labels{/name}","releases_url":"https://api.github.com/repos/quiltdata/quilt/releases{/id}","deployments_url":"https://api.github.com/repos/quiltdata/quilt/deployments","created_at":"2017-02-10T02:46:03Z","updated_at":"2018-06-28T00:26:48Z","pushed_at":"2018-06-28T18:59:50Z","git_url":"git://github.com/quiltdata/quilt.git","ssh_url":"git@github.com:quiltdata/quilt.git","clone_url":"https://github.com/quiltdata/quilt.git","svn_url":"https://github.com/quiltdata/quilt","homepage":"https://quiltdata.com","size":10245,"stargazers_count":539,"watchers_count":539,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":26,"open_issues":32,"watchers":539,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/663"},"html":{"href":"https://github.com/quiltdata/quilt/pull/663"},"issue":{"href":"https://api.github.com/repos/quiltdata/quilt/issues/663"},"comments":{"href":"https://api.github.com/repos/quiltdata/quilt/issues/663/comments"},"review_comments":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/663/comments"},"review_comment":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quiltdata/quilt/pulls/663/commits"},"statuses":{"href":"https://api.github.com/repos/quiltdata/quilt/statuses/be0475dc0716a4ff971fc806404ac5dfe9787d3f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dimaryaz"}}