{"action":"created","comment":{"url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/comments/55925422","id":55925422,"diff_hunk":"@@ -0,0 +1,284 @@\n+\"\"\"Intervals in Theano including special functions for sparsifying.\"\"\"\n+\n+from athenet.sparsifying.utils.numlike import Numlike\n+from theano import function\n+from theano import tensor as T\n+from theano.ifelse import ifelse\n+\n+\n+class Interval(Numlike):\n+    \"\"\"Theano interval class\n+\n+    Note: Should be treated as interval type with bounds as Theano nodes.\n+    Opetations on Interval create nodes in Theano graph.\"\"\"\n+\n+    def __init__(self, lower, upper):\n+        \"\"\"Creates interval.\n+\n+        :lower: lower bound of Interval to be set\n+        :upper: upper bound if Interval to be set\n+\n+        Note: lower must be lower than upper. It is not being checked.\"\"\"\n+        self.lower = lower\n+        self.upper = upper\n+\n+    def __getitem__(self, at):\n+        \"\"\"Returns specified slice of interval as a interval.\n+\n+        :at: Coordinates / slice to be taken.\n+\n+        Does not copy data.\"\"\"\n+        return Interval(self.lower[at], self.upper[at])\n+\n+    def __setitem__(self, at, other):\n+        \"\"\"Just like Theano set_subtensor function, but as a operator.\n+\n+        :at: Coordinates / slice to be set.\n+        :other: Data to be put at 'at'\n+\n+        \"\"\"\n+        self.lower = T.set_subtensor(self.lower[at], other.lower)\n+        self.upper = T.set_subtensor(self.upper[at], other.upper)\n+\n+    def __repr__(self):\n+        \"\"\"Standard repr method.\"\"\"\n+        return '[' + repr(self.lower) + ', ' + repr(self.upper) + ']'\n+\n+    def __str__(self):\n+        \"\"\"\"Standard str method.\"\"\"\n+        return '[' + str(self.lower) + ', ' + str(self.upper) + ']'\n+\n+    def shape(self):\n+        \"\"\"Returns shape of interval. Checks only 'lower' matrix.\n+\n+        Note: does not require self.upper for computations. Therefore it is not\n+        safe, but faster.\"\"\"\n+        return self.lower.shape\n+\n+    def __add__(self, other):\n+        \"\"\"Returns sum of two intervals.\n+\n+        :other: Interval to be added.\"\"\"\n+        if isinstance(other, Interval):\n+            res_lower = self.lower + other.lower\n+            res_upper = self.upper + other.upper\n+        else:\n+            res_lower = self.lower + other\n+            res_upper = self.upper + other\n+        return Interval(res_lower, res_upper)\n+\n+    __radd__ = __add__\n+\n+    def __sub__(self, other):\n+        \"\"\"Returns difference between two intervals.\n+\n+        :other: Interval to be subtracted.\"\"\"\n+        if isinstance(other, Interval):\n+            res_lower = self.lower - other.upper\n+            res_upper = self.upper - other.lower\n+        else:\n+            res_lower = self.lower - other\n+            res_upper = self.upper - other\n+        return Interval(res_lower, res_upper)\n+\n+    def __rsub__(self, other):\n+        \"\"\"Returns diffeerence between number and interval.\n+\n+        :other: A number that self will be subtracted from.\"\"\"\n+        res_lower = other - self.upper\n+        res_upper = other - self.lower\n+        return Interval(res_lower, res_upper)\n+\n+    def __mul__(self, other):\n+        \"\"\"Returns product of two intervals.\n+\n+        :other: Interval to be multiplied.\"\"\"\n+        if isinstance(other, Interval):\n+            ll = self.lower * other.lower\n+            lu = self.lower * other.upper\n+            ul = self.upper * other.lower\n+            uu = self.upper * other.upper\n+            l = T.minimum(ll, lu)\n+            l = T.minimum(l, ul)\n+            l = T.minimum(l, uu)\n+            u = T.maximum(ll, lu)\n+            u = T.maximum(u, ul)\n+            u = T.maximum(u, uu)\n+            return Interval(l, u)\n+        else:\n+            ll = self.lower * other\n+            uu = self.upper * other\n+            l = T.minimum(ll, uu)\n+            u = T.maximum(ll, uu)\n+            return Interval(l, u)\n+\n+    __rmul__ = __mul__\n+\n+    def __div__(self, other):\n+        \"\"\"Returns quotient of self and other.\n+\n+        :other: Divisor.\n+\n+        Note: Divisor should not contain zero.\"\"\"\n+        lower = self.lower\n+        upper = self.upper\n+        if isinstance(other, Interval):\n+            o_lower = other.lower\n+            o_upper = other.upper\n+            A = T.switch(T.gt(o_lower, 0.0), 1, 0)  # not(b_la), b_ua\n+            B = T.switch(T.gt(lower, 0.0), 1, 0)\n+            C = T.switch(T.gt(upper, 0.0), 1, 0)\n+            b_lb = T.or_(T.and_(A, B),\n+                         T.and_(1 - A, C))\n+            b_ub = T.or_(1 - T.or_(A, B),\n+                         T.and_(A, 1 - C))\n+            la = T.switch(A, lower, upper)\n+            ua = T.switch(A, upper, lower)\n+            lb = T.switch(b_lb, o_upper, o_lower)\n+            ub = T.switch(b_ub, o_upper, o_lower)\n+            return Interval(la / lb, ua / ub)\n+        else:\n+            if other > 0:\n+                return Interval(lower / other, upper / other)\n+            else:\n+                return Interval(upper / other, lower / other)\n+\n+    def __rdiv__(self, other):\n+        \"\"\"Returns quotient of other and self.\n+\n+        :other: Divident.\n+\n+        Note: Divisor should not contain zero.\"\"\"","path":"athenet/sparsifying/utils/interval.py","position":151,"original_position":151,"commit_id":"e4b3ebcf25d8dd424c857e05abc967d890cbd031","original_commit_id":"c6f7ecc913401bbceb197cf3f2c59eefbd95aff7","user":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"body":"maybe \"self\" in brackets? Just a suggestion","created_at":"2016-03-12T18:20:47Z","updated_at":"2016-03-12T18:20:47Z","html_url":"https://github.com/heurezjusz/Athenet/pull/8#discussion_r55925422","pull_request_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/comments/55925422"},"html":{"href":"https://github.com/heurezjusz/Athenet/pull/8#discussion_r55925422"},"pull_request":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8","id":60918336,"html_url":"https://github.com/heurezjusz/Athenet/pull/8","diff_url":"https://github.com/heurezjusz/Athenet/pull/8.diff","patch_url":"https://github.com/heurezjusz/Athenet/pull/8.patch","issue_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/8","number":8,"state":"open","locked":false,"title":"Interval","user":{"login":"glogowski-wojciech","id":9470107,"avatar_url":"https://avatars.githubusercontent.com/u/9470107?v=3","gravatar_id":"","url":"https://api.github.com/users/glogowski-wojciech","html_url":"https://github.com/glogowski-wojciech","followers_url":"https://api.github.com/users/glogowski-wojciech/followers","following_url":"https://api.github.com/users/glogowski-wojciech/following{/other_user}","gists_url":"https://api.github.com/users/glogowski-wojciech/gists{/gist_id}","starred_url":"https://api.github.com/users/glogowski-wojciech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glogowski-wojciech/subscriptions","organizations_url":"https://api.github.com/users/glogowski-wojciech/orgs","repos_url":"https://api.github.com/users/glogowski-wojciech/repos","events_url":"https://api.github.com/users/glogowski-wojciech/events{/privacy}","received_events_url":"https://api.github.com/users/glogowski-wojciech/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-26T23:05:38Z","updated_at":"2016-03-12T18:20:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a032fc5748d70e6846c3b2f8f5f1def64efedff","assignee":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8/commits","review_comments_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8/comments","review_comment_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/8/comments","statuses_url":"https://api.github.com/repos/heurezjusz/Athenet/statuses/e4b3ebcf25d8dd424c857e05abc967d890cbd031","head":{"label":"heurezjusz:interval","ref":"interval","sha":"e4b3ebcf25d8dd424c857e05abc967d890cbd031","user":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"repo":{"id":46612711,"name":"Athenet","full_name":"heurezjusz/Athenet","owner":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/heurezjusz/Athenet","description":"Make the network faster","fork":false,"url":"https://api.github.com/repos/heurezjusz/Athenet","forks_url":"https://api.github.com/repos/heurezjusz/Athenet/forks","keys_url":"https://api.github.com/repos/heurezjusz/Athenet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heurezjusz/Athenet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heurezjusz/Athenet/teams","hooks_url":"https://api.github.com/repos/heurezjusz/Athenet/hooks","issue_events_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/events{/number}","events_url":"https://api.github.com/repos/heurezjusz/Athenet/events","assignees_url":"https://api.github.com/repos/heurezjusz/Athenet/assignees{/user}","branches_url":"https://api.github.com/repos/heurezjusz/Athenet/branches{/branch}","tags_url":"https://api.github.com/repos/heurezjusz/Athenet/tags","blobs_url":"https://api.github.com/repos/heurezjusz/Athenet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heurezjusz/Athenet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heurezjusz/Athenet/git/refs{/sha}","trees_url":"https://api.github.com/repos/heurezjusz/Athenet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heurezjusz/Athenet/statuses/{sha}","languages_url":"https://api.github.com/repos/heurezjusz/Athenet/languages","stargazers_url":"https://api.github.com/repos/heurezjusz/Athenet/stargazers","contributors_url":"https://api.github.com/repos/heurezjusz/Athenet/contributors","subscribers_url":"https://api.github.com/repos/heurezjusz/Athenet/subscribers","subscription_url":"https://api.github.com/repos/heurezjusz/Athenet/subscription","commits_url":"https://api.github.com/repos/heurezjusz/Athenet/commits{/sha}","git_commits_url":"https://api.github.com/repos/heurezjusz/Athenet/git/commits{/sha}","comments_url":"https://api.github.com/repos/heurezjusz/Athenet/comments{/number}","issue_comment_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/comments{/number}","contents_url":"https://api.github.com/repos/heurezjusz/Athenet/contents/{+path}","compare_url":"https://api.github.com/repos/heurezjusz/Athenet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heurezjusz/Athenet/merges","archive_url":"https://api.github.com/repos/heurezjusz/Athenet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heurezjusz/Athenet/downloads","issues_url":"https://api.github.com/repos/heurezjusz/Athenet/issues{/number}","pulls_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls{/number}","milestones_url":"https://api.github.com/repos/heurezjusz/Athenet/milestones{/number}","notifications_url":"https://api.github.com/repos/heurezjusz/Athenet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heurezjusz/Athenet/labels{/name}","releases_url":"https://api.github.com/repos/heurezjusz/Athenet/releases{/id}","deployments_url":"https://api.github.com/repos/heurezjusz/Athenet/deployments","created_at":"2015-11-21T11:32:47Z","updated_at":"2016-02-02T12:59:39Z","pushed_at":"2016-03-12T17:48:29Z","git_url":"git://github.com/heurezjusz/Athenet.git","ssh_url":"git@github.com:heurezjusz/Athenet.git","clone_url":"https://github.com/heurezjusz/Athenet.git","svn_url":"https://github.com/heurezjusz/Athenet","homepage":null,"size":4521,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"base":{"label":"heurezjusz:develop","ref":"develop","sha":"1be232217b1e1e97fbd82d30e16e3469ffd18191","user":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"repo":{"id":46612711,"name":"Athenet","full_name":"heurezjusz/Athenet","owner":{"login":"heurezjusz","id":15955224,"avatar_url":"https://avatars.githubusercontent.com/u/15955224?v=3","gravatar_id":"","url":"https://api.github.com/users/heurezjusz","html_url":"https://github.com/heurezjusz","followers_url":"https://api.github.com/users/heurezjusz/followers","following_url":"https://api.github.com/users/heurezjusz/following{/other_user}","gists_url":"https://api.github.com/users/heurezjusz/gists{/gist_id}","starred_url":"https://api.github.com/users/heurezjusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heurezjusz/subscriptions","organizations_url":"https://api.github.com/users/heurezjusz/orgs","repos_url":"https://api.github.com/users/heurezjusz/repos","events_url":"https://api.github.com/users/heurezjusz/events{/privacy}","received_events_url":"https://api.github.com/users/heurezjusz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/heurezjusz/Athenet","description":"Make the network faster","fork":false,"url":"https://api.github.com/repos/heurezjusz/Athenet","forks_url":"https://api.github.com/repos/heurezjusz/Athenet/forks","keys_url":"https://api.github.com/repos/heurezjusz/Athenet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heurezjusz/Athenet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heurezjusz/Athenet/teams","hooks_url":"https://api.github.com/repos/heurezjusz/Athenet/hooks","issue_events_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/events{/number}","events_url":"https://api.github.com/repos/heurezjusz/Athenet/events","assignees_url":"https://api.github.com/repos/heurezjusz/Athenet/assignees{/user}","branches_url":"https://api.github.com/repos/heurezjusz/Athenet/branches{/branch}","tags_url":"https://api.github.com/repos/heurezjusz/Athenet/tags","blobs_url":"https://api.github.com/repos/heurezjusz/Athenet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heurezjusz/Athenet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heurezjusz/Athenet/git/refs{/sha}","trees_url":"https://api.github.com/repos/heurezjusz/Athenet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heurezjusz/Athenet/statuses/{sha}","languages_url":"https://api.github.com/repos/heurezjusz/Athenet/languages","stargazers_url":"https://api.github.com/repos/heurezjusz/Athenet/stargazers","contributors_url":"https://api.github.com/repos/heurezjusz/Athenet/contributors","subscribers_url":"https://api.github.com/repos/heurezjusz/Athenet/subscribers","subscription_url":"https://api.github.com/repos/heurezjusz/Athenet/subscription","commits_url":"https://api.github.com/repos/heurezjusz/Athenet/commits{/sha}","git_commits_url":"https://api.github.com/repos/heurezjusz/Athenet/git/commits{/sha}","comments_url":"https://api.github.com/repos/heurezjusz/Athenet/comments{/number}","issue_comment_url":"https://api.github.com/repos/heurezjusz/Athenet/issues/comments{/number}","contents_url":"https://api.github.com/repos/heurezjusz/Athenet/contents/{+path}","compare_url":"https://api.github.com/repos/heurezjusz/Athenet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heurezjusz/Athenet/merges","archive_url":"https://api.github.com/repos/heurezjusz/Athenet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heurezjusz/Athenet/downloads","issues_url":"https://api.github.com/repos/heurezjusz/Athenet/issues{/number}","pulls_url":"https://api.github.com/repos/heurezjusz/Athenet/pulls{/number}","milestones_url":"https://api.github.com/repos/heurezjusz/Athenet/milestones{/number}","notifications_url":"https://api.github.com/repos/heurezjusz/Athenet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heurezjusz/Athenet/labels{/name}","releases_url":"https://api.github.com/repos/heurezjusz/Athenet/releases{/id}","deployments_url":"https://api.github.com/repos/heurezjusz/Athenet/deployments","created_at":"2015-11-21T11:32:47Z","updated_at":"2016-02-02T12:59:39Z","pushed_at":"2016-03-12T17:48:29Z","git_url":"git://github.com/heurezjusz/Athenet.git","ssh_url":"git@github.com:heurezjusz/Athenet.git","clone_url":"https://github.com/heurezjusz/Athenet.git","svn_url":"https://github.com/heurezjusz/Athenet","homepage":null,"size":4521,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8"},"html":{"href":"https://github.com/heurezjusz/Athenet/pull/8"},"issue":{"href":"https://api.github.com/repos/heurezjusz/Athenet/issues/8"},"comments":{"href":"https://api.github.com/repos/heurezjusz/Athenet/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heurezjusz/Athenet/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/heurezjusz/Athenet/statuses/e4b3ebcf25d8dd424c857e05abc967d890cbd031"}}}}