{"action":"created","comment":{"url":"https://api.github.com/repos/pyne/pyne/pulls/comments/125928988","pull_request_review_id":48366375,"id":125928988,"diff_hunk":"@@ -370,3 +379,137 @@ def parse_det(detfile, write_py=False):\n     exec(f, {}, det)\n \n     return det\n+\n+\n+def parse_coe(coefile, grabB1=True):\n+    \"\"\" Used to parse output from serpent 2's ability to branch problem variables\n+    in order to generate group constants at several states.\n+\n+    See the serpent wiki at:\n+    http://serpent.vtt.fi/mediawiki/index.php/Automated_burnup_sequence\n+\n+    Parameters\n+    ----------\n+    coefile : str or file-like object\n+        Path to *.coe file or a *.coe file handle.\n+    grabB1 : bool\n+        whether to include results from the B1 corrected spectrum\n+        if group constants were generated on full-core, set this to false\n+        to save memory.\n+\n+    Returns\n+    -------\n+    coe : dict\n+        Nested dictionary of the parsed coe file. First dimension key is\n+        burnup index (1-indexed). Next is the universe group constants were\n+        generated in. Then, branch names represent the keys, in the order that\n+        serpent printed them. On the final dimension, the parameters returned\n+        by serpent make up the remaining keys.\n+\n+        note: B1 is used for leakage-corrected group constants generated on\n+        an infinite lattice. Don't use these values otherwise.\n+\n+    \"\"\"\n+    if isinstance(coefile, basestring):\n+        f = open(coefile, 'r')\n+    else:\n+        f = coefile\n+\n+    coe = {}\n+    layers = None\n+\n+    while True:\n+\n+        # this line describes branch and coe indices\n+        try:\n+            l = next(f).split()\n+        except StopIteration:\n+            break\n+        _, numbranch, coeIndex, nTot, nUni = tuple([int(item) for item in l])\n+\n+        # this line describes what branch you're on\n+        l = next(f).split()\n+        # init list to hold branch names if it is still None\n+        if layers is None:\n+            layers = [[] for i in range(int(l[0]))]\n+        for i, branch in enumerate(l[1:]):\n+            # append if not seen before\n+            if branch not in layers[i]:\n+                layers[i].append(branch)\n+        theseBranches = l[1:]\n+\n+        next(f)\n+        l = next(f).split()\n+        BUi = int(l[1])  # index of BU step\n+        if BUi not in coe.keys():\n+            coe[BUi] = {}\n+\n+        # ok, should be at a totally new set of data now,\n+        # so, let's gather all params.\n+        for iUni in range(nUni):\n+\n+            l = next(f).split()\n+            uni = l[0]\n+            if uni not in coe[BUi].keys():\n+                coe[BUi][uni] = {}\n+            nPara = int(l[1])  # num of params to follow\n+\n+            thisCoe = coe[BUi][uni]\n+            # delve through the branches, reassigning the thisCoe reference\n+            # at each successive level\n+            for branch in theseBranches:\n+                if branch not in thisCoe.keys():\n+                    thisCoe[branch] = {}\n+                thisCoe = thisCoe[branch]\n+\n+            names = []\n+            values = []  # should all be numeric in nature\n+            for i in range(nPara):\n+                # build from lists to avoid frequently rehashing dicts\n+                l = next(f).split()\n+                name = l[0]\n+                # check if B1\n+                # also, yeah 'and' could be used, but bool checking\n+                # is faster than string comparison, so that's why to nest\n+                if not grabB1:\n+                    if name[0:2] == 'B1':\n+                        continue\n+                value = l[2:]\n+                names.append(name)\n+                if len(values) == 1:\n+                    values.append(float(value[0]))\n+                else:\n+                    values.append([float(item) for item in value])\n+\n+            thisCoe = coe[BUi][uni]\n+            for branch in theseBranches:\n+                thisCoe = thisCoe[branch]\n+            thisCoe = dict(zip(names, values))\n+\n+    f.close()\n+\n+    return coe\n+\n+\n+def print_coe(coedict, lvl=0):\n+    \"\"\" Pretty prints a dictionary returned\n+    by parse_coe. Use this to visualize its\n+    nested structure.\n+\n+    Parameters:","path":"pyne/serpent.py","position":null,"original_position":210,"commit_id":"706ba14c93ae4bdc11343d80d665e3d6c1ae9cca","original_commit_id":"8def163a6a452a36ab921fb6ebc308689cc893d5","user":{"login":"gridley","id":18088906,"avatar_url":"https://avatars3.githubusercontent.com/u/18088906?v=3","gravatar_id":"","url":"https://api.github.com/users/gridley","html_url":"https://github.com/gridley","followers_url":"https://api.github.com/users/gridley/followers","following_url":"https://api.github.com/users/gridley/following{/other_user}","gists_url":"https://api.github.com/users/gridley/gists{/gist_id}","starred_url":"https://api.github.com/users/gridley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gridley/subscriptions","organizations_url":"https://api.github.com/users/gridley/orgs","repos_url":"https://api.github.com/users/gridley/repos","events_url":"https://api.github.com/users/gridley/events{/privacy}","received_events_url":"https://api.github.com/users/gridley/received_events","type":"User","site_admin":false},"body":"fixed this, and now with tests passing.","created_at":"2017-07-06T15:11:33Z","updated_at":"2017-07-06T15:11:33Z","html_url":"https://github.com/pyne/pyne/pull/898#discussion_r125928988","pull_request_url":"https://api.github.com/repos/pyne/pyne/pulls/898","_links":{"self":{"href":"https://api.github.com/repos/pyne/pyne/pulls/comments/125928988"},"html":{"href":"https://github.com/pyne/pyne/pull/898#discussion_r125928988"},"pull_request":{"href":"https://api.github.com/repos/pyne/pyne/pulls/898"}}},"pull_request":{"url":"https://api.github.com/repos/pyne/pyne/pulls/898","id":128677025,"html_url":"https://github.com/pyne/pyne/pull/898","diff_url":"https://github.com/pyne/pyne/pull/898.diff","patch_url":"https://github.com/pyne/pyne/pull/898.patch","issue_url":"https://api.github.com/repos/pyne/pyne/issues/898","number":898,"state":"open","locked":false,"title":"Serpent branching group constants parsing in pyne/serpent.py","user":{"login":"gridley","id":18088906,"avatar_url":"https://avatars3.githubusercontent.com/u/18088906?v=3","gravatar_id":"","url":"https://api.github.com/users/gridley","html_url":"https://github.com/gridley","followers_url":"https://api.github.com/users/gridley/followers","following_url":"https://api.github.com/users/gridley/following{/other_user}","gists_url":"https://api.github.com/users/gridley/gists{/gist_id}","starred_url":"https://api.github.com/users/gridley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gridley/subscriptions","organizations_url":"https://api.github.com/users/gridley/orgs","repos_url":"https://api.github.com/users/gridley/repos","events_url":"https://api.github.com/users/gridley/events{/privacy}","received_events_url":"https://api.github.com/users/gridley/received_events","type":"User","site_admin":false},"body":"Hi all,\r\n\r\nThese commits add capability to serpent.py to parse its somewhat different group constant generation output. For information on the syntax for having serpent do this, please see here [here](http://serpent.vtt.fi/mediawiki/index.php/Automated_burnup_sequence). The braching must cover all combinations of variations created with the \"branch\" command, so the parsed data is given as a nested dictionary. This should facilitate keeping data organized. The entries in the dictionary are indexed by first burnup step, then universe ID, then all branch names, and finally the parameter name of interest. An example can be found in the docstring for parse_coe.\r\n\r\nIn addition, a function for printing the coefficient dictionaries was included. This should display all of the nested structure quite well. Subsequently nested data gets indented, and not all params are printed by default for brevity.\r\n\r\nLastly, an appropriate test and example output file was added to the tests directory, implemented in test_serpent.py.","created_at":"2017-07-03T18:27:29Z","updated_at":"2017-07-06T15:11:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dea1696c97acd2706ada2f83c2903bcc572d7860","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pyne/pyne/pulls/898/commits","review_comments_url":"https://api.github.com/repos/pyne/pyne/pulls/898/comments","review_comment_url":"https://api.github.com/repos/pyne/pyne/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyne/pyne/issues/898/comments","statuses_url":"https://api.github.com/repos/pyne/pyne/statuses/706ba14c93ae4bdc11343d80d665e3d6c1ae9cca","head":{"label":"gridley:sssCoe","ref":"sssCoe","sha":"706ba14c93ae4bdc11343d80d665e3d6c1ae9cca","user":{"login":"gridley","id":18088906,"avatar_url":"https://avatars3.githubusercontent.com/u/18088906?v=3","gravatar_id":"","url":"https://api.github.com/users/gridley","html_url":"https://github.com/gridley","followers_url":"https://api.github.com/users/gridley/followers","following_url":"https://api.github.com/users/gridley/following{/other_user}","gists_url":"https://api.github.com/users/gridley/gists{/gist_id}","starred_url":"https://api.github.com/users/gridley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gridley/subscriptions","organizations_url":"https://api.github.com/users/gridley/orgs","repos_url":"https://api.github.com/users/gridley/repos","events_url":"https://api.github.com/users/gridley/events{/privacy}","received_events_url":"https://api.github.com/users/gridley/received_events","type":"User","site_admin":false},"repo":{"id":95921842,"name":"pyne","full_name":"gridley/pyne","owner":{"login":"gridley","id":18088906,"avatar_url":"https://avatars3.githubusercontent.com/u/18088906?v=3","gravatar_id":"","url":"https://api.github.com/users/gridley","html_url":"https://github.com/gridley","followers_url":"https://api.github.com/users/gridley/followers","following_url":"https://api.github.com/users/gridley/following{/other_user}","gists_url":"https://api.github.com/users/gridley/gists{/gist_id}","starred_url":"https://api.github.com/users/gridley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gridley/subscriptions","organizations_url":"https://api.github.com/users/gridley/orgs","repos_url":"https://api.github.com/users/gridley/repos","events_url":"https://api.github.com/users/gridley/events{/privacy}","received_events_url":"https://api.github.com/users/gridley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gridley/pyne","description":"PyNE: The Nuclear Engineering Toolkit","fork":true,"url":"https://api.github.com/repos/gridley/pyne","forks_url":"https://api.github.com/repos/gridley/pyne/forks","keys_url":"https://api.github.com/repos/gridley/pyne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gridley/pyne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gridley/pyne/teams","hooks_url":"https://api.github.com/repos/gridley/pyne/hooks","issue_events_url":"https://api.github.com/repos/gridley/pyne/issues/events{/number}","events_url":"https://api.github.com/repos/gridley/pyne/events","assignees_url":"https://api.github.com/repos/gridley/pyne/assignees{/user}","branches_url":"https://api.github.com/repos/gridley/pyne/branches{/branch}","tags_url":"https://api.github.com/repos/gridley/pyne/tags","blobs_url":"https://api.github.com/repos/gridley/pyne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gridley/pyne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gridley/pyne/git/refs{/sha}","trees_url":"https://api.github.com/repos/gridley/pyne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gridley/pyne/statuses/{sha}","languages_url":"https://api.github.com/repos/gridley/pyne/languages","stargazers_url":"https://api.github.com/repos/gridley/pyne/stargazers","contributors_url":"https://api.github.com/repos/gridley/pyne/contributors","subscribers_url":"https://api.github.com/repos/gridley/pyne/subscribers","subscription_url":"https://api.github.com/repos/gridley/pyne/subscription","commits_url":"https://api.github.com/repos/gridley/pyne/commits{/sha}","git_commits_url":"https://api.github.com/repos/gridley/pyne/git/commits{/sha}","comments_url":"https://api.github.com/repos/gridley/pyne/comments{/number}","issue_comment_url":"https://api.github.com/repos/gridley/pyne/issues/comments{/number}","contents_url":"https://api.github.com/repos/gridley/pyne/contents/{+path}","compare_url":"https://api.github.com/repos/gridley/pyne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gridley/pyne/merges","archive_url":"https://api.github.com/repos/gridley/pyne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gridley/pyne/downloads","issues_url":"https://api.github.com/repos/gridley/pyne/issues{/number}","pulls_url":"https://api.github.com/repos/gridley/pyne/pulls{/number}","milestones_url":"https://api.github.com/repos/gridley/pyne/milestones{/number}","notifications_url":"https://api.github.com/repos/gridley/pyne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gridley/pyne/labels{/name}","releases_url":"https://api.github.com/repos/gridley/pyne/releases{/id}","deployments_url":"https://api.github.com/repos/gridley/pyne/deployments","created_at":"2017-06-30T20:29:53Z","updated_at":"2017-06-30T20:29:57Z","pushed_at":"2017-07-06T15:11:16Z","git_url":"git://github.com/gridley/pyne.git","ssh_url":"git@github.com:gridley/pyne.git","clone_url":"https://github.com/gridley/pyne.git","svn_url":"https://github.com/gridley/pyne","homepage":"http://pyne.io/","size":20077,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"pyne:develop","ref":"develop","sha":"db02976fda77559354c38e33c38d60f321fb3190","user":{"login":"pyne","id":760696,"avatar_url":"https://avatars1.githubusercontent.com/u/760696?v=3","gravatar_id":"","url":"https://api.github.com/users/pyne","html_url":"https://github.com/pyne","followers_url":"https://api.github.com/users/pyne/followers","following_url":"https://api.github.com/users/pyne/following{/other_user}","gists_url":"https://api.github.com/users/pyne/gists{/gist_id}","starred_url":"https://api.github.com/users/pyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyne/subscriptions","organizations_url":"https://api.github.com/users/pyne/orgs","repos_url":"https://api.github.com/users/pyne/repos","events_url":"https://api.github.com/users/pyne/events{/privacy}","received_events_url":"https://api.github.com/users/pyne/received_events","type":"Organization","site_admin":false},"repo":{"id":1684953,"name":"pyne","full_name":"pyne/pyne","owner":{"login":"pyne","id":760696,"avatar_url":"https://avatars1.githubusercontent.com/u/760696?v=3","gravatar_id":"","url":"https://api.github.com/users/pyne","html_url":"https://github.com/pyne","followers_url":"https://api.github.com/users/pyne/followers","following_url":"https://api.github.com/users/pyne/following{/other_user}","gists_url":"https://api.github.com/users/pyne/gists{/gist_id}","starred_url":"https://api.github.com/users/pyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyne/subscriptions","organizations_url":"https://api.github.com/users/pyne/orgs","repos_url":"https://api.github.com/users/pyne/repos","events_url":"https://api.github.com/users/pyne/events{/privacy}","received_events_url":"https://api.github.com/users/pyne/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyne/pyne","description":"PyNE: The Nuclear Engineering Toolkit","fork":false,"url":"https://api.github.com/repos/pyne/pyne","forks_url":"https://api.github.com/repos/pyne/pyne/forks","keys_url":"https://api.github.com/repos/pyne/pyne/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyne/pyne/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyne/pyne/teams","hooks_url":"https://api.github.com/repos/pyne/pyne/hooks","issue_events_url":"https://api.github.com/repos/pyne/pyne/issues/events{/number}","events_url":"https://api.github.com/repos/pyne/pyne/events","assignees_url":"https://api.github.com/repos/pyne/pyne/assignees{/user}","branches_url":"https://api.github.com/repos/pyne/pyne/branches{/branch}","tags_url":"https://api.github.com/repos/pyne/pyne/tags","blobs_url":"https://api.github.com/repos/pyne/pyne/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyne/pyne/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyne/pyne/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyne/pyne/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyne/pyne/statuses/{sha}","languages_url":"https://api.github.com/repos/pyne/pyne/languages","stargazers_url":"https://api.github.com/repos/pyne/pyne/stargazers","contributors_url":"https://api.github.com/repos/pyne/pyne/contributors","subscribers_url":"https://api.github.com/repos/pyne/pyne/subscribers","subscription_url":"https://api.github.com/repos/pyne/pyne/subscription","commits_url":"https://api.github.com/repos/pyne/pyne/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyne/pyne/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyne/pyne/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyne/pyne/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyne/pyne/contents/{+path}","compare_url":"https://api.github.com/repos/pyne/pyne/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyne/pyne/merges","archive_url":"https://api.github.com/repos/pyne/pyne/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyne/pyne/downloads","issues_url":"https://api.github.com/repos/pyne/pyne/issues{/number}","pulls_url":"https://api.github.com/repos/pyne/pyne/pulls{/number}","milestones_url":"https://api.github.com/repos/pyne/pyne/milestones{/number}","notifications_url":"https://api.github.com/repos/pyne/pyne/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyne/pyne/labels{/name}","releases_url":"https://api.github.com/repos/pyne/pyne/releases{/id}","deployments_url":"https://api.github.com/repos/pyne/pyne/deployments","created_at":"2011-04-30T15:04:07Z","updated_at":"2017-07-04T17:03:11Z","pushed_at":"2017-07-06T15:11:17Z","git_url":"git://github.com/pyne/pyne.git","ssh_url":"git@github.com:pyne/pyne.git","clone_url":"https://github.com/pyne/pyne.git","svn_url":"https://github.com/pyne/pyne","homepage":"http://pyne.io/","size":19860,"stargazers_count":80,"watchers_count":80,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":106,"mirror_url":null,"open_issues_count":98,"forks":106,"open_issues":98,"watchers":80,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/pyne/pyne/pulls/898"},"html":{"href":"https://github.com/pyne/pyne/pull/898"},"issue":{"href":"https://api.github.com/repos/pyne/pyne/issues/898"},"comments":{"href":"https://api.github.com/repos/pyne/pyne/issues/898/comments"},"review_comments":{"href":"https://api.github.com/repos/pyne/pyne/pulls/898/comments"},"review_comment":{"href":"https://api.github.com/repos/pyne/pyne/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyne/pyne/pulls/898/commits"},"statuses":{"href":"https://api.github.com/repos/pyne/pyne/statuses/706ba14c93ae4bdc11343d80d665e3d6c1ae9cca"}}}}
{"actor":{"display_login":"gridley"}}