{"action":"created","comment":{"url":"https://api.github.com/repos/nengo/nengo_viz/pulls/comments/30994516","id":30994516,"diff_hunk":"@@ -0,0 +1,54 @@\n+import nengo\n+import numpy as np\n+import struct\n+\n+from nengo_viz.components.component import Component, Template\n+\n+\n+class Voltage(Component):\n+    def __init__(self, viz, config, uid, obj, n_neurons=5):\n+        super(Voltage, self).__init__(viz, config, uid)\n+        self.viz = viz\n+        self.obj = obj.neurons\n+        self.data = []\n+        self.label = viz.viz.get_label(obj)\n+        self.max_neurons = self.obj.size_out\n+        self.n_neurons = min(n_neurons, self.max_neurons)\n+        self.struct = struct.Struct('<%df' % (1 + self.n_neurons))\n+\n+    def add_nengo_objects(self, viz):\n+        with viz.model:\n+            self.probe = nengo.Probe(self.obj[:self.n_neurons], 'voltage')\n+\n+    def remove_nengo_objects(self, viz):\n+        viz.model.probes.remove(self.probe)\n+\n+    def format_data(self, t, x):\n+        data = self.struct.pack(t, *x[:self.n_neurons])\n+        self.data.append(data)\n+\n+    def update_client(self, client):\n+        sim = self.viz.sim\n+        if sim is None:\n+            return\n+\n+        # TODO: this is hack to delete probe data in Nengo 2.0.1, since we\n+        # can't limit the size of probes. Fix this up with Nengo 2.1.\n+        data = sim.data.raw[self.probe][:]\n+        del sim.data.raw[self.probe][:]  # clear the data\n+        trange = sim.trange()[-len(data):]\n+\n+        for t, datum in zip(trange, data):\n+            packet = self.struct.pack(t, *datum)\n+            client.write(packet, binary=True)\n+\n+    def javascript(self):\n+        info = dict(uid=self.uid, label=self.label,\n+                    n_lines=self.n_neurons, synapse=0)\n+        json = self.javascript_config(info)\n+        return 'new VIZ.Value(main, sim, %s);' % json","path":"nengo_viz/components/voltage.py","position":49,"original_position":49,"commit_id":"18ee725d7e21d0aa8661336753673b85699fb5b3","original_commit_id":"18ee725d7e21d0aa8661336753673b85699fb5b3","user":{"login":"tcstewar","id":2380772,"avatar_url":"https://avatars.githubusercontent.com/u/2380772?v=3","gravatar_id":"","url":"https://api.github.com/users/tcstewar","html_url":"https://github.com/tcstewar","followers_url":"https://api.github.com/users/tcstewar/followers","following_url":"https://api.github.com/users/tcstewar/following{/other_user}","gists_url":"https://api.github.com/users/tcstewar/gists{/gist_id}","starred_url":"https://api.github.com/users/tcstewar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcstewar/subscriptions","organizations_url":"https://api.github.com/users/tcstewar/orgs","repos_url":"https://api.github.com/users/tcstewar/repos","events_url":"https://api.github.com/users/tcstewar/events{/privacy}","received_events_url":"https://api.github.com/users/tcstewar/received_events","type":"User","site_admin":false},"body":"Ah, that's a good point.  Some refactoring would be needed here.  In fact, this may be similar to some of the refactoring @jgosmann did in his \"all is relative\" branch.  So it probably makes sense to leave this as it is and deal with it when we start wanting separate features for the value graph and the voltage graph.","created_at":"2015-05-25T20:57:54Z","updated_at":"2015-05-25T20:57:54Z","html_url":"https://github.com/nengo/nengo_viz/pull/154#discussion_r30994516","pull_request_url":"https://api.github.com/repos/nengo/nengo_viz/pulls/154","_links":{"self":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/comments/30994516"},"html":{"href":"https://github.com/nengo/nengo_viz/pull/154#discussion_r30994516"},"pull_request":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/154"}}},"pull_request":{"url":"https://api.github.com/repos/nengo/nengo_viz/pulls/154","id":35783473,"html_url":"https://github.com/nengo/nengo_viz/pull/154","diff_url":"https://github.com/nengo/nengo_viz/pull/154.diff","patch_url":"https://github.com/nengo/nengo_viz/pull/154.patch","issue_url":"https://api.github.com/repos/nengo/nengo_viz/issues/154","number":154,"state":"open","locked":false,"title":"Voltage plots","user":{"login":"hunse","id":1952250,"avatar_url":"https://avatars.githubusercontent.com/u/1952250?v=3","gravatar_id":"","url":"https://api.github.com/users/hunse","html_url":"https://github.com/hunse","followers_url":"https://api.github.com/users/hunse/followers","following_url":"https://api.github.com/users/hunse/following{/other_user}","gists_url":"https://api.github.com/users/hunse/gists{/gist_id}","starred_url":"https://api.github.com/users/hunse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunse/subscriptions","organizations_url":"https://api.github.com/users/hunse/orgs","repos_url":"https://api.github.com/users/hunse/repos","events_url":"https://api.github.com/users/hunse/events{/privacy}","received_events_url":"https://api.github.com/users/hunse/received_events","type":"User","site_admin":false},"body":"Here's a first stab at a voltage plot. I tested it on `basic.py`, and though the output looks a little funny, it's actually correct (I checked it with plotting directly using matplotlib). The funniness is due to the filtering; maybe we want to reduce or turn off the filtering for voltage plots?","created_at":"2015-05-19T22:54:41Z","updated_at":"2015-05-25T20:57:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9625115d2654d29250f8eb1320c6c75e709e91f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nengo/nengo_viz/pulls/154/commits","review_comments_url":"https://api.github.com/repos/nengo/nengo_viz/pulls/154/comments","review_comment_url":"https://api.github.com/repos/nengo/nengo_viz/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nengo/nengo_viz/issues/154/comments","statuses_url":"https://api.github.com/repos/nengo/nengo_viz/statuses/18ee725d7e21d0aa8661336753673b85699fb5b3","head":{"label":"nengo:voltages","ref":"voltages","sha":"18ee725d7e21d0aa8661336753673b85699fb5b3","user":{"login":"nengo","id":9197486,"avatar_url":"https://avatars.githubusercontent.com/u/9197486?v=3","gravatar_id":"","url":"https://api.github.com/users/nengo","html_url":"https://github.com/nengo","followers_url":"https://api.github.com/users/nengo/followers","following_url":"https://api.github.com/users/nengo/following{/other_user}","gists_url":"https://api.github.com/users/nengo/gists{/gist_id}","starred_url":"https://api.github.com/users/nengo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nengo/subscriptions","organizations_url":"https://api.github.com/users/nengo/orgs","repos_url":"https://api.github.com/users/nengo/repos","events_url":"https://api.github.com/users/nengo/events{/privacy}","received_events_url":"https://api.github.com/users/nengo/received_events","type":"Organization","site_admin":false},"repo":{"id":28949681,"name":"nengo_viz","full_name":"nengo/nengo_viz","owner":{"login":"nengo","id":9197486,"avatar_url":"https://avatars.githubusercontent.com/u/9197486?v=3","gravatar_id":"","url":"https://api.github.com/users/nengo","html_url":"https://github.com/nengo","followers_url":"https://api.github.com/users/nengo/followers","following_url":"https://api.github.com/users/nengo/following{/other_user}","gists_url":"https://api.github.com/users/nengo/gists{/gist_id}","starred_url":"https://api.github.com/users/nengo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nengo/subscriptions","organizations_url":"https://api.github.com/users/nengo/orgs","repos_url":"https://api.github.com/users/nengo/repos","events_url":"https://api.github.com/users/nengo/events{/privacy}","received_events_url":"https://api.github.com/users/nengo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nengo/nengo_viz","description":"Nengo interactive visualizer","fork":false,"url":"https://api.github.com/repos/nengo/nengo_viz","forks_url":"https://api.github.com/repos/nengo/nengo_viz/forks","keys_url":"https://api.github.com/repos/nengo/nengo_viz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nengo/nengo_viz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nengo/nengo_viz/teams","hooks_url":"https://api.github.com/repos/nengo/nengo_viz/hooks","issue_events_url":"https://api.github.com/repos/nengo/nengo_viz/issues/events{/number}","events_url":"https://api.github.com/repos/nengo/nengo_viz/events","assignees_url":"https://api.github.com/repos/nengo/nengo_viz/assignees{/user}","branches_url":"https://api.github.com/repos/nengo/nengo_viz/branches{/branch}","tags_url":"https://api.github.com/repos/nengo/nengo_viz/tags","blobs_url":"https://api.github.com/repos/nengo/nengo_viz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nengo/nengo_viz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nengo/nengo_viz/git/refs{/sha}","trees_url":"https://api.github.com/repos/nengo/nengo_viz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nengo/nengo_viz/statuses/{sha}","languages_url":"https://api.github.com/repos/nengo/nengo_viz/languages","stargazers_url":"https://api.github.com/repos/nengo/nengo_viz/stargazers","contributors_url":"https://api.github.com/repos/nengo/nengo_viz/contributors","subscribers_url":"https://api.github.com/repos/nengo/nengo_viz/subscribers","subscription_url":"https://api.github.com/repos/nengo/nengo_viz/subscription","commits_url":"https://api.github.com/repos/nengo/nengo_viz/commits{/sha}","git_commits_url":"https://api.github.com/repos/nengo/nengo_viz/git/commits{/sha}","comments_url":"https://api.github.com/repos/nengo/nengo_viz/comments{/number}","issue_comment_url":"https://api.github.com/repos/nengo/nengo_viz/issues/comments{/number}","contents_url":"https://api.github.com/repos/nengo/nengo_viz/contents/{+path}","compare_url":"https://api.github.com/repos/nengo/nengo_viz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nengo/nengo_viz/merges","archive_url":"https://api.github.com/repos/nengo/nengo_viz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nengo/nengo_viz/downloads","issues_url":"https://api.github.com/repos/nengo/nengo_viz/issues{/number}","pulls_url":"https://api.github.com/repos/nengo/nengo_viz/pulls{/number}","milestones_url":"https://api.github.com/repos/nengo/nengo_viz/milestones{/number}","notifications_url":"https://api.github.com/repos/nengo/nengo_viz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nengo/nengo_viz/labels{/name}","releases_url":"https://api.github.com/repos/nengo/nengo_viz/releases{/id}","created_at":"2015-01-08T05:00:06Z","updated_at":"2015-05-13T17:58:58Z","pushed_at":"2015-05-25T20:53:15Z","git_url":"git://github.com/nengo/nengo_viz.git","ssh_url":"git@github.com:nengo/nengo_viz.git","clone_url":"https://github.com/nengo/nengo_viz.git","svn_url":"https://github.com/nengo/nengo_viz","homepage":"","size":5033,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":82,"forks":1,"open_issues":82,"watchers":4,"default_branch":"master"}},"base":{"label":"nengo:master","ref":"master","sha":"2e3cd89c86b37f4d8fdd2adcb53e6225347e74f0","user":{"login":"nengo","id":9197486,"avatar_url":"https://avatars.githubusercontent.com/u/9197486?v=3","gravatar_id":"","url":"https://api.github.com/users/nengo","html_url":"https://github.com/nengo","followers_url":"https://api.github.com/users/nengo/followers","following_url":"https://api.github.com/users/nengo/following{/other_user}","gists_url":"https://api.github.com/users/nengo/gists{/gist_id}","starred_url":"https://api.github.com/users/nengo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nengo/subscriptions","organizations_url":"https://api.github.com/users/nengo/orgs","repos_url":"https://api.github.com/users/nengo/repos","events_url":"https://api.github.com/users/nengo/events{/privacy}","received_events_url":"https://api.github.com/users/nengo/received_events","type":"Organization","site_admin":false},"repo":{"id":28949681,"name":"nengo_viz","full_name":"nengo/nengo_viz","owner":{"login":"nengo","id":9197486,"avatar_url":"https://avatars.githubusercontent.com/u/9197486?v=3","gravatar_id":"","url":"https://api.github.com/users/nengo","html_url":"https://github.com/nengo","followers_url":"https://api.github.com/users/nengo/followers","following_url":"https://api.github.com/users/nengo/following{/other_user}","gists_url":"https://api.github.com/users/nengo/gists{/gist_id}","starred_url":"https://api.github.com/users/nengo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nengo/subscriptions","organizations_url":"https://api.github.com/users/nengo/orgs","repos_url":"https://api.github.com/users/nengo/repos","events_url":"https://api.github.com/users/nengo/events{/privacy}","received_events_url":"https://api.github.com/users/nengo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nengo/nengo_viz","description":"Nengo interactive visualizer","fork":false,"url":"https://api.github.com/repos/nengo/nengo_viz","forks_url":"https://api.github.com/repos/nengo/nengo_viz/forks","keys_url":"https://api.github.com/repos/nengo/nengo_viz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nengo/nengo_viz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nengo/nengo_viz/teams","hooks_url":"https://api.github.com/repos/nengo/nengo_viz/hooks","issue_events_url":"https://api.github.com/repos/nengo/nengo_viz/issues/events{/number}","events_url":"https://api.github.com/repos/nengo/nengo_viz/events","assignees_url":"https://api.github.com/repos/nengo/nengo_viz/assignees{/user}","branches_url":"https://api.github.com/repos/nengo/nengo_viz/branches{/branch}","tags_url":"https://api.github.com/repos/nengo/nengo_viz/tags","blobs_url":"https://api.github.com/repos/nengo/nengo_viz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nengo/nengo_viz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nengo/nengo_viz/git/refs{/sha}","trees_url":"https://api.github.com/repos/nengo/nengo_viz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nengo/nengo_viz/statuses/{sha}","languages_url":"https://api.github.com/repos/nengo/nengo_viz/languages","stargazers_url":"https://api.github.com/repos/nengo/nengo_viz/stargazers","contributors_url":"https://api.github.com/repos/nengo/nengo_viz/contributors","subscribers_url":"https://api.github.com/repos/nengo/nengo_viz/subscribers","subscription_url":"https://api.github.com/repos/nengo/nengo_viz/subscription","commits_url":"https://api.github.com/repos/nengo/nengo_viz/commits{/sha}","git_commits_url":"https://api.github.com/repos/nengo/nengo_viz/git/commits{/sha}","comments_url":"https://api.github.com/repos/nengo/nengo_viz/comments{/number}","issue_comment_url":"https://api.github.com/repos/nengo/nengo_viz/issues/comments{/number}","contents_url":"https://api.github.com/repos/nengo/nengo_viz/contents/{+path}","compare_url":"https://api.github.com/repos/nengo/nengo_viz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nengo/nengo_viz/merges","archive_url":"https://api.github.com/repos/nengo/nengo_viz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nengo/nengo_viz/downloads","issues_url":"https://api.github.com/repos/nengo/nengo_viz/issues{/number}","pulls_url":"https://api.github.com/repos/nengo/nengo_viz/pulls{/number}","milestones_url":"https://api.github.com/repos/nengo/nengo_viz/milestones{/number}","notifications_url":"https://api.github.com/repos/nengo/nengo_viz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nengo/nengo_viz/labels{/name}","releases_url":"https://api.github.com/repos/nengo/nengo_viz/releases{/id}","created_at":"2015-01-08T05:00:06Z","updated_at":"2015-05-13T17:58:58Z","pushed_at":"2015-05-25T20:53:15Z","git_url":"git://github.com/nengo/nengo_viz.git","ssh_url":"git@github.com:nengo/nengo_viz.git","clone_url":"https://github.com/nengo/nengo_viz.git","svn_url":"https://github.com/nengo/nengo_viz","homepage":"","size":5033,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":82,"forks":1,"open_issues":82,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/154"},"html":{"href":"https://github.com/nengo/nengo_viz/pull/154"},"issue":{"href":"https://api.github.com/repos/nengo/nengo_viz/issues/154"},"comments":{"href":"https://api.github.com/repos/nengo/nengo_viz/issues/154/comments"},"review_comments":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/154/comments"},"review_comment":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nengo/nengo_viz/pulls/154/commits"},"statuses":{"href":"https://api.github.com/repos/nengo/nengo_viz/statuses/18ee725d7e21d0aa8661336753673b85699fb5b3"}}}}