{"action":"created","comment":{"url":"https://api.github.com/repos/obspy/obspy/pulls/comments/77803956","id":77803956,"diff_hunk":"@@ -83,6 +84,55 @@ def __init__(self, arrivals, model):\n         self.model = model\n         self.extend(arrivals)\n \n+    def __add__(self, other):\n+        if isinstance(other, Arrival):\n+            other = Arrivals([other], model=self.model)\n+        if not isinstance(other, Arrivals):\n+            raise TypeError\n+        return self.__class__(super(Arrivals, self).__add__(other),\n+                              model=self.model)\n+\n+    def __iadd__(self, other):\n+        if isinstance(other, Arrival):\n+            other = Arrivals([other], model=self.model)\n+        if not isinstance(other, Arrivals):\n+            raise TypeError\n+        self.extend(other)\n+        return self\n+\n+    def __mul__(self, num):\n+        if not isinstance(num, int):\n+            raise TypeError(\"Integer expected\")\n+        arr = self.copy()\n+        for _i in range(num-1):\n+            arr += self.copy()\n+        return arr\n+\n+    def __setitem__(self, index, arrival):\n+        if isinstance(arrival, Arrival):\n+            super(Arrivals, self).__setitem__(index, arrival)\n+        else:\n+            msg = 'Only Arrival objects can be assigned.'\n+            raise TypeError(msg)\n+\n+    def __setslice__(self, i, j, seq):\n+        if all(isinstance(x, Arrival) for x in seq):\n+            super(Arrivals, self).__setslice__(i, j, seq)\n+        else:\n+            msg = 'Only Arrival objects can be assigned.'\n+            raise TypeError(msg)\n+\n+    def __getitem__(self, index):\n+        if isinstance(index, slice):\n+            return self.__class__(super(Arrivals, self).__getitem__(index),\n+                                  model=self.model)\n+        else:\n+            return super(Arrivals, self).__getitem__(index)\n+\n+    def __getslice__(self, i, j):","path":"obspy/taup/tau.py","position":66,"original_position":66,"commit_id":"ad24fc75502daa38ed41807e0c7a02a9ef6339da","original_commit_id":"ad24fc75502daa38ed41807e0c7a02a9ef6339da","user":{"login":"krischer","id":800487,"avatar_url":"https://avatars.githubusercontent.com/u/800487?v=3","gravatar_id":"","url":"https://api.github.com/users/krischer","html_url":"https://github.com/krischer","followers_url":"https://api.github.com/users/krischer/followers","following_url":"https://api.github.com/users/krischer/following{/other_user}","gists_url":"https://api.github.com/users/krischer/gists{/gist_id}","starred_url":"https://api.github.com/users/krischer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krischer/subscriptions","organizations_url":"https://api.github.com/users/krischer/orgs","repos_url":"https://api.github.com/users/krischer/repos","events_url":"https://api.github.com/users/krischer/events{/privacy}","received_events_url":"https://api.github.com/users/krischer/received_events","type":"User","site_admin":false},"body":"This has been deprecated since Python 2.0 and does not actually exists for Python 3. This should now be implemented as `slice` objects to the `__getitem__()` method. Here it is a bit awkward as built-in Python 2 objects such as `list` (which `Arrivals` currently inherits from) does have a `__getslice__` method so it has to be overwritten to get it working on Python 2. That's a bit of a mess.\r\n\r\nMaybe its easier to just inherit from `collections.abc.MutableSequence` (`collections.MutableSequence` in Python 2) and add the required methods? Inheriting from `collections.UserList` (`UserList` module in Python 2) is also an option.","created_at":"2016-09-07T11:26:41Z","updated_at":"2016-09-07T11:26:41Z","html_url":"https://github.com/obspy/obspy/pull/1518#discussion_r77803956","pull_request_url":"https://api.github.com/repos/obspy/obspy/pulls/1518","_links":{"self":{"href":"https://api.github.com/repos/obspy/obspy/pulls/comments/77803956"},"html":{"href":"https://github.com/obspy/obspy/pull/1518#discussion_r77803956"},"pull_request":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1518"}}},"pull_request":{"url":"https://api.github.com/repos/obspy/obspy/pulls/1518","id":84157896,"html_url":"https://github.com/obspy/obspy/pull/1518","diff_url":"https://github.com/obspy/obspy/pull/1518.diff","patch_url":"https://github.com/obspy/obspy/pull/1518.patch","issue_url":"https://api.github.com/repos/obspy/obspy/issues/1518","number":1518,"state":"open","locked":false,"title":"List operations on obspy.taup.tau.Arrivals should return an Arrivals object ","user":{"login":"claudiodsf","id":1390993,"avatar_url":"https://avatars.githubusercontent.com/u/1390993?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiodsf","html_url":"https://github.com/claudiodsf","followers_url":"https://api.github.com/users/claudiodsf/followers","following_url":"https://api.github.com/users/claudiodsf/following{/other_user}","gists_url":"https://api.github.com/users/claudiodsf/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiodsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiodsf/subscriptions","organizations_url":"https://api.github.com/users/claudiodsf/orgs","repos_url":"https://api.github.com/users/claudiodsf/repos","events_url":"https://api.github.com/users/claudiodsf/events{/privacy}","received_events_url":"https://api.github.com/users/claudiodsf/received_events","type":"User","site_admin":false},"body":"I started playing with `obspy.taup.tau.Arrivals` and realized that if I slice an `Arrivals` object I get a simple list, meaning, for instance, that I cannot plot it anymore:\r\n\r\n```python\r\n>>> from obspy.taup import TauPyModel\r\n>>> model = TauPyModel(model='iasp91')\r\n>>> arrivals = model.get_ray_paths(500, 140, phase_list=['PP', 'SSS'])\r\n>>> print(type(arrivals[1:3]))\r\n<type 'list'>\r\n```\r\nSame thing if I join two `Arrivals` objects (here the same, for sake of simplicity):\r\n```python\r\n>>> print(type(arrivals + arrivals))\r\n<class 'future.types.newlist.newlist'>\r\n```\r\n\r\nIt would be nice if those operations could still produce an `Arrivals` object.","created_at":"2016-09-06T16:52:10Z","updated_at":"2016-09-07T11:26:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f4e3492cb97c76ea8001872413aff20f773e5ef","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/obspy/obspy/pulls/1518/commits","review_comments_url":"https://api.github.com/repos/obspy/obspy/pulls/1518/comments","review_comment_url":"https://api.github.com/repos/obspy/obspy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/obspy/obspy/issues/1518/comments","statuses_url":"https://api.github.com/repos/obspy/obspy/statuses/ad24fc75502daa38ed41807e0c7a02a9ef6339da","head":{"label":"claudiodsf:arrivals_ops","ref":"arrivals_ops","sha":"ad24fc75502daa38ed41807e0c7a02a9ef6339da","user":{"login":"claudiodsf","id":1390993,"avatar_url":"https://avatars.githubusercontent.com/u/1390993?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiodsf","html_url":"https://github.com/claudiodsf","followers_url":"https://api.github.com/users/claudiodsf/followers","following_url":"https://api.github.com/users/claudiodsf/following{/other_user}","gists_url":"https://api.github.com/users/claudiodsf/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiodsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiodsf/subscriptions","organizations_url":"https://api.github.com/users/claudiodsf/orgs","repos_url":"https://api.github.com/users/claudiodsf/repos","events_url":"https://api.github.com/users/claudiodsf/events{/privacy}","received_events_url":"https://api.github.com/users/claudiodsf/received_events","type":"User","site_admin":false},"repo":{"id":5999303,"name":"obspy","full_name":"claudiodsf/obspy","owner":{"login":"claudiodsf","id":1390993,"avatar_url":"https://avatars.githubusercontent.com/u/1390993?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiodsf","html_url":"https://github.com/claudiodsf","followers_url":"https://api.github.com/users/claudiodsf/followers","following_url":"https://api.github.com/users/claudiodsf/following{/other_user}","gists_url":"https://api.github.com/users/claudiodsf/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiodsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiodsf/subscriptions","organizations_url":"https://api.github.com/users/claudiodsf/orgs","repos_url":"https://api.github.com/users/claudiodsf/repos","events_url":"https://api.github.com/users/claudiodsf/events{/privacy}","received_events_url":"https://api.github.com/users/claudiodsf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/claudiodsf/obspy","description":"ObsPy: A Python Toolbox for seismology/seismological observatories.","fork":true,"url":"https://api.github.com/repos/claudiodsf/obspy","forks_url":"https://api.github.com/repos/claudiodsf/obspy/forks","keys_url":"https://api.github.com/repos/claudiodsf/obspy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/claudiodsf/obspy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/claudiodsf/obspy/teams","hooks_url":"https://api.github.com/repos/claudiodsf/obspy/hooks","issue_events_url":"https://api.github.com/repos/claudiodsf/obspy/issues/events{/number}","events_url":"https://api.github.com/repos/claudiodsf/obspy/events","assignees_url":"https://api.github.com/repos/claudiodsf/obspy/assignees{/user}","branches_url":"https://api.github.com/repos/claudiodsf/obspy/branches{/branch}","tags_url":"https://api.github.com/repos/claudiodsf/obspy/tags","blobs_url":"https://api.github.com/repos/claudiodsf/obspy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/claudiodsf/obspy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/claudiodsf/obspy/git/refs{/sha}","trees_url":"https://api.github.com/repos/claudiodsf/obspy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/claudiodsf/obspy/statuses/{sha}","languages_url":"https://api.github.com/repos/claudiodsf/obspy/languages","stargazers_url":"https://api.github.com/repos/claudiodsf/obspy/stargazers","contributors_url":"https://api.github.com/repos/claudiodsf/obspy/contributors","subscribers_url":"https://api.github.com/repos/claudiodsf/obspy/subscribers","subscription_url":"https://api.github.com/repos/claudiodsf/obspy/subscription","commits_url":"https://api.github.com/repos/claudiodsf/obspy/commits{/sha}","git_commits_url":"https://api.github.com/repos/claudiodsf/obspy/git/commits{/sha}","comments_url":"https://api.github.com/repos/claudiodsf/obspy/comments{/number}","issue_comment_url":"https://api.github.com/repos/claudiodsf/obspy/issues/comments{/number}","contents_url":"https://api.github.com/repos/claudiodsf/obspy/contents/{+path}","compare_url":"https://api.github.com/repos/claudiodsf/obspy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/claudiodsf/obspy/merges","archive_url":"https://api.github.com/repos/claudiodsf/obspy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/claudiodsf/obspy/downloads","issues_url":"https://api.github.com/repos/claudiodsf/obspy/issues{/number}","pulls_url":"https://api.github.com/repos/claudiodsf/obspy/pulls{/number}","milestones_url":"https://api.github.com/repos/claudiodsf/obspy/milestones{/number}","notifications_url":"https://api.github.com/repos/claudiodsf/obspy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/claudiodsf/obspy/labels{/name}","releases_url":"https://api.github.com/repos/claudiodsf/obspy/releases{/id}","deployments_url":"https://api.github.com/repos/claudiodsf/obspy/deployments","created_at":"2012-09-28T15:38:19Z","updated_at":"2015-03-20T10:08:43Z","pushed_at":"2016-09-07T09:29:54Z","git_url":"git://github.com/claudiodsf/obspy.git","ssh_url":"git@github.com:claudiodsf/obspy.git","clone_url":"https://github.com/claudiodsf/obspy.git","svn_url":"https://github.com/claudiodsf/obspy","homepage":"https://github.com/obspy/obspy/wiki","size":77019,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"obspy:maintenance_1.0.x","ref":"maintenance_1.0.x","sha":"8f36463cecbafdf6167aa816291240f7b8b996eb","user":{"login":"obspy","id":1701221,"avatar_url":"https://avatars.githubusercontent.com/u/1701221?v=3","gravatar_id":"","url":"https://api.github.com/users/obspy","html_url":"https://github.com/obspy","followers_url":"https://api.github.com/users/obspy/followers","following_url":"https://api.github.com/users/obspy/following{/other_user}","gists_url":"https://api.github.com/users/obspy/gists{/gist_id}","starred_url":"https://api.github.com/users/obspy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obspy/subscriptions","organizations_url":"https://api.github.com/users/obspy/orgs","repos_url":"https://api.github.com/users/obspy/repos","events_url":"https://api.github.com/users/obspy/events{/privacy}","received_events_url":"https://api.github.com/users/obspy/received_events","type":"Organization","site_admin":false},"repo":{"id":5731348,"name":"obspy","full_name":"obspy/obspy","owner":{"login":"obspy","id":1701221,"avatar_url":"https://avatars.githubusercontent.com/u/1701221?v=3","gravatar_id":"","url":"https://api.github.com/users/obspy","html_url":"https://github.com/obspy","followers_url":"https://api.github.com/users/obspy/followers","following_url":"https://api.github.com/users/obspy/following{/other_user}","gists_url":"https://api.github.com/users/obspy/gists{/gist_id}","starred_url":"https://api.github.com/users/obspy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obspy/subscriptions","organizations_url":"https://api.github.com/users/obspy/orgs","repos_url":"https://api.github.com/users/obspy/repos","events_url":"https://api.github.com/users/obspy/events{/privacy}","received_events_url":"https://api.github.com/users/obspy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/obspy/obspy","description":"ObsPy: A Python Toolbox for seismology/seismological observatories.","fork":false,"url":"https://api.github.com/repos/obspy/obspy","forks_url":"https://api.github.com/repos/obspy/obspy/forks","keys_url":"https://api.github.com/repos/obspy/obspy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obspy/obspy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obspy/obspy/teams","hooks_url":"https://api.github.com/repos/obspy/obspy/hooks","issue_events_url":"https://api.github.com/repos/obspy/obspy/issues/events{/number}","events_url":"https://api.github.com/repos/obspy/obspy/events","assignees_url":"https://api.github.com/repos/obspy/obspy/assignees{/user}","branches_url":"https://api.github.com/repos/obspy/obspy/branches{/branch}","tags_url":"https://api.github.com/repos/obspy/obspy/tags","blobs_url":"https://api.github.com/repos/obspy/obspy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obspy/obspy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obspy/obspy/git/refs{/sha}","trees_url":"https://api.github.com/repos/obspy/obspy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obspy/obspy/statuses/{sha}","languages_url":"https://api.github.com/repos/obspy/obspy/languages","stargazers_url":"https://api.github.com/repos/obspy/obspy/stargazers","contributors_url":"https://api.github.com/repos/obspy/obspy/contributors","subscribers_url":"https://api.github.com/repos/obspy/obspy/subscribers","subscription_url":"https://api.github.com/repos/obspy/obspy/subscription","commits_url":"https://api.github.com/repos/obspy/obspy/commits{/sha}","git_commits_url":"https://api.github.com/repos/obspy/obspy/git/commits{/sha}","comments_url":"https://api.github.com/repos/obspy/obspy/comments{/number}","issue_comment_url":"https://api.github.com/repos/obspy/obspy/issues/comments{/number}","contents_url":"https://api.github.com/repos/obspy/obspy/contents/{+path}","compare_url":"https://api.github.com/repos/obspy/obspy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obspy/obspy/merges","archive_url":"https://api.github.com/repos/obspy/obspy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obspy/obspy/downloads","issues_url":"https://api.github.com/repos/obspy/obspy/issues{/number}","pulls_url":"https://api.github.com/repos/obspy/obspy/pulls{/number}","milestones_url":"https://api.github.com/repos/obspy/obspy/milestones{/number}","notifications_url":"https://api.github.com/repos/obspy/obspy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obspy/obspy/labels{/name}","releases_url":"https://api.github.com/repos/obspy/obspy/releases{/id}","deployments_url":"https://api.github.com/repos/obspy/obspy/deployments","created_at":"2012-09-08T19:17:46Z","updated_at":"2016-09-02T08:54:43Z","pushed_at":"2016-09-07T11:15:56Z","git_url":"git://github.com/obspy/obspy.git","ssh_url":"git@github.com:obspy/obspy.git","clone_url":"https://github.com/obspy/obspy.git","svn_url":"https://github.com/obspy/obspy","homepage":"https://www.obspy.org","size":97619,"stargazers_count":229,"watchers_count":229,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":171,"mirror_url":null,"open_issues_count":186,"forks":171,"open_issues":186,"watchers":229,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1518"},"html":{"href":"https://github.com/obspy/obspy/pull/1518"},"issue":{"href":"https://api.github.com/repos/obspy/obspy/issues/1518"},"comments":{"href":"https://api.github.com/repos/obspy/obspy/issues/1518/comments"},"review_comments":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1518/comments"},"review_comment":{"href":"https://api.github.com/repos/obspy/obspy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/obspy/obspy/pulls/1518/commits"},"statuses":{"href":"https://api.github.com/repos/obspy/obspy/statuses/ad24fc75502daa38ed41807e0c7a02a9ef6339da"}}}}
{"actor":{"display_login":"krischer"}}