{"action":"created","comment":{"url":"https://api.github.com/repos/quantopian/zipline/pulls/comments/53260796","id":53260796,"diff_hunk":"@@ -0,0 +1,511 @@\n+\"\"\"\n+Tests for the reference loader for EarningsCalendar.\n+\"\"\"\n+from functools import partial\n+from unittest import TestCase\n+\n+import blaze as bz\n+from blaze.compute.core import swap_resources_into_scope\n+from contextlib2 import ExitStack\n+from nose_parameterized import parameterized\n+import numpy as np\n+import pandas as pd\n+from pandas.util.testing import assert_series_equal\n+from six import iteritems\n+\n+from zipline.pipeline import Pipeline\n+from zipline.pipeline.data import (CashBuybackAuthorizations,\n+                                   ShareBuybackAuthorizations)\n+from zipline.pipeline.engine import SimplePipelineEngine\n+from zipline.pipeline.factors.events import (\n+    BusinessDaysSincePreviousCashBuybackAuth,\n+    BusinessDaysSincePreviousShareBuybackAuth\n+)\n+from zipline.pipeline.loaders.buyback_auth import \\\n+    CashBuybackAuthorizationsLoader, ShareBuybackAuthorizationsLoader\n+from zipline.pipeline.loaders.blaze import (\n+    BlazeCashBuybackAuthorizationsLoader,\n+    BlazeShareBuybackAuthorizationsLoader,\n+    BUYBACK_ANNOUNCEMENT_FIELD_NAME,\n+    SHARE_COUNT_FIELD_NAME,\n+    SID_FIELD_NAME,\n+    TS_FIELD_NAME,\n+    CASH_FIELD_NAME\n+)\n+from zipline.utils.numpy_utils import make_datetime64D, NaTD\n+from zipline.utils.test_utils import (\n+    gen_calendars,\n+    make_simple_equity_info,\n+    num_days_in_range,\n+    tmp_asset_finder,\n+)\n+\n+\n+sids = A, B, C, D, E = range(5)\n+\n+equity_info = make_simple_equity_info(\n+    sids,\n+    start_date=pd.Timestamp('2013-01-01', tz='UTC'),\n+    end_date=pd.Timestamp('2015-01-01', tz='UTC'),\n+)\n+\n+buyback_authorizations = {\n+    # K1--K2--A1--A2--SC1--SC2--V1--V2.\n+    A: pd.DataFrame({\n+        \"timestamp\": pd.to_datetime(['2014-01-05', '2014-01-10']),\n+        BUYBACK_ANNOUNCEMENT_FIELD_NAME: pd.to_datetime(['2014-01-15',\n+                                                         '2014-01-20']),\n+        SHARE_COUNT_FIELD_NAME: [1, 15],\n+        CASH_FIELD_NAME: [10, 20]\n+    }),\n+    # K1--K2--E2--E1.\n+    B: pd.DataFrame({\n+        \"timestamp\": pd.to_datetime(['2014-01-05', '2014-01-10']),\n+        BUYBACK_ANNOUNCEMENT_FIELD_NAME: pd.to_datetime([\n+            '2014-01-20', '2014-01-15'\n+        ]),\n+        SHARE_COUNT_FIELD_NAME: [7, 13], CASH_FIELD_NAME: [10, 22]\n+    }),\n+    # K1--E1--K2--E2.\n+    C: pd.DataFrame({\n+        \"timestamp\": pd.to_datetime(['2014-01-05', '2014-01-15']),\n+        BUYBACK_ANNOUNCEMENT_FIELD_NAME: pd.to_datetime([\n+            '2014-01-10', '2014-01-20'\n+        ]),\n+        SHARE_COUNT_FIELD_NAME: [3, 1],\n+        CASH_FIELD_NAME: [4, 7]\n+    }),\n+    # K1 == K2.\n+    D: pd.DataFrame({\n+        \"timestamp\": pd.to_datetime(['2014-01-05'] * 2),\n+        BUYBACK_ANNOUNCEMENT_FIELD_NAME: pd.to_datetime([\n+            '2014-01-10', '2014-01-15'\n+        ]),\n+        SHARE_COUNT_FIELD_NAME: [6, 23],\n+        CASH_FIELD_NAME: [1, 2]\n+    }),\n+    E: pd.DataFrame(\n+        columns=[\"timestamp\",\n+                 BUYBACK_ANNOUNCEMENT_FIELD_NAME,\n+                 SHARE_COUNT_FIELD_NAME,\n+                 CASH_FIELD_NAME],\n+        dtype='datetime64[ns]'\n+    ),\n+}\n+\n+# Must be a list - can't use generator since this needs to be used more than\n+# once.\n+param_dates = list(gen_calendars(\n+    '2014-01-01',\n+    '2014-01-31',\n+    critical_dates=pd.to_datetime([\n+        '2014-01-05',\n+        '2014-01-10',\n+        '2014-01-15',\n+        '2014-01-20',\n+    ]),\n+))\n+\n+\n+def zip_with_floats(dates, flts):\n+    return pd.Series(flts, index=dates).astype('float')\n+\n+\n+def num_days_between(dates, start_date, end_date):\n+    return num_days_in_range(dates, start_date, end_date)\n+\n+\n+def zip_with_dates(index_dates, dts):\n+    return pd.Series(pd.to_datetime(dts), index=index_dates)\n+\n+\n+class BuybackAuthLoaderCommonTest:","path":"tests/pipeline/test_buyback_auth.py","position":122,"original_position":122,"commit_id":"6f13468073476a993049baa7758846ad453859f1","original_commit_id":"6f13468073476a993049baa7758846ad453859f1","user":{"login":"llllllllll","id":3064397,"avatar_url":"https://avatars.githubusercontent.com/u/3064397?v=3","gravatar_id":"","url":"https://api.github.com/users/llllllllll","html_url":"https://github.com/llllllllll","followers_url":"https://api.github.com/users/llllllllll/followers","following_url":"https://api.github.com/users/llllllllll/following{/other_user}","gists_url":"https://api.github.com/users/llllllllll/gists{/gist_id}","starred_url":"https://api.github.com/users/llllllllll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llllllllll/subscriptions","organizations_url":"https://api.github.com/users/llllllllll/orgs","repos_url":"https://api.github.com/users/llllllllll/repos","events_url":"https://api.github.com/users/llllllllll/events{/privacy}","received_events_url":"https://api.github.com/users/llllllllll/received_events","type":"User","site_admin":false},"body":"no old style classes in py2","created_at":"2016-02-18T01:33:25Z","updated_at":"2016-02-18T01:33:25Z","html_url":"https://github.com/quantopian/zipline/pull/990#discussion_r53260796","pull_request_url":"https://api.github.com/repos/quantopian/zipline/pulls/990","_links":{"self":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/comments/53260796"},"html":{"href":"https://github.com/quantopian/zipline/pull/990#discussion_r53260796"},"pull_request":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/990"}}},"pull_request":{"url":"https://api.github.com/repos/quantopian/zipline/pulls/990","id":58960344,"html_url":"https://github.com/quantopian/zipline/pull/990","diff_url":"https://github.com/quantopian/zipline/pull/990.diff","patch_url":"https://github.com/quantopian/zipline/pull/990.patch","issue_url":"https://api.github.com/repos/quantopian/zipline/issues/990","number":990,"state":"open","locked":false,"title":"Buyback auth in pipeline","user":{"login":"mtydykov","id":5226409,"avatar_url":"https://avatars.githubusercontent.com/u/5226409?v=3","gravatar_id":"","url":"https://api.github.com/users/mtydykov","html_url":"https://github.com/mtydykov","followers_url":"https://api.github.com/users/mtydykov/followers","following_url":"https://api.github.com/users/mtydykov/following{/other_user}","gists_url":"https://api.github.com/users/mtydykov/gists{/gist_id}","starred_url":"https://api.github.com/users/mtydykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtydykov/subscriptions","organizations_url":"https://api.github.com/users/mtydykov/orgs","repos_url":"https://api.github.com/users/mtydykov/repos","events_url":"https://api.github.com/users/mtydykov/events{/privacy}","received_events_url":"https://api.github.com/users/mtydykov/received_events","type":"User","site_admin":false},"body":"This adds buyback authorizations to Pipeline and refactors out much of the logic from earnings, since most of it can be reused for buyback authorizations and other events. \r\n\r\nNote: This PR won't be completely done until https://github.com/quantopian/zipline/pull/962 is completed, since we need missing values (see line 121 in `zipline/pipeline/loaders/events.py`).","created_at":"2016-02-10T21:57:38Z","updated_at":"2016-02-18T01:33:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e68c953b0a54b3b79b7718261ce4e0de3c58b354","assignee":{"login":"llllllllll","id":3064397,"avatar_url":"https://avatars.githubusercontent.com/u/3064397?v=3","gravatar_id":"","url":"https://api.github.com/users/llllllllll","html_url":"https://github.com/llllllllll","followers_url":"https://api.github.com/users/llllllllll/followers","following_url":"https://api.github.com/users/llllllllll/following{/other_user}","gists_url":"https://api.github.com/users/llllllllll/gists{/gist_id}","starred_url":"https://api.github.com/users/llllllllll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llllllllll/subscriptions","organizations_url":"https://api.github.com/users/llllllllll/orgs","repos_url":"https://api.github.com/users/llllllllll/repos","events_url":"https://api.github.com/users/llllllllll/events{/privacy}","received_events_url":"https://api.github.com/users/llllllllll/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/quantopian/zipline/pulls/990/commits","review_comments_url":"https://api.github.com/repos/quantopian/zipline/pulls/990/comments","review_comment_url":"https://api.github.com/repos/quantopian/zipline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quantopian/zipline/issues/990/comments","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/6f13468073476a993049baa7758846ad453859f1","head":{"label":"quantopian:buyback_auth_in_pipeline","ref":"buyback_auth_in_pipeline","sha":"6f13468073476a993049baa7758846ad453859f1","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":6297520,"name":"zipline","full_name":"quantopian/zipline","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/zipline","description":"Zipline, a Pythonic Algorithmic Trading Library","fork":false,"url":"https://api.github.com/repos/quantopian/zipline","forks_url":"https://api.github.com/repos/quantopian/zipline/forks","keys_url":"https://api.github.com/repos/quantopian/zipline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/zipline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/zipline/teams","hooks_url":"https://api.github.com/repos/quantopian/zipline/hooks","issue_events_url":"https://api.github.com/repos/quantopian/zipline/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/zipline/events","assignees_url":"https://api.github.com/repos/quantopian/zipline/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/zipline/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/zipline/tags","blobs_url":"https://api.github.com/repos/quantopian/zipline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/zipline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/zipline/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/zipline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/zipline/languages","stargazers_url":"https://api.github.com/repos/quantopian/zipline/stargazers","contributors_url":"https://api.github.com/repos/quantopian/zipline/contributors","subscribers_url":"https://api.github.com/repos/quantopian/zipline/subscribers","subscription_url":"https://api.github.com/repos/quantopian/zipline/subscription","commits_url":"https://api.github.com/repos/quantopian/zipline/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/zipline/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/zipline/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/zipline/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/zipline/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/zipline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/zipline/merges","archive_url":"https://api.github.com/repos/quantopian/zipline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/zipline/downloads","issues_url":"https://api.github.com/repos/quantopian/zipline/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/zipline/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/zipline/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/zipline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/zipline/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/zipline/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/zipline/deployments","created_at":"2012-10-19T15:50:29Z","updated_at":"2016-02-17T17:28:00Z","pushed_at":"2016-02-18T01:22:57Z","git_url":"git://github.com/quantopian/zipline.git","ssh_url":"git@github.com:quantopian/zipline.git","clone_url":"https://github.com/quantopian/zipline.git","svn_url":"https://github.com/quantopian/zipline","homepage":"","size":15222,"stargazers_count":2903,"watchers_count":2903,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":844,"mirror_url":null,"open_issues_count":157,"forks":844,"open_issues":157,"watchers":2903,"default_branch":"master"}},"base":{"label":"quantopian:master","ref":"master","sha":"d8bbaec5a8f2cdcb1c938aa3f3885adff3f3cddd","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":6297520,"name":"zipline","full_name":"quantopian/zipline","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/zipline","description":"Zipline, a Pythonic Algorithmic Trading Library","fork":false,"url":"https://api.github.com/repos/quantopian/zipline","forks_url":"https://api.github.com/repos/quantopian/zipline/forks","keys_url":"https://api.github.com/repos/quantopian/zipline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantopian/zipline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantopian/zipline/teams","hooks_url":"https://api.github.com/repos/quantopian/zipline/hooks","issue_events_url":"https://api.github.com/repos/quantopian/zipline/issues/events{/number}","events_url":"https://api.github.com/repos/quantopian/zipline/events","assignees_url":"https://api.github.com/repos/quantopian/zipline/assignees{/user}","branches_url":"https://api.github.com/repos/quantopian/zipline/branches{/branch}","tags_url":"https://api.github.com/repos/quantopian/zipline/tags","blobs_url":"https://api.github.com/repos/quantopian/zipline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantopian/zipline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantopian/zipline/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantopian/zipline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantopian/zipline/statuses/{sha}","languages_url":"https://api.github.com/repos/quantopian/zipline/languages","stargazers_url":"https://api.github.com/repos/quantopian/zipline/stargazers","contributors_url":"https://api.github.com/repos/quantopian/zipline/contributors","subscribers_url":"https://api.github.com/repos/quantopian/zipline/subscribers","subscription_url":"https://api.github.com/repos/quantopian/zipline/subscription","commits_url":"https://api.github.com/repos/quantopian/zipline/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantopian/zipline/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantopian/zipline/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantopian/zipline/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantopian/zipline/contents/{+path}","compare_url":"https://api.github.com/repos/quantopian/zipline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantopian/zipline/merges","archive_url":"https://api.github.com/repos/quantopian/zipline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantopian/zipline/downloads","issues_url":"https://api.github.com/repos/quantopian/zipline/issues{/number}","pulls_url":"https://api.github.com/repos/quantopian/zipline/pulls{/number}","milestones_url":"https://api.github.com/repos/quantopian/zipline/milestones{/number}","notifications_url":"https://api.github.com/repos/quantopian/zipline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantopian/zipline/labels{/name}","releases_url":"https://api.github.com/repos/quantopian/zipline/releases{/id}","deployments_url":"https://api.github.com/repos/quantopian/zipline/deployments","created_at":"2012-10-19T15:50:29Z","updated_at":"2016-02-17T17:28:00Z","pushed_at":"2016-02-18T01:22:57Z","git_url":"git://github.com/quantopian/zipline.git","ssh_url":"git@github.com:quantopian/zipline.git","clone_url":"https://github.com/quantopian/zipline.git","svn_url":"https://github.com/quantopian/zipline","homepage":"","size":15222,"stargazers_count":2903,"watchers_count":2903,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":844,"mirror_url":null,"open_issues_count":157,"forks":844,"open_issues":157,"watchers":2903,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/990"},"html":{"href":"https://github.com/quantopian/zipline/pull/990"},"issue":{"href":"https://api.github.com/repos/quantopian/zipline/issues/990"},"comments":{"href":"https://api.github.com/repos/quantopian/zipline/issues/990/comments"},"review_comments":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/990/comments"},"review_comment":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quantopian/zipline/pulls/990/commits"},"statuses":{"href":"https://api.github.com/repos/quantopian/zipline/statuses/6f13468073476a993049baa7758846ad453859f1"}}}}