{"action":"created","comment":{"url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/comments/92947374","pull_request_review_id":13469378,"id":92947374,"diff_hunk":"@@ -343,6 +378,161 @@ def test_mean_variance_compute():\n     assert np.all(EH.MultilevelExpectation.dat.data == exact_mean) == 1\n \n \n+def test_identifier_hierarchy():\n+\n+    M = UnitSquareMesh(10, 10)\n+    L = 3\n+    MH = MeshHierarchy(M, L)\n+\n+    V_h = [FunctionSpace(m, 'DG', 1) for m in MH]\n+\n+    EH = EnsembleHierarchy(V_h)\n+\n+    u_h_1 = Function(V_h[0]).assign(1)\n+    u_h_2 = Function(V_h[1]).assign(2)\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        assert EH._identifier_hierarchy[0][i] == S.identifier\n+        assert S.index == tuple([0, i])\n+\n+    u_h_1 = Function(V_h[1]).assign(2)\n+    u_h_2 = Function(V_h[2]).assign(3)\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        assert EH._identifier_hierarchy[1][i] == S.identifier\n+        assert S.index == tuple([1, i])\n+\n+    assert len(EH._identifier_hierarchy) == len(EH._hierarchy)\n+    assert len(EH._identifier_hierarchy[0]) == len(EH._hierarchy[0])\n+    assert len(EH._identifier_hierarchy[1]) == len(EH._hierarchy[1])\n+\n+\n+def test_state_hierarchy_1():\n+\n+    M = UnitSquareMesh(10, 10)\n+    L = 3\n+    MH = MeshHierarchy(M, L)\n+\n+    V_h = [FunctionSpace(m, 'DG', 1) for m in MH]\n+\n+    EH = EnsembleHierarchy(V_h)\n+\n+    u_h_1 = Function(V_h[0]).assign(1)\n+    u_h_2 = Function(V_h[1]).assign(2)\n+\n+    ens1 = []\n+    ens2 = []\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        ens1.append(S)\n+        assert np.max(np.abs(EH._state_hierarchy[0][i].state[1].dat.data -\n+                      ens1[i].state[1].dat.data)) < 1e-5\n+        assert np.max(np.abs(EH._state_hierarchy[0][i].identifier - ens1[i].identifier)) < 1e-5\n+\n+    u_h_1 = Function(V_h[1]).assign(2)\n+    u_h_2 = Function(V_h[2]).assign(3)\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        ens2.append(S)\n+        assert np.max(np.abs(EH._state_hierarchy[1][i].state[1].dat.data -\n+                      ens2[i].state[1].dat.data)) < 1e-5\n+        assert np.max(np.abs(EH._state_hierarchy[1][i].identifier - ens2[i].identifier)) < 1e-5\n+\n+\n+def test_updating_ensemble_members():\n+\n+    M = UnitSquareMesh(10, 10)\n+    L = 3\n+    MH = MeshHierarchy(M, L)\n+\n+    V_h = [FunctionSpace(m, 'DG', 1) for m in MH]\n+\n+    EH = EnsembleHierarchy(V_h)\n+\n+    u_h_1 = Function(V_h[0]).assign(1)\n+    u_h_2 = Function(V_h[1]).assign(2)\n+\n+    ens1 = []\n+    ens2 = []\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        ens1.append(S)\n+\n+    u_h_1 = Function(V_h[1]).assign(2)\n+    u_h_2 = Function(V_h[2]).assign(3)\n+\n+    for i in range(10):\n+\n+        S = State(u_h_1, u_h_2)\n+        EH.AppendToEnsemble(S)\n+        ens2.append(S)","path":"tests/test_ensemble_hierarchy.py","position":113,"original_position":148,"commit_id":"91a9f84b5020879011fe38d312f9107fa4301083","original_commit_id":"91a9f84b5020879011fe38d312f9107fa4301083","user":{"login":"alsgregory","id":16209367,"avatar_url":"https://avatars.githubusercontent.com/u/16209367?v=3","gravatar_id":"","url":"https://api.github.com/users/alsgregory","html_url":"https://github.com/alsgregory","followers_url":"https://api.github.com/users/alsgregory/followers","following_url":"https://api.github.com/users/alsgregory/following{/other_user}","gists_url":"https://api.github.com/users/alsgregory/gists{/gist_id}","starred_url":"https://api.github.com/users/alsgregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alsgregory/subscriptions","organizations_url":"https://api.github.com/users/alsgregory/orgs","repos_url":"https://api.github.com/users/alsgregory/repos","events_url":"https://api.github.com/users/alsgregory/events{/privacy}","received_events_url":"https://api.github.com/users/alsgregory/received_events","type":"User","site_admin":false},"body":"Here, instead of having to make a makeshift ensemble to keep states in before then updating them, as the real ensemble hierarchy has got the states that are projected and modified in, thus make another 'unmodified' ensemble hierarchy as an alternative attribute to EH than <_hierarchy>! Then keep this ensemble in here and just use this to go get the states again!","created_at":"2016-12-18T18:24:42Z","updated_at":"2016-12-18T18:24:42Z","html_url":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17#discussion_r92947374","pull_request_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/comments/92947374"},"html":{"href":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17#discussion_r92947374"},"pull_request":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17","id":95690160,"html_url":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17","diff_url":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17.diff","patch_url":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17.patch","issue_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/17","number":17,"state":"open","locked":false,"title":"update_ensemble_members","user":{"login":"alsgregory","id":16209367,"avatar_url":"https://avatars.githubusercontent.com/u/16209367?v=3","gravatar_id":"","url":"https://api.github.com/users/alsgregory","html_url":"https://github.com/alsgregory","followers_url":"https://api.github.com/users/alsgregory/followers","following_url":"https://api.github.com/users/alsgregory/following{/other_user}","gists_url":"https://api.github.com/users/alsgregory/gists{/gist_id}","starred_url":"https://api.github.com/users/alsgregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alsgregory/subscriptions","organizations_url":"https://api.github.com/users/alsgregory/orgs","repos_url":"https://api.github.com/users/alsgregory/repos","events_url":"https://api.github.com/users/alsgregory/events{/privacy}","received_events_url":"https://api.github.com/users/alsgregory/received_events","type":"User","site_admin":false},"body":"Additions:\r\n\r\n- Being able to update `State`s inside `EnsembleHierarchy`, and making a hierarchy (part of `EnsembleHierarchy`) that keeps `State`s existing on the original `FunctionSpace`s as to 'pick-up' with a realisation after calculating statistics etc.\r\n- For the class to realise where a `State` is in an `EnsembleHierarchy` and as to replace/update it, index tuples are used, attributed to the `State` object.\r\n- Unique idenitifiers are used to make sure that a `State` to be updated is definitely in an `EnsembleHierarchy` already and in the place that the index tells it to.","created_at":"2016-11-29T13:17:23Z","updated_at":"2016-12-18T18:24:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c2adaab5cf0ac84dafa6cbeb42a3df76ef1e8565","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17/commits","review_comments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17/comments","review_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/17/comments","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/statuses/91a9f84b5020879011fe38d312f9107fa4301083","head":{"label":"firedrakeproject:update_ensemble_members","ref":"update_ensemble_members","sha":"91a9f84b5020879011fe38d312f9107fa4301083","user":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"repo":{"id":64209942,"name":"firedrake-mlmc","full_name":"firedrakeproject/firedrake-mlmc","owner":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firedrakeproject/firedrake-mlmc","description":"A toolbox for multilevel Monte Carlo algorithms with Firedrake","fork":false,"url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc","forks_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/forks","keys_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/teams","hooks_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/hooks","issue_events_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/events{/number}","events_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/events","assignees_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/assignees{/user}","branches_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/branches{/branch}","tags_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/tags","blobs_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/refs{/sha}","trees_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/statuses/{sha}","languages_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/languages","stargazers_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/stargazers","contributors_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/contributors","subscribers_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/subscribers","subscription_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/subscription","commits_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/commits{/sha}","git_commits_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/commits{/sha}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/comments{/number}","issue_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/comments{/number}","contents_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/contents/{+path}","compare_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/merges","archive_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/downloads","issues_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues{/number}","pulls_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls{/number}","milestones_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/milestones{/number}","notifications_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/labels{/name}","releases_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/releases{/id}","deployments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/deployments","created_at":"2016-07-26T09:48:12Z","updated_at":"2016-08-16T08:22:43Z","pushed_at":"2016-11-29T13:54:08Z","git_url":"git://github.com/firedrakeproject/firedrake-mlmc.git","ssh_url":"git@github.com:firedrakeproject/firedrake-mlmc.git","clone_url":"https://github.com/firedrakeproject/firedrake-mlmc.git","svn_url":"https://github.com/firedrakeproject/firedrake-mlmc","homepage":null,"size":457,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"firedrakeproject:master","ref":"master","sha":"c5de9d73d7368aea08516bf3bf6d6c60ab40c233","user":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"repo":{"id":64209942,"name":"firedrake-mlmc","full_name":"firedrakeproject/firedrake-mlmc","owner":{"login":"firedrakeproject","id":5558005,"avatar_url":"https://avatars.githubusercontent.com/u/5558005?v=3","gravatar_id":"","url":"https://api.github.com/users/firedrakeproject","html_url":"https://github.com/firedrakeproject","followers_url":"https://api.github.com/users/firedrakeproject/followers","following_url":"https://api.github.com/users/firedrakeproject/following{/other_user}","gists_url":"https://api.github.com/users/firedrakeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/firedrakeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firedrakeproject/subscriptions","organizations_url":"https://api.github.com/users/firedrakeproject/orgs","repos_url":"https://api.github.com/users/firedrakeproject/repos","events_url":"https://api.github.com/users/firedrakeproject/events{/privacy}","received_events_url":"https://api.github.com/users/firedrakeproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/firedrakeproject/firedrake-mlmc","description":"A toolbox for multilevel Monte Carlo algorithms with Firedrake","fork":false,"url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc","forks_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/forks","keys_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/teams","hooks_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/hooks","issue_events_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/events{/number}","events_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/events","assignees_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/assignees{/user}","branches_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/branches{/branch}","tags_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/tags","blobs_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/refs{/sha}","trees_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/statuses/{sha}","languages_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/languages","stargazers_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/stargazers","contributors_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/contributors","subscribers_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/subscribers","subscription_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/subscription","commits_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/commits{/sha}","git_commits_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/git/commits{/sha}","comments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/comments{/number}","issue_comment_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/comments{/number}","contents_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/contents/{+path}","compare_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/merges","archive_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/downloads","issues_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues{/number}","pulls_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls{/number}","milestones_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/milestones{/number}","notifications_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/labels{/name}","releases_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/releases{/id}","deployments_url":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/deployments","created_at":"2016-07-26T09:48:12Z","updated_at":"2016-08-16T08:22:43Z","pushed_at":"2016-11-29T13:54:08Z","git_url":"git://github.com/firedrakeproject/firedrake-mlmc.git","ssh_url":"git@github.com:firedrakeproject/firedrake-mlmc.git","clone_url":"https://github.com/firedrakeproject/firedrake-mlmc.git","svn_url":"https://github.com/firedrakeproject/firedrake-mlmc","homepage":null,"size":457,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17"},"html":{"href":"https://github.com/firedrakeproject/firedrake-mlmc/pull/17"},"issue":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/17"},"comments":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/firedrakeproject/firedrake-mlmc/statuses/91a9f84b5020879011fe38d312f9107fa4301083"}}}}
{"actor":{"display_login":"alsgregory"}}