{"action":"created","comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments/31593538","id":31593538,"diff_hunk":"@@ -0,0 +1,114 @@\n+import numpy.testing as npt\n+from pymc3.tests import backend_fixtures as bf\n+from pymc3.backends import ndarray, csv\n+\n+\n+class TestCSV0dSampling(bf.SamplingTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = ()\n+\n+\n+class TestCSV1dSampling(bf.SamplingTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = 2\n+\n+\n+class TestCSV2dSampling(bf.SamplingTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = (2, 3)\n+\n+\n+class TestCSV0dSelection(bf.SelectionNoSliceTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = ()\n+\n+\n+class TestCSV1dSelection(bf.SelectionNoSliceTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = 2\n+\n+\n+class TestCSV2dSelection(bf.SelectionNoSliceTestCase):\n+    backend = csv.CSV\n+    name = 'csv-db'\n+    shape = (2, 3)\n+\n+\n+class TestCSVDumpLoad(bf.DumpLoadTestCase):\n+    backend = csv.CSV\n+    load_func = staticmethod(csv.load)\n+    name = 'csv-db'\n+    shape = (2, 3)\n+\n+\n+class TestCSVDumpFunction(bf.BackendEqualityTestCase):\n+    backend0 = backend1 = ndarray.NDArray\n+    name0 = None\n+    name1 = 'csv-db'\n+    shape = (2, 3)\n+\n+    @classmethod\n+    def setUpClass(cls):\n+        super(TestCSVDumpFunction, cls).setUpClass()\n+        csv.dump(cls.name1, cls.mtrace1)\n+        with cls.model:\n+            cls.mtrace1 = csv.load(cls.name1)\n+\n+\n+class TestTraceToDf(bf.ModelBackendSampledTestCase):\n+    backend = ndarray.NDArray\n+    name = 'csv-db'\n+    shape = (2, 3)\n+\n+    def test_trace_to_df(self):\n+        mtrace = self.mtrace\n+        df = csv._trace_to_df(mtrace._traces[0])\n+        self.assertEqual(len(mtrace), df.shape[0])\n+\n+        xarr = mtrace.get_values('x', chains=0)\n+        npt.assert_equal(xarr[:, 0, 0], df['x__0_0'].values)\n+        npt.assert_equal(xarr[:, 1, 0], df['x__1_0'].values)\n+        npt.assert_equal(xarr[:, 1, 2], df['x__1_2'].values)\n+\n+\n+class TestNDArrayCSVEquality(bf.BackendEqualityTestCase):\n+    backend0 = ndarray.NDArray\n+    name0 = None\n+    backend1 = csv.CSV\n+    name1 = 'test.db'\n+    shape = (2, 3)\n+\n+\n+def test_create_flat_names_0d():\n+    shape = ()\n+    result = csv._create_flat_names('x', shape)\n+    expected = ['x']\n+    assert result == expected\n+    assert csv._create_shape(result) == shape\n+\n+\n+def test_create_flat_names_1d():\n+    shape = 2,\n+    result = csv._create_flat_names('x', shape)\n+    expected = ['x__0', 'x__1']","path":"pymc3/tests/test_csv_backend.py","position":98,"original_position":98,"commit_id":"f690fb996783787023826721e3c25f126b504812","original_commit_id":"f690fb996783787023826721e3c25f126b504812","user":{"login":"kyleam","id":1297788,"avatar_url":"https://avatars.githubusercontent.com/u/1297788?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleam","html_url":"https://github.com/kyleam","followers_url":"https://api.github.com/users/kyleam/followers","following_url":"https://api.github.com/users/kyleam/following{/other_user}","gists_url":"https://api.github.com/users/kyleam/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleam/subscriptions","organizations_url":"https://api.github.com/users/kyleam/orgs","repos_url":"https://api.github.com/users/kyleam/repos","events_url":"https://api.github.com/users/kyleam/events{/privacy}","received_events_url":"https://api.github.com/users/kyleam/received_events","type":"User","site_admin":false},"body":"Just to make the indices visually distinct since it's common for\r\nvariable names to have both underscores and digits.  But if people\r\nhave a strong preference against it, I'm ok changing it to one\r\nunderscore.\r\n","created_at":"2015-06-03T04:47:14Z","updated_at":"2015-06-03T04:47:14Z","html_url":"https://github.com/pymc-devs/pymc3/pull/723#discussion_r31593538","pull_request_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723","_links":{"self":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments/31593538"},"html":{"href":"https://github.com/pymc-devs/pymc3/pull/723#discussion_r31593538"},"pull_request":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723"}}},"pull_request":{"url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723","id":36597464,"html_url":"https://github.com/pymc-devs/pymc3/pull/723","diff_url":"https://github.com/pymc-devs/pymc3/pull/723.diff","patch_url":"https://github.com/pymc-devs/pymc3/pull/723.patch","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/723","number":723,"state":"open","locked":false,"title":"Add CSV backend","user":{"login":"kyleam","id":1297788,"avatar_url":"https://avatars.githubusercontent.com/u/1297788?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleam","html_url":"https://github.com/kyleam","followers_url":"https://api.github.com/users/kyleam/followers","following_url":"https://api.github.com/users/kyleam/following{/other_user}","gists_url":"https://api.github.com/users/kyleam/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleam/subscriptions","organizations_url":"https://api.github.com/users/kyleam/orgs","repos_url":"https://api.github.com/users/kyleam/repos","events_url":"https://api.github.com/users/kyleam/events{/privacy}","received_events_url":"https://api.github.com/users/kyleam/received_events","type":"User","site_admin":false},"body":"This has a couple of advantages over the Text backend.\r\n\r\n1. The values are stored as in a table per chain, not a file per\r\n   variable.  This is easier to inspect and work with directly if\r\n   desired (e.g., with pd.read_csv).\r\n\r\n2. Values are stored during sampling, not kept in memory.\r\n\r\nThis relies on Pandas, which currently isn't listed as a hard\r\ndependency.","created_at":"2015-06-01T03:52:55Z","updated_at":"2015-06-03T04:47:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00b7f7b15cadb9ffe597231f624936d037c9b093","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723/commits","review_comments_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723/comments","review_comment_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/723/comments","statuses_url":"https://api.github.com/repos/pymc-devs/pymc3/statuses/f690fb996783787023826721e3c25f126b504812","head":{"label":"pymc-devs:csv","ref":"csv","sha":"f690fb996783787023826721e3c25f126b504812","user":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"repo":{"id":192904,"name":"pymc3","full_name":"pymc-devs/pymc3","owner":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pymc-devs/pymc3","description":"PyMC version 3","fork":false,"url":"https://api.github.com/repos/pymc-devs/pymc3","forks_url":"https://api.github.com/repos/pymc-devs/pymc3/forks","keys_url":"https://api.github.com/repos/pymc-devs/pymc3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pymc-devs/pymc3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pymc-devs/pymc3/teams","hooks_url":"https://api.github.com/repos/pymc-devs/pymc3/hooks","issue_events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/events{/number}","events_url":"https://api.github.com/repos/pymc-devs/pymc3/events","assignees_url":"https://api.github.com/repos/pymc-devs/pymc3/assignees{/user}","branches_url":"https://api.github.com/repos/pymc-devs/pymc3/branches{/branch}","tags_url":"https://api.github.com/repos/pymc-devs/pymc3/tags","blobs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pymc-devs/pymc3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/refs{/sha}","trees_url":"https://api.github.com/repos/pymc-devs/pymc3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pymc-devs/pymc3/statuses/{sha}","languages_url":"https://api.github.com/repos/pymc-devs/pymc3/languages","stargazers_url":"https://api.github.com/repos/pymc-devs/pymc3/stargazers","contributors_url":"https://api.github.com/repos/pymc-devs/pymc3/contributors","subscribers_url":"https://api.github.com/repos/pymc-devs/pymc3/subscribers","subscription_url":"https://api.github.com/repos/pymc-devs/pymc3/subscription","commits_url":"https://api.github.com/repos/pymc-devs/pymc3/commits{/sha}","git_commits_url":"https://api.github.com/repos/pymc-devs/pymc3/git/commits{/sha}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/comments{/number}","issue_comment_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments{/number}","contents_url":"https://api.github.com/repos/pymc-devs/pymc3/contents/{+path}","compare_url":"https://api.github.com/repos/pymc-devs/pymc3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pymc-devs/pymc3/merges","archive_url":"https://api.github.com/repos/pymc-devs/pymc3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pymc-devs/pymc3/downloads","issues_url":"https://api.github.com/repos/pymc-devs/pymc3/issues{/number}","pulls_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls{/number}","milestones_url":"https://api.github.com/repos/pymc-devs/pymc3/milestones{/number}","notifications_url":"https://api.github.com/repos/pymc-devs/pymc3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/labels{/name}","releases_url":"https://api.github.com/repos/pymc-devs/pymc3/releases{/id}","created_at":"2009-05-05T09:43:50Z","updated_at":"2015-06-02T00:58:14Z","pushed_at":"2015-06-03T04:27:35Z","git_url":"git://github.com/pymc-devs/pymc3.git","ssh_url":"git@github.com:pymc-devs/pymc3.git","clone_url":"https://github.com/pymc-devs/pymc3.git","svn_url":"https://github.com/pymc-devs/pymc3","homepage":"","size":50795,"stargazers_count":1054,"watchers_count":1054,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":235,"mirror_url":null,"open_issues_count":72,"forks":235,"open_issues":72,"watchers":1054,"default_branch":"master"}},"base":{"label":"pymc-devs:master","ref":"master","sha":"fb8f964ebeb671b71a164807790d336af5efe66d","user":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"repo":{"id":192904,"name":"pymc3","full_name":"pymc-devs/pymc3","owner":{"login":"pymc-devs","id":81121,"avatar_url":"https://avatars.githubusercontent.com/u/81121?v=3","gravatar_id":"","url":"https://api.github.com/users/pymc-devs","html_url":"https://github.com/pymc-devs","followers_url":"https://api.github.com/users/pymc-devs/followers","following_url":"https://api.github.com/users/pymc-devs/following{/other_user}","gists_url":"https://api.github.com/users/pymc-devs/gists{/gist_id}","starred_url":"https://api.github.com/users/pymc-devs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pymc-devs/subscriptions","organizations_url":"https://api.github.com/users/pymc-devs/orgs","repos_url":"https://api.github.com/users/pymc-devs/repos","events_url":"https://api.github.com/users/pymc-devs/events{/privacy}","received_events_url":"https://api.github.com/users/pymc-devs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pymc-devs/pymc3","description":"PyMC version 3","fork":false,"url":"https://api.github.com/repos/pymc-devs/pymc3","forks_url":"https://api.github.com/repos/pymc-devs/pymc3/forks","keys_url":"https://api.github.com/repos/pymc-devs/pymc3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pymc-devs/pymc3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pymc-devs/pymc3/teams","hooks_url":"https://api.github.com/repos/pymc-devs/pymc3/hooks","issue_events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/events{/number}","events_url":"https://api.github.com/repos/pymc-devs/pymc3/events","assignees_url":"https://api.github.com/repos/pymc-devs/pymc3/assignees{/user}","branches_url":"https://api.github.com/repos/pymc-devs/pymc3/branches{/branch}","tags_url":"https://api.github.com/repos/pymc-devs/pymc3/tags","blobs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pymc-devs/pymc3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pymc-devs/pymc3/git/refs{/sha}","trees_url":"https://api.github.com/repos/pymc-devs/pymc3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pymc-devs/pymc3/statuses/{sha}","languages_url":"https://api.github.com/repos/pymc-devs/pymc3/languages","stargazers_url":"https://api.github.com/repos/pymc-devs/pymc3/stargazers","contributors_url":"https://api.github.com/repos/pymc-devs/pymc3/contributors","subscribers_url":"https://api.github.com/repos/pymc-devs/pymc3/subscribers","subscription_url":"https://api.github.com/repos/pymc-devs/pymc3/subscription","commits_url":"https://api.github.com/repos/pymc-devs/pymc3/commits{/sha}","git_commits_url":"https://api.github.com/repos/pymc-devs/pymc3/git/commits{/sha}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/comments{/number}","issue_comment_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments{/number}","contents_url":"https://api.github.com/repos/pymc-devs/pymc3/contents/{+path}","compare_url":"https://api.github.com/repos/pymc-devs/pymc3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pymc-devs/pymc3/merges","archive_url":"https://api.github.com/repos/pymc-devs/pymc3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pymc-devs/pymc3/downloads","issues_url":"https://api.github.com/repos/pymc-devs/pymc3/issues{/number}","pulls_url":"https://api.github.com/repos/pymc-devs/pymc3/pulls{/number}","milestones_url":"https://api.github.com/repos/pymc-devs/pymc3/milestones{/number}","notifications_url":"https://api.github.com/repos/pymc-devs/pymc3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/labels{/name}","releases_url":"https://api.github.com/repos/pymc-devs/pymc3/releases{/id}","created_at":"2009-05-05T09:43:50Z","updated_at":"2015-06-02T00:58:14Z","pushed_at":"2015-06-03T04:27:35Z","git_url":"git://github.com/pymc-devs/pymc3.git","ssh_url":"git@github.com:pymc-devs/pymc3.git","clone_url":"https://github.com/pymc-devs/pymc3.git","svn_url":"https://github.com/pymc-devs/pymc3","homepage":"","size":50795,"stargazers_count":1054,"watchers_count":1054,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":235,"mirror_url":null,"open_issues_count":72,"forks":235,"open_issues":72,"watchers":1054,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723"},"html":{"href":"https://github.com/pymc-devs/pymc3/pull/723"},"issue":{"href":"https://api.github.com/repos/pymc-devs/pymc3/issues/723"},"comments":{"href":"https://api.github.com/repos/pymc-devs/pymc3/issues/723/comments"},"review_comments":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723/comments"},"review_comment":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pymc-devs/pymc3/pulls/723/commits"},"statuses":{"href":"https://api.github.com/repos/pymc-devs/pymc3/statuses/f690fb996783787023826721e3c25f126b504812"}}}}