{"action":"created","comment":{"url":"https://api.github.com/repos/quantopian/qrisk/pulls/comments/67934377","id":67934377,"diff_hunk":"@@ -40,12 +40,71 @@ class TestStats(TestCase):\n             '2000-1-1',\n             periods=500,\n             freq='D'))\n-    px_list = np.array(\n-        [10, -10, 10]) / 100.  # Ends in drawdown\n-    dt = pd.date_range('2000-1-3', periods=3, freq='D')\n \n-    px_list_2 = [1.0, 1.2, 1.0, 0.8, 0.7, 0.8, 0.8, 0.8]\n-    dt_2 = pd.date_range('2000-1-3', periods=8, freq='D')\n+    s_1 = pd.Series(np.array([10, -10, 10]) / 100.,\n+                    index=pd.date_range('2000-1-3', periods=3, freq='D'))\n+\n+    s_2 = pd.Series([1.0, 1.2, 1.0, 0.8, 0.7, 0.8, 0.8, 0.8],\n+                    index=pd.date_range('2000-1-3', periods=8, freq='D'))\n+\n+    s_3 = pd.Series(np.array([1, 10, -2, 2, 3, 2, 1, -10])/100,\n+                    index=pd.date_range('2000-1-3', periods=8, freq='D'))\n+\n+    one = [-0.00171614, 0.01322056, 0.03063862, -0.01422057, -0.00489779,\n+           0.01268925, -0.03357711, 0.01797036]\n+    two = [0.01846232, 0.00793951, -0.01448395, 0.00422537, -0.00339611,\n+           0.03756813, 0.0151531, 0.03549769]\n+    df_index_simple = pd.date_range('2000-1-3', periods=8, freq='D')\n+    df_index_week = pd.date_range('2000-1-3', periods=8, freq='W')\n+    df_index_month = pd.date_range('2000-1-3', periods=8, freq='M')\n+\n+    d_simple = {'one': pd.Series(one, index=df_index_simple),\n+                'two': pd.Series(two, index=df_index_simple)}\n+    df_simple = pd.DataFrame(d_simple)\n+\n+    d_week = {'one': pd.Series(one, index=df_index_week),\n+              'two': pd.Series(two, index=df_index_week)}\n+    df_week = pd.DataFrame(d_week)\n+\n+    d_month = {'one': pd.Series(one, index=df_index_month),\n+               'two': pd.Series(two, index=df_index_month)}\n+    df_month = pd.DataFrame(d_month)\n+\n+    @parameterized.expand([\n+        (simple_rets, 0, 0.33100000000000041),\n+        (simple_week_rets, 100, 133.10000000000005),\n+        (simple_benchmark, 100, 112.55088100000002)\n+        ])\n+    def test_cum_returns(self, returns, starting_value, expected):\n+        self.assertEqual(\n+            stats.cum_returns(\n+                returns, starting_value\n+            )[-1],\n+            expected)\n+\n+    @parameterized.expand([\n+        (simple_rets, stats.WEEKLY, 72),\n+        (simple_rets, stats.MONTHLY, 17),\n+        (simple_rets, stats.YEARLY, 2),\n+        (simple_week_rets, stats.WEEKLY, 499),\n+        (simple_week_rets, stats.YEARLY, 10),\n+        (simple_month_rets, stats.YEARLY, 42)\n+    ])\n+    def test_aggregate_returns(self, returns, convert_to, expected):\n+        self.assertEqual(\n+            len(stats.aggregate_returns(returns, convert_to)),\n+            expected)\n+\n+    @parameterized.expand([\n+        (simple_rets, 0.0),\n+        (s_3, -0.10000000000000002)\n+        ])","path":"qrisk/tests/test_stats.py","position":86,"original_position":86,"commit_id":"ea1c7ed3442b349a8772bf9f2b7cb8d4e90a9186","original_commit_id":"ea1c7ed3442b349a8772bf9f2b7cb8d4e90a9186","user":{"login":"abhijeetkalyan","id":3505048,"avatar_url":"https://avatars.githubusercontent.com/u/3505048?v=3","gravatar_id":"","url":"https://api.github.com/users/abhijeetkalyan","html_url":"https://github.com/abhijeetkalyan","followers_url":"https://api.github.com/users/abhijeetkalyan/followers","following_url":"https://api.github.com/users/abhijeetkalyan/following{/other_user}","gists_url":"https://api.github.com/users/abhijeetkalyan/gists{/gist_id}","starred_url":"https://api.github.com/users/abhijeetkalyan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhijeetkalyan/subscriptions","organizations_url":"https://api.github.com/users/abhijeetkalyan/orgs","repos_url":"https://api.github.com/users/abhijeetkalyan/repos","events_url":"https://api.github.com/users/abhijeetkalyan/events{/privacy}","received_events_url":"https://api.github.com/users/abhijeetkalyan/received_events","type":"User","site_admin":false},"body":"This is really pedantic, but on some tests we do:\r\n```python\r\n@parameterized.expand([\r\n    foo,\r\n    bar\r\n    ])\r\n```\r\n\r\nwhereas on others, we do\r\n```python\r\n@parameterized.expand([\r\n    foo,\r\n    bar\r\n])\r\n```\r\n\r\ncan we be consistent on one style? (Not a big deal though) ","created_at":"2016-06-21T19:20:21Z","updated_at":"2016-06-21T19:20:21Z","html_url":"https://github.com/quantopian/qrisk/pull/2#discussion_r67934377","pull_request_url":"https://api.github.com/repos/quantopian/qrisk/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/comments/67934377"},"html":{"href":"https://github.com/quantopian/qrisk/pull/2#discussion_r67934377"},"pull_request":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/quantopian/qrisk/pulls/2","id":74655957,"html_url":"https://github.com/quantopian/qrisk/pull/2","diff_url":"https://github.com/quantopian/qrisk/pull/2.diff","patch_url":"https://github.com/quantopian/qrisk/pull/2.patch","issue_url":"https://api.github.com/repos/quantopian/qrisk/issues/2","number":2,"state":"open","locked":false,"title":"ENH: At least one test per function","user":{"login":"ahgnaw","id":921335,"avatar_url":"https://avatars.githubusercontent.com/u/921335?v=3","gravatar_id":"","url":"https://api.github.com/users/ahgnaw","html_url":"https://github.com/ahgnaw","followers_url":"https://api.github.com/users/ahgnaw/followers","following_url":"https://api.github.com/users/ahgnaw/following{/other_user}","gists_url":"https://api.github.com/users/ahgnaw/gists{/gist_id}","starred_url":"https://api.github.com/users/ahgnaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahgnaw/subscriptions","organizations_url":"https://api.github.com/users/ahgnaw/orgs","repos_url":"https://api.github.com/users/ahgnaw/repos","events_url":"https://api.github.com/users/ahgnaw/events{/privacy}","received_events_url":"https://api.github.com/users/ahgnaw/received_events","type":"User","site_admin":false},"body":"Made some functions more general and added at least one test per function.","created_at":"2016-06-21T17:48:13Z","updated_at":"2016-06-21T19:20:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d69e565670fcb94a8800823ccecfadb2214cdf93","assignee":{"login":"twiecki","id":674200,"avatar_url":"https://avatars.githubusercontent.com/u/674200?v=3","gravatar_id":"","url":"https://api.github.com/users/twiecki","html_url":"https://github.com/twiecki","followers_url":"https://api.github.com/users/twiecki/followers","following_url":"https://api.github.com/users/twiecki/following{/other_user}","gists_url":"https://api.github.com/users/twiecki/gists{/gist_id}","starred_url":"https://api.github.com/users/twiecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twiecki/subscriptions","organizations_url":"https://api.github.com/users/twiecki/orgs","repos_url":"https://api.github.com/users/twiecki/repos","events_url":"https://api.github.com/users/twiecki/events{/privacy}","received_events_url":"https://api.github.com/users/twiecki/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/quantopian/qrisk/pulls/2/commits","review_comments_url":"https://api.github.com/repos/quantopian/qrisk/pulls/2/comments","review_comment_url":"https://api.github.com/repos/quantopian/qrisk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quantopian/qrisk/issues/2/comments","statuses_url":"https://api.github.com/repos/quantopian/qrisk/statuses/ea1c7ed3442b349a8772bf9f2b7cb8d4e90a9186","head":{"label":"quantopian:exhaustive_testing","ref":"exhaustive_testing","sha":"ea1c7ed3442b349a8772bf9f2b7cb8d4e90a9186","user":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"repo":{"id":54192943,"name":"qrisk","full_name":"quantopian/qrisk","owner":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quantopian/qrisk","description":"Common financial risk and performance metrics. Used by zipline and pyfolio.","fork":false,"url":"https://api.github.com/repos/quantopian/qrisk","forks_url":"https://api.github.com/repos/quantopian/qrisk/forks","keys_url":"https://api.github.com/repos/quantopian/qrisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/qrisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/qrisk/teams","hooks_url":"https://api.github.com/repos/quantopian/qrisk/hooks","issue_events_url":"https://api.github.com/repos/quantopian/qrisk/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/qrisk/events","assignees_url":"https://api.github.com/repos/quantopian/qrisk/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/qrisk/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/qrisk/tags","blobs_url":"https://api.github.com/repos/quantopian/qrisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/qrisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/qrisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/qrisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/qrisk/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/qrisk/languages","stargazers_url":"https://api.github.com/repos/quantopian/qrisk/stargazers","contributors_url":"https://api.github.com/repos/quantopian/qrisk/contributors","subscribers_url":"https://api.github.com/repos/quantopian/qrisk/subscribers","subscription_url":"https://api.github.com/repos/quantopian/qrisk/subscription","commits_url":"https://api.github.com/repos/quantopian/qrisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/qrisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/qrisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/qrisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/qrisk/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/qrisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/qrisk/merges","archive_url":"https://api.github.com/repos/quantopian/qrisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/qrisk/downloads","issues_url":"https://api.github.com/repos/quantopian/qrisk/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/qrisk/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/qrisk/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/qrisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/qrisk/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/qrisk/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/qrisk/deployments","created_at":"2016-03-18T10:22:52Z","updated_at":"2016-06-16T15:44:07Z","pushed_at":"2016-06-21T17:48:13Z","git_url":"git://github.com/quantopian/qrisk.git","ssh_url":"git@github.com:quantopian/qrisk.git","clone_url":"https://github.com/quantopian/qrisk.git","svn_url":"https://github.com/quantopian/qrisk","homepage":"","size":36,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":12,"default_branch":"master"}},"base":{"label":"quantopian:master","ref":"master","sha":"0608be402bc7fee16a1c823d27995974b9d28b35","user":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"repo":{"id":54192943,"name":"qrisk","full_name":"quantopian/qrisk","owner":{"login":"quantopian","id":1393215,"avatar_url":"https://avatars.githubusercontent.com/u/1393215?v=3","gravatar_id":"","url":"https://api.github.com/users/quantopian","html_url":"https://github.com/quantopian","followers_url":"https://api.github.com/users/quantopian/followers","following_url":"https://api.github.com/users/quantopian/following{/other_user}","gists_url":"https://api.github.com/users/quantopian/gists{/gist_id}","starred_url":"https://api.github.com/users/quantopian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantopian/subscriptions","organizations_url":"https://api.github.com/users/quantopian/orgs","repos_url":"https://api.github.com/users/quantopian/repos","events_url":"https://api.github.com/users/quantopian/events{/privacy}","received_events_url":"https://api.github.com/users/quantopian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quantopian/qrisk","description":"Common financial risk and performance metrics. Used by zipline and pyfolio.","fork":false,"url":"https://api.github.com/repos/quantopian/qrisk","forks_url":"https://api.github.com/repos/quantopian/qrisk/forks","keys_url":"https://api.github.com/repos/quantopian/qrisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/qrisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/qrisk/teams","hooks_url":"https://api.github.com/repos/quantopian/qrisk/hooks","issue_events_url":"https://api.github.com/repos/quantopian/qrisk/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/qrisk/events","assignees_url":"https://api.github.com/repos/quantopian/qrisk/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/qrisk/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/qrisk/tags","blobs_url":"https://api.github.com/repos/quantopian/qrisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/qrisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/qrisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/qrisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/qrisk/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/qrisk/languages","stargazers_url":"https://api.github.com/repos/quantopian/qrisk/stargazers","contributors_url":"https://api.github.com/repos/quantopian/qrisk/contributors","subscribers_url":"https://api.github.com/repos/quantopian/qrisk/subscribers","subscription_url":"https://api.github.com/repos/quantopian/qrisk/subscription","commits_url":"https://api.github.com/repos/quantopian/qrisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/qrisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/qrisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/qrisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/qrisk/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/qrisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/qrisk/merges","archive_url":"https://api.github.com/repos/quantopian/qrisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/qrisk/downloads","issues_url":"https://api.github.com/repos/quantopian/qrisk/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/qrisk/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/qrisk/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/qrisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/qrisk/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/qrisk/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/qrisk/deployments","created_at":"2016-03-18T10:22:52Z","updated_at":"2016-06-16T15:44:07Z","pushed_at":"2016-06-21T17:48:13Z","git_url":"git://github.com/quantopian/qrisk.git","ssh_url":"git@github.com:quantopian/qrisk.git","clone_url":"https://github.com/quantopian/qrisk.git","svn_url":"https://github.com/quantopian/qrisk","homepage":"","size":36,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/2"},"html":{"href":"https://github.com/quantopian/qrisk/pull/2"},"issue":{"href":"https://api.github.com/repos/quantopian/qrisk/issues/2"},"comments":{"href":"https://api.github.com/repos/quantopian/qrisk/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quantopian/qrisk/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/quantopian/qrisk/statuses/ea1c7ed3442b349a8772bf9f2b7cb8d4e90a9186"}}}}
{"actor":{"display_login":"abhijeetkalyan"}}