{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/155943783","pull_request_review_id":82346592,"id":155943783,"diff_hunk":"@@ -0,0 +1,176 @@\n+from sympy.core import Basic\n+import operator\n+\n+class Ordinal(Basic):\n+    \"\"\"\n+    Represents ordinals in Cantor normal form.\n+\n+    Internally, this class is just a list of lists (known\n+    as \"terms\").\n+    In single terms [a, b], a represents power to the ordinal and b represents multiplying factor\n+    Examples\n+    ========\n+    >>> from sympy.sets import Ordinal, Ordinals\n+    >>> Ordinals.w  # doctest: +SKIP\n+    w\n+    >>> a = Ordinals.w\n+    >>> a.is_limit_ordinal\n+    True\n+    >>> Ordinal([[3,2]])  # doctest: +SKIP\n+    {w**3}*2\n+    >>> Ordinal([[5,1],[3,2]])  # doctest: +SKIP\n+    w**5 + {w**3}*2\n+    \"\"\"\n+    def __new__(cls, terms):\n+        obj = super(Ordinal, cls).__new__(cls, *terms)\n+        powers = [i[0] for i in obj.args]\n+        if not all(earlier >= later for earlier, later in zip(powers, powers[1:])):\n+            raise ValueError(\"powers must be in decreasing order\")\n+        return obj\n+\n+    @property\n+    def is_successor_ordinal(self):\n+        return (self.args[-1][0] == 0)\n+\n+    @property\n+    def is_limit_ordinal(self):\n+        return not self.is_successor_ordinal\n+\n+    def _insert_index(self, a, x, lo=0, hi=None):\n+        \"\"\"Return the index where to insert item x in list a,\n+        assuming a is sorted in descending order\n+\n+        Essentially, the function returns number of elements in a which are >= than x.\n+        \"\"\"\n+        if lo < 0:\n+            raise ValueError('lo must be non-negative')\n+        if hi is None:\n+            hi = len(a)\n+        while lo < hi:\n+            mid = (lo+hi)//2\n+            if x > a[mid]: hi = mid\n+            else: lo = mid+1\n+        return lo\n+\n+    def _compare(self, other, index):\n+        value_self = [i[index] for i in self.args]\n+        value_other = [i[index] for i in other.args]\n+        if value_other == value_self:\n+            return -1\n+        else:\n+            return map(operator.eq, value_self, value_other).index(False)\n+\n+    def __eq__(self, other):\n+        if isinstance(other, Ordinal):\n+            return self.args == other.args\n+        else:\n+            return False\n+\n+    def __lt__(self, other):\n+        if isinstance(other, int):","path":"sympy/sets/ordinals.py","position":70,"original_position":70,"commit_id":"38726d7a75d8c388da322a518b5fa51991f2f6f5","original_commit_id":"38726d7a75d8c388da322a518b5fa51991f2f6f5","user":{"login":"jksuom","id":6929119,"avatar_url":"https://avatars3.githubusercontent.com/u/6929119?v=4","gravatar_id":"","url":"https://api.github.com/users/jksuom","html_url":"https://github.com/jksuom","followers_url":"https://api.github.com/users/jksuom/followers","following_url":"https://api.github.com/users/jksuom/following{/other_user}","gists_url":"https://api.github.com/users/jksuom/gists{/gist_id}","starred_url":"https://api.github.com/users/jksuom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jksuom/subscriptions","organizations_url":"https://api.github.com/users/jksuom/orgs","repos_url":"https://api.github.com/users/jksuom/repos","events_url":"https://api.github.com/users/jksuom/events{/privacy}","received_events_url":"https://api.github.com/users/jksuom/received_events","type":"User","site_admin":false},"body":"I would not define automatic comparison of ordinals and ordinary (cardinal) numbers. (There could be a method for converting an integer to a finite ordinal, but that should be used explicitly.) I would return `NotImplemented` when `other` is not an ordinal.","created_at":"2017-12-10T10:34:12Z","updated_at":"2017-12-10T10:34:12Z","html_url":"https://github.com/sympy/sympy/pull/13682#discussion_r155943783","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/13682","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/155943783"},"html":{"href":"https://github.com/sympy/sympy/pull/13682#discussion_r155943783"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13682"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/13682","id":156716327,"html_url":"https://github.com/sympy/sympy/pull/13682","diff_url":"https://github.com/sympy/sympy/pull/13682.diff","patch_url":"https://github.com/sympy/sympy/pull/13682.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/13682","number":13682,"state":"open","locked":false,"title":"[WIP] Implementation of ordinal arithemetics","user":{"login":"ashishkg0022","id":21151623,"avatar_url":"https://avatars1.githubusercontent.com/u/21151623?v=4","gravatar_id":"","url":"https://api.github.com/users/ashishkg0022","html_url":"https://github.com/ashishkg0022","followers_url":"https://api.github.com/users/ashishkg0022/followers","following_url":"https://api.github.com/users/ashishkg0022/following{/other_user}","gists_url":"https://api.github.com/users/ashishkg0022/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishkg0022/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishkg0022/subscriptions","organizations_url":"https://api.github.com/users/ashishkg0022/orgs","repos_url":"https://api.github.com/users/ashishkg0022/repos","events_url":"https://api.github.com/users/ashishkg0022/events{/privacy}","received_events_url":"https://api.github.com/users/ashishkg0022/received_events","type":"User","site_admin":false},"body":"implemented ordinal arithemetics\r\nFixes #8668 \r\n","created_at":"2017-12-06T12:25:36Z","updated_at":"2017-12-10T10:34:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8a3015d77a7ec1c53ef01c5ab7896228c7cb579","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/13682/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/13682/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/13682/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/38726d7a75d8c388da322a518b5fa51991f2f6f5","head":{"label":"ashishkg0022:ordinals_arihemetic","ref":"ordinals_arihemetic","sha":"38726d7a75d8c388da322a518b5fa51991f2f6f5","user":{"login":"ashishkg0022","id":21151623,"avatar_url":"https://avatars1.githubusercontent.com/u/21151623?v=4","gravatar_id":"","url":"https://api.github.com/users/ashishkg0022","html_url":"https://github.com/ashishkg0022","followers_url":"https://api.github.com/users/ashishkg0022/followers","following_url":"https://api.github.com/users/ashishkg0022/following{/other_user}","gists_url":"https://api.github.com/users/ashishkg0022/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishkg0022/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishkg0022/subscriptions","organizations_url":"https://api.github.com/users/ashishkg0022/orgs","repos_url":"https://api.github.com/users/ashishkg0022/repos","events_url":"https://api.github.com/users/ashishkg0022/events{/privacy}","received_events_url":"https://api.github.com/users/ashishkg0022/received_events","type":"User","site_admin":false},"repo":{"id":108741132,"name":"sympy","full_name":"ashishkg0022/sympy","owner":{"login":"ashishkg0022","id":21151623,"avatar_url":"https://avatars1.githubusercontent.com/u/21151623?v=4","gravatar_id":"","url":"https://api.github.com/users/ashishkg0022","html_url":"https://github.com/ashishkg0022","followers_url":"https://api.github.com/users/ashishkg0022/followers","following_url":"https://api.github.com/users/ashishkg0022/following{/other_user}","gists_url":"https://api.github.com/users/ashishkg0022/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishkg0022/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishkg0022/subscriptions","organizations_url":"https://api.github.com/users/ashishkg0022/orgs","repos_url":"https://api.github.com/users/ashishkg0022/repos","events_url":"https://api.github.com/users/ashishkg0022/events{/privacy}","received_events_url":"https://api.github.com/users/ashishkg0022/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ashishkg0022/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/ashishkg0022/sympy","forks_url":"https://api.github.com/repos/ashishkg0022/sympy/forks","keys_url":"https://api.github.com/repos/ashishkg0022/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ashishkg0022/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ashishkg0022/sympy/teams","hooks_url":"https://api.github.com/repos/ashishkg0022/sympy/hooks","issue_events_url":"https://api.github.com/repos/ashishkg0022/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/ashishkg0022/sympy/events","assignees_url":"https://api.github.com/repos/ashishkg0022/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/ashishkg0022/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/ashishkg0022/sympy/tags","blobs_url":"https://api.github.com/repos/ashishkg0022/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ashishkg0022/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ashishkg0022/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/ashishkg0022/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ashishkg0022/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/ashishkg0022/sympy/languages","stargazers_url":"https://api.github.com/repos/ashishkg0022/sympy/stargazers","contributors_url":"https://api.github.com/repos/ashishkg0022/sympy/contributors","subscribers_url":"https://api.github.com/repos/ashishkg0022/sympy/subscribers","subscription_url":"https://api.github.com/repos/ashishkg0022/sympy/subscription","commits_url":"https://api.github.com/repos/ashishkg0022/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/ashishkg0022/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/ashishkg0022/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/ashishkg0022/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/ashishkg0022/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/ashishkg0022/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ashishkg0022/sympy/merges","archive_url":"https://api.github.com/repos/ashishkg0022/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ashishkg0022/sympy/downloads","issues_url":"https://api.github.com/repos/ashishkg0022/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/ashishkg0022/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/ashishkg0022/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/ashishkg0022/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ashishkg0022/sympy/labels{/name}","releases_url":"https://api.github.com/repos/ashishkg0022/sympy/releases{/id}","deployments_url":"https://api.github.com/repos/ashishkg0022/sympy/deployments","created_at":"2017-10-29T14:26:13Z","updated_at":"2017-10-29T14:26:20Z","pushed_at":"2017-12-10T09:46:04Z","git_url":"git://github.com/ashishkg0022/sympy.git","ssh_url":"git@github.com:ashishkg0022/sympy.git","clone_url":"https://github.com/ashishkg0022/sympy.git","svn_url":"https://github.com/ashishkg0022/sympy","homepage":"http://sympy.org/","size":86624,"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,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"53fc684467088cdf0acccb6ad770cbde97e32268","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-12-10T09:13:44Z","pushed_at":"2017-12-10T09:46:08Z","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":86724,"stargazers_count":4402,"watchers_count":4402,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2103,"mirror_url":null,"archived":false,"open_issues_count":3063,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":2103,"open_issues":3063,"watchers":4402,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13682"},"html":{"href":"https://github.com/sympy/sympy/pull/13682"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/13682"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/13682/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13682/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/13682/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/38726d7a75d8c388da322a518b5fa51991f2f6f5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jksuom"}}