{"action":"created","comment":{"url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/comments/24253095","id":24253095,"diff_hunk":"@@ -0,0 +1,75 @@\n+\"\"\"Simple class for a centralized dictionary translating the normal ROOT and\n+Davinci variable names into their pretty versions. Several functions are\n+provided to obtain formatted strings for the variables. The longest substring\n+within the provided normal name is identified and return values are given\"\"\"\n+\n+\n+decor = '#text{{{0}}}'\n+decor_unit = '#text{{[{0}]}}'\n+decor_withunit = '#text{{{0} [{1}]}}'\n+\n+\n+def find_best_match(name):\n+    matched = []\n+    for var in v_dict.keys():\n+        if all(part in name for part in var.split('*')):\n+            matched.append(var)\n+    return max(matched, key=len)\n+\n+\n+def get_pretty(name):\n+    \"\"\"Function to return just the pretty name formatted for ROOT\"\"\"\n+    var, unit = v_dict[find_best_match(name)]\n+    return decor.format(var)\n+\n+\n+def get_pretty_with_unit(name):\n+    \"\"\"Function to return just the pretty name formatted for ROOT\"\"\"\n+    var, unit = v_dict[find_best_match(name)]\n+    if not unit:\n+        return decor.format(var)\n+    else:\n+        return decor_withunit.format(var, unit)\n+\n+\n+def get_pretty_tuple(name):\n+    \"\"\"Function returning a tuple of pretty formated var and unit\"\"\"\n+    var, unit = v_dict[find_best_match(name)]\n+    if not unit:\n+        return (decor.format(var), '')\n+    else:\n+        return (decor.format(var), decor_unit.format(unit))\n+\n+\n+def get_pretty_tuple_bdttools(name):\n+    \"\"\"Function returning a tuple of pretty formated\n+    var and unit for BDTTools\"\"\"\n+    var, unit = v_dict[find_best_match(name)]\n+    if not unit:\n+        return (decor.format(var), 'NONE')\n+    else:\n+        return (decor.format(var), decor_unit.format(unit))\n+\n+\"\"\"Dictionary holding all the variables and their units, has to be updated\n+manually if new variables are added. Variables with a * meaning both parts have\n+to be substrings of the normal name. Access functions take care of placing\n+necessary tex wrappings around it\"\"\"\n+v_dict = {\n+    'P': ('$p$', 'MeV'),\n+    'ETA': ('$#eta$', ''),\n+    'PT': ('$p_T$', 'MeV'),\n+    'Y': ('$y$', ''),\n+    'E': ('$E$', ''),\n+    'TRUE_P': ('$p$', 'MeV'),\n+    'Lead*PT': ('Lead. $p_{T}$', 'MeV'),\n+    'SecLead*PT': ('2$^#text{nd}$ Lead. $p_{T}$', 'MeV'),\n+    'ThirdLead*PT': ('3$^#text{rd}$ Lead. $p_{T}$', 'MeV'),\n+    'DIRA': ('DIRA', ''),\n+    'Loki': ('$#cos(#theta_{#pi})$', ''),","path":"analysis/charmproduction/prettyvar.py","position":68,"original_position":68,"commit_id":"e542d6a8c483b21e37aba6e90d61d5b31e34faf5","original_commit_id":"e542d6a8c483b21e37aba6e90d61d5b31e34faf5","user":{"login":"dominikmuller","id":9555975,"avatar_url":"https://avatars.githubusercontent.com/u/9555975?v=3","gravatar_id":"","url":"https://api.github.com/users/dominikmuller","html_url":"https://github.com/dominikmuller","followers_url":"https://api.github.com/users/dominikmuller/followers","following_url":"https://api.github.com/users/dominikmuller/following{/other_user}","gists_url":"https://api.github.com/users/dominikmuller/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikmuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikmuller/subscriptions","organizations_url":"https://api.github.com/users/dominikmuller/orgs","repos_url":"https://api.github.com/users/dominikmuller/repos","events_url":"https://api.github.com/users/dominikmuller/events{/privacy}","received_events_url":"https://api.github.com/users/dominikmuller/received_events","type":"User","site_admin":false},"body":"Yes it should. My mistake. Thanks!.  Forgot to add that the actual content of the dict is no final.","created_at":"2015-02-06T16:44:28Z","updated_at":"2015-02-06T16:44:28Z","html_url":"https://github.com/alexpearce/CharmProduction/pull/64#discussion_r24253095","pull_request_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/comments/24253095"},"html":{"href":"https://github.com/alexpearce/CharmProduction/pull/64#discussion_r24253095"},"pull_request":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64","id":28822067,"html_url":"https://github.com/alexpearce/CharmProduction/pull/64","diff_url":"https://github.com/alexpearce/CharmProduction/pull/64.diff","patch_url":"https://github.com/alexpearce/CharmProduction/pull/64.patch","issue_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/64","number":64,"state":"open","locked":false,"title":"Central dictionary for pretty variable names and units","user":{"login":"dominikmuller","id":9555975,"avatar_url":"https://avatars.githubusercontent.com/u/9555975?v=3","gravatar_id":"","url":"https://api.github.com/users/dominikmuller","html_url":"https://github.com/dominikmuller","followers_url":"https://api.github.com/users/dominikmuller/followers","following_url":"https://api.github.com/users/dominikmuller/following{/other_user}","gists_url":"https://api.github.com/users/dominikmuller/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikmuller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikmuller/subscriptions","organizations_url":"https://api.github.com/users/dominikmuller/orgs","repos_url":"https://api.github.com/users/dominikmuller/repos","events_url":"https://api.github.com/users/dominikmuller/events{/privacy}","received_events_url":"https://api.github.com/users/dominikmuller/received_events","type":"User","site_admin":false},"body":"Based on Chris' suggestion I did a first implementation for a central pretty names dictionary. It uses a dict mapping the actual names to the pretty name and unit:\r\n\r\n```\r\n'ThirdLead*PT': ('3$^#text{rd}$ Lead. $p_{T}$', 'MeV')\r\n```\r\n\r\nBoth the unit and the variable should be formatted the way you would usually do it in LaTeX without the need to place decorating stuff  to trick ROOT tex output. The only exception is the need to use `#` instead of `\\` for LaTeX commands.\r\nThere are for different functions to access the pretty names depending on what's needed. Each provided actual name is compared to all keys in the dict by determining which keys are substrings of the provided actual name. Of those, the longest matching substring is chosen to determine the pretty name.\r\nKeys including `*` are split and all resulting strings have to be a substring of the actual name.\r\n\r\nSee below for the changes I did to the BDT wrapper functions and the DpToKpipi mode. If both of you are happy I am going to modify all other modes and add their variables to the dict.\r\n","created_at":"2015-02-06T16:37:40Z","updated_at":"2015-02-06T16:44:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ceed2a31a872a73618c473bbebe4b6f14acc9bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64/commits","review_comments_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64/comments","review_comment_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/comments/{number}","comments_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/64/comments","statuses_url":"https://api.github.com/repos/alexpearce/CharmProduction/statuses/e542d6a8c483b21e37aba6e90d61d5b31e34faf5","head":{"label":"alexpearce:PrettyDict","ref":"PrettyDict","sha":"e542d6a8c483b21e37aba6e90d61d5b31e34faf5","user":{"login":"alexpearce","id":540853,"avatar_url":"https://avatars.githubusercontent.com/u/540853?v=3","gravatar_id":"","url":"https://api.github.com/users/alexpearce","html_url":"https://github.com/alexpearce","followers_url":"https://api.github.com/users/alexpearce/followers","following_url":"https://api.github.com/users/alexpearce/following{/other_user}","gists_url":"https://api.github.com/users/alexpearce/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpearce/subscriptions","organizations_url":"https://api.github.com/users/alexpearce/orgs","repos_url":"https://api.github.com/users/alexpearce/repos","events_url":"https://api.github.com/users/alexpearce/events{/privacy}","received_events_url":"https://api.github.com/users/alexpearce/received_events","type":"User","site_admin":false},"repo":{"id":22913076,"name":"CharmProduction","full_name":"alexpearce/CharmProduction","owner":{"login":"alexpearce","id":540853,"avatar_url":"https://avatars.githubusercontent.com/u/540853?v=3","gravatar_id":"","url":"https://api.github.com/users/alexpearce","html_url":"https://github.com/alexpearce","followers_url":"https://api.github.com/users/alexpearce/followers","following_url":"https://api.github.com/users/alexpearce/following{/other_user}","gists_url":"https://api.github.com/users/alexpearce/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpearce/subscriptions","organizations_url":"https://api.github.com/users/alexpearce/orgs","repos_url":"https://api.github.com/users/alexpearce/repos","events_url":"https://api.github.com/users/alexpearce/events{/privacy}","received_events_url":"https://api.github.com/users/alexpearce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexpearce/CharmProduction","description":"Prompt charm cross section analysis code.","fork":false,"url":"https://api.github.com/repos/alexpearce/CharmProduction","forks_url":"https://api.github.com/repos/alexpearce/CharmProduction/forks","keys_url":"https://api.github.com/repos/alexpearce/CharmProduction/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexpearce/CharmProduction/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexpearce/CharmProduction/teams","hooks_url":"https://api.github.com/repos/alexpearce/CharmProduction/hooks","issue_events_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/events{/number}","events_url":"https://api.github.com/repos/alexpearce/CharmProduction/events","assignees_url":"https://api.github.com/repos/alexpearce/CharmProduction/assignees{/user}","branches_url":"https://api.github.com/repos/alexpearce/CharmProduction/branches{/branch}","tags_url":"https://api.github.com/repos/alexpearce/CharmProduction/tags","blobs_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexpearce/CharmProduction/statuses/{sha}","languages_url":"https://api.github.com/repos/alexpearce/CharmProduction/languages","stargazers_url":"https://api.github.com/repos/alexpearce/CharmProduction/stargazers","contributors_url":"https://api.github.com/repos/alexpearce/CharmProduction/contributors","subscribers_url":"https://api.github.com/repos/alexpearce/CharmProduction/subscribers","subscription_url":"https://api.github.com/repos/alexpearce/CharmProduction/subscription","commits_url":"https://api.github.com/repos/alexpearce/CharmProduction/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexpearce/CharmProduction/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/comments/{number}","contents_url":"https://api.github.com/repos/alexpearce/CharmProduction/contents/{+path}","compare_url":"https://api.github.com/repos/alexpearce/CharmProduction/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexpearce/CharmProduction/merges","archive_url":"https://api.github.com/repos/alexpearce/CharmProduction/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexpearce/CharmProduction/downloads","issues_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues{/number}","pulls_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls{/number}","milestones_url":"https://api.github.com/repos/alexpearce/CharmProduction/milestones{/number}","notifications_url":"https://api.github.com/repos/alexpearce/CharmProduction/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexpearce/CharmProduction/labels{/name}","releases_url":"https://api.github.com/repos/alexpearce/CharmProduction/releases{/id}","created_at":"2014-08-13T11:19:55Z","updated_at":"2015-02-06T15:05:59Z","pushed_at":"2015-02-06T16:39:21Z","git_url":"git://github.com/alexpearce/CharmProduction.git","ssh_url":"git@github.com:alexpearce/CharmProduction.git","clone_url":"https://github.com/alexpearce/CharmProduction.git","svn_url":"https://github.com/alexpearce/CharmProduction","homepage":"","size":5667,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":2,"default_branch":"master"}},"base":{"label":"alexpearce:master","ref":"master","sha":"185e8a0275990a9693d62b61d6c7059cceb58de9","user":{"login":"alexpearce","id":540853,"avatar_url":"https://avatars.githubusercontent.com/u/540853?v=3","gravatar_id":"","url":"https://api.github.com/users/alexpearce","html_url":"https://github.com/alexpearce","followers_url":"https://api.github.com/users/alexpearce/followers","following_url":"https://api.github.com/users/alexpearce/following{/other_user}","gists_url":"https://api.github.com/users/alexpearce/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpearce/subscriptions","organizations_url":"https://api.github.com/users/alexpearce/orgs","repos_url":"https://api.github.com/users/alexpearce/repos","events_url":"https://api.github.com/users/alexpearce/events{/privacy}","received_events_url":"https://api.github.com/users/alexpearce/received_events","type":"User","site_admin":false},"repo":{"id":22913076,"name":"CharmProduction","full_name":"alexpearce/CharmProduction","owner":{"login":"alexpearce","id":540853,"avatar_url":"https://avatars.githubusercontent.com/u/540853?v=3","gravatar_id":"","url":"https://api.github.com/users/alexpearce","html_url":"https://github.com/alexpearce","followers_url":"https://api.github.com/users/alexpearce/followers","following_url":"https://api.github.com/users/alexpearce/following{/other_user}","gists_url":"https://api.github.com/users/alexpearce/gists{/gist_id}","starred_url":"https://api.github.com/users/alexpearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexpearce/subscriptions","organizations_url":"https://api.github.com/users/alexpearce/orgs","repos_url":"https://api.github.com/users/alexpearce/repos","events_url":"https://api.github.com/users/alexpearce/events{/privacy}","received_events_url":"https://api.github.com/users/alexpearce/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexpearce/CharmProduction","description":"Prompt charm cross section analysis code.","fork":false,"url":"https://api.github.com/repos/alexpearce/CharmProduction","forks_url":"https://api.github.com/repos/alexpearce/CharmProduction/forks","keys_url":"https://api.github.com/repos/alexpearce/CharmProduction/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexpearce/CharmProduction/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexpearce/CharmProduction/teams","hooks_url":"https://api.github.com/repos/alexpearce/CharmProduction/hooks","issue_events_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/events{/number}","events_url":"https://api.github.com/repos/alexpearce/CharmProduction/events","assignees_url":"https://api.github.com/repos/alexpearce/CharmProduction/assignees{/user}","branches_url":"https://api.github.com/repos/alexpearce/CharmProduction/branches{/branch}","tags_url":"https://api.github.com/repos/alexpearce/CharmProduction/tags","blobs_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexpearce/CharmProduction/statuses/{sha}","languages_url":"https://api.github.com/repos/alexpearce/CharmProduction/languages","stargazers_url":"https://api.github.com/repos/alexpearce/CharmProduction/stargazers","contributors_url":"https://api.github.com/repos/alexpearce/CharmProduction/contributors","subscribers_url":"https://api.github.com/repos/alexpearce/CharmProduction/subscribers","subscription_url":"https://api.github.com/repos/alexpearce/CharmProduction/subscription","commits_url":"https://api.github.com/repos/alexpearce/CharmProduction/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexpearce/CharmProduction/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexpearce/CharmProduction/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues/comments/{number}","contents_url":"https://api.github.com/repos/alexpearce/CharmProduction/contents/{+path}","compare_url":"https://api.github.com/repos/alexpearce/CharmProduction/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexpearce/CharmProduction/merges","archive_url":"https://api.github.com/repos/alexpearce/CharmProduction/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexpearce/CharmProduction/downloads","issues_url":"https://api.github.com/repos/alexpearce/CharmProduction/issues{/number}","pulls_url":"https://api.github.com/repos/alexpearce/CharmProduction/pulls{/number}","milestones_url":"https://api.github.com/repos/alexpearce/CharmProduction/milestones{/number}","notifications_url":"https://api.github.com/repos/alexpearce/CharmProduction/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexpearce/CharmProduction/labels{/name}","releases_url":"https://api.github.com/repos/alexpearce/CharmProduction/releases{/id}","created_at":"2014-08-13T11:19:55Z","updated_at":"2015-02-06T15:05:59Z","pushed_at":"2015-02-06T16:39:21Z","git_url":"git://github.com/alexpearce/CharmProduction.git","ssh_url":"git@github.com:alexpearce/CharmProduction.git","clone_url":"https://github.com/alexpearce/CharmProduction.git","svn_url":"https://github.com/alexpearce/CharmProduction","homepage":"","size":5667,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64"},"html":{"href":"https://github.com/alexpearce/CharmProduction/pull/64"},"issue":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/issues/64"},"comments":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/alexpearce/CharmProduction/statuses/e542d6a8c483b21e37aba6e90d61d5b31e34faf5"}}}}