{"action":"created","comment":{"url":"https://api.github.com/repos/gammapy/gammapy/pulls/comments/47443296","id":47443296,"diff_hunk":"@@ -133,23 +140,70 @@ def _configure_root_logger(level='info', format=None):\n \n \n def read_yaml(filename, logger=None):\n-    \"\"\"Read config from YAML file.\"\"\"\n+    \"\"\"\n+    Read config from YAML file \n+    \"\"\"\n     import yaml\n     if logger is not None:\n         logger.info('Reading {}'.format(filename))\n     with open(filename) as fh:\n         config = yaml.safe_load(fh)\n+\n     return config\n \n \n def write_yaml(config, filename, logger=None):\n-    \"\"\"Write YAML config file\n+    \"\"\"\n+    Write YAML config file\n \n     This function can be used by scripts that alter the users config file.\n+\n+    Parameters\n+    ----------\n+    config : dict\n+        config to write\n+    filename : str, `~gammapy.exter.pathlib.Path`\n+        file to write\n     \"\"\"\n     import yaml\n-    filename = filename + '.yaml'\n+    filename = make_path(filename)\n     if logger is not None:\n         logger.info('Writing {}'.format(filename))\n-    with open(filename, 'w') as outfile:\n+    with open(str(filename), 'w') as outfile:\n         outfile.write(yaml.dump(config, default_flow_style=False))\n+\n+\n+def make_path(path):\n+    \"\"\"\n+    Expand environment varibles on `~pathlib.Path` construction\n+\n+    Parameters\n+    ----------\n+    path : str, `~gammapy.extern.pathlib.Path`\n+        path to expand\n+    \"\"\"\n+    return Path(expandvars(str(path)))\n+\n+\n+def recursive_update_dict(old, new):\n+    \"\"\"Recursively update a dict with new values\n+\n+    The built-in update function cannot be used for hierarchical dicts\n+    where only a subset of keys shall be updated.\n+    see: http://stackoverflow.com/questions/3232943/update-value-of-a-nested-dictionary-of-varying-depth\n+\n+    Parameters\n+    ----------\n+    old : dict\n+        dict to be changed\n+    new : dict\n+        dict containing changes\n+    \"\"\"\n+\n+    result = old.copy()\n+    for k, v in new.iteritems():\n+        if k in result and isinstance(result[k], dict):\n+            result[k] = recursive_update(result[k], v)","path":"gammapy/utils/scripts.py","position":100,"original_position":100,"commit_id":"b224792908ddf66518a26edcb6ddafbe40b97728","original_commit_id":"b224792908ddf66518a26edcb6ddafbe40b97728","user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"body":"This is a bug ... it should be `recursive_update_dict`, not `recursive_update`.\r\n","created_at":"2015-12-13T11:36:37Z","updated_at":"2015-12-13T11:36:37Z","html_url":"https://github.com/gammapy/gammapy/pull/396#discussion_r47443296","pull_request_url":"https://api.github.com/repos/gammapy/gammapy/pulls/396","_links":{"self":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/comments/47443296"},"html":{"href":"https://github.com/gammapy/gammapy/pull/396#discussion_r47443296"},"pull_request":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/396"}}},"pull_request":{"url":"https://api.github.com/repos/gammapy/gammapy/pulls/396","id":52866128,"html_url":"https://github.com/gammapy/gammapy/pull/396","diff_url":"https://github.com/gammapy/gammapy/pull/396.diff","patch_url":"https://github.com/gammapy/gammapy/pull/396.patch","issue_url":"https://api.github.com/repos/gammapy/gammapy/issues/396","number":396,"state":"closed","locked":false,"title":"Rewrite spectrum analysis","user":{"login":"joleroi","id":11678435,"avatar_url":"https://avatars.githubusercontent.com/u/11678435?v=3","gravatar_id":"","url":"https://api.github.com/users/joleroi","html_url":"https://github.com/joleroi","followers_url":"https://api.github.com/users/joleroi/followers","following_url":"https://api.github.com/users/joleroi/following{/other_user}","gists_url":"https://api.github.com/users/joleroi/gists{/gist_id}","starred_url":"https://api.github.com/users/joleroi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joleroi/subscriptions","organizations_url":"https://api.github.com/users/joleroi/orgs","repos_url":"https://api.github.com/users/joleroi/repos","events_url":"https://api.github.com/users/joleroi/events{/privacy}","received_events_url":"https://api.github.com/users/joleroi/received_events","type":"User","site_admin":false},"body":"This PR (hopefully) brings the Spectrum Analysis to a state where other people can use it.\r\n\r\n* [x] Option to use plain sherpa instead of hspec\r\n* [x] Split out fitting into separate class\r\n* [x] Document\r\n* [x] Add tests","created_at":"2015-12-07T16:24:43Z","updated_at":"2015-12-13T11:36:37Z","closed_at":"2015-12-11T12:34:34Z","merged_at":"2015-12-11T12:34:34Z","merge_commit_sha":"5aa9b59ce49ff64203aea65a19fed362dd3a4e44","assignee":{"login":"joleroi","id":11678435,"avatar_url":"https://avatars.githubusercontent.com/u/11678435?v=3","gravatar_id":"","url":"https://api.github.com/users/joleroi","html_url":"https://github.com/joleroi","followers_url":"https://api.github.com/users/joleroi/followers","following_url":"https://api.github.com/users/joleroi/following{/other_user}","gists_url":"https://api.github.com/users/joleroi/gists{/gist_id}","starred_url":"https://api.github.com/users/joleroi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joleroi/subscriptions","organizations_url":"https://api.github.com/users/joleroi/orgs","repos_url":"https://api.github.com/users/joleroi/repos","events_url":"https://api.github.com/users/joleroi/events{/privacy}","received_events_url":"https://api.github.com/users/joleroi/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/gammapy/gammapy/milestones/7","html_url":"https://github.com/gammapy/gammapy/milestones/0.5","labels_url":"https://api.github.com/repos/gammapy/gammapy/milestones/7/labels","id":1275561,"number":7,"title":"0.5","description":"","creator":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"open_issues":45,"closed_issues":2,"state":"open","created_at":"2015-08-27T09:29:48Z","updated_at":"2015-12-12T14:05:59Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/gammapy/gammapy/pulls/396/commits","review_comments_url":"https://api.github.com/repos/gammapy/gammapy/pulls/396/comments","review_comment_url":"https://api.github.com/repos/gammapy/gammapy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gammapy/gammapy/issues/396/comments","statuses_url":"https://api.github.com/repos/gammapy/gammapy/statuses/b224792908ddf66518a26edcb6ddafbe40b97728","head":{"label":"joleroi:spectrum_analysis","ref":"spectrum_analysis","sha":"b224792908ddf66518a26edcb6ddafbe40b97728","user":{"login":"joleroi","id":11678435,"avatar_url":"https://avatars.githubusercontent.com/u/11678435?v=3","gravatar_id":"","url":"https://api.github.com/users/joleroi","html_url":"https://github.com/joleroi","followers_url":"https://api.github.com/users/joleroi/followers","following_url":"https://api.github.com/users/joleroi/following{/other_user}","gists_url":"https://api.github.com/users/joleroi/gists{/gist_id}","starred_url":"https://api.github.com/users/joleroi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joleroi/subscriptions","organizations_url":"https://api.github.com/users/joleroi/orgs","repos_url":"https://api.github.com/users/joleroi/repos","events_url":"https://api.github.com/users/joleroi/events{/privacy}","received_events_url":"https://api.github.com/users/joleroi/received_events","type":"User","site_admin":false},"repo":{"id":34865384,"name":"gammapy","full_name":"joleroi/gammapy","owner":{"login":"joleroi","id":11678435,"avatar_url":"https://avatars.githubusercontent.com/u/11678435?v=3","gravatar_id":"","url":"https://api.github.com/users/joleroi","html_url":"https://github.com/joleroi","followers_url":"https://api.github.com/users/joleroi/followers","following_url":"https://api.github.com/users/joleroi/following{/other_user}","gists_url":"https://api.github.com/users/joleroi/gists{/gist_id}","starred_url":"https://api.github.com/users/joleroi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joleroi/subscriptions","organizations_url":"https://api.github.com/users/joleroi/orgs","repos_url":"https://api.github.com/users/joleroi/repos","events_url":"https://api.github.com/users/joleroi/events{/privacy}","received_events_url":"https://api.github.com/users/joleroi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joleroi/gammapy","description":"A Python package for gamma-ray astronomy","fork":true,"url":"https://api.github.com/repos/joleroi/gammapy","forks_url":"https://api.github.com/repos/joleroi/gammapy/forks","keys_url":"https://api.github.com/repos/joleroi/gammapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joleroi/gammapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joleroi/gammapy/teams","hooks_url":"https://api.github.com/repos/joleroi/gammapy/hooks","issue_events_url":"https://api.github.com/repos/joleroi/gammapy/issues/events{/number}","events_url":"https://api.github.com/repos/joleroi/gammapy/events","assignees_url":"https://api.github.com/repos/joleroi/gammapy/assignees{/user}","branches_url":"https://api.github.com/repos/joleroi/gammapy/branches{/branch}","tags_url":"https://api.github.com/repos/joleroi/gammapy/tags","blobs_url":"https://api.github.com/repos/joleroi/gammapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joleroi/gammapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joleroi/gammapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/joleroi/gammapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joleroi/gammapy/statuses/{sha}","languages_url":"https://api.github.com/repos/joleroi/gammapy/languages","stargazers_url":"https://api.github.com/repos/joleroi/gammapy/stargazers","contributors_url":"https://api.github.com/repos/joleroi/gammapy/contributors","subscribers_url":"https://api.github.com/repos/joleroi/gammapy/subscribers","subscription_url":"https://api.github.com/repos/joleroi/gammapy/subscription","commits_url":"https://api.github.com/repos/joleroi/gammapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/joleroi/gammapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/joleroi/gammapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/joleroi/gammapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/joleroi/gammapy/contents/{+path}","compare_url":"https://api.github.com/repos/joleroi/gammapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joleroi/gammapy/merges","archive_url":"https://api.github.com/repos/joleroi/gammapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joleroi/gammapy/downloads","issues_url":"https://api.github.com/repos/joleroi/gammapy/issues{/number}","pulls_url":"https://api.github.com/repos/joleroi/gammapy/pulls{/number}","milestones_url":"https://api.github.com/repos/joleroi/gammapy/milestones{/number}","notifications_url":"https://api.github.com/repos/joleroi/gammapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joleroi/gammapy/labels{/name}","releases_url":"https://api.github.com/repos/joleroi/gammapy/releases{/id}","created_at":"2015-04-30T16:42:10Z","updated_at":"2015-04-30T16:42:10Z","pushed_at":"2015-12-11T15:00:58Z","git_url":"git://github.com/joleroi/gammapy.git","ssh_url":"git@github.com:joleroi/gammapy.git","clone_url":"https://github.com/joleroi/gammapy.git","svn_url":"https://github.com/joleroi/gammapy","homepage":"https://gammapy.readthedocs.org/","size":4369,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gammapy:master","ref":"master","sha":"72e5951948b156af26b00ffbc2388c2586a141cc","user":{"login":"gammapy","id":852764,"avatar_url":"https://avatars.githubusercontent.com/u/852764?v=3","gravatar_id":"","url":"https://api.github.com/users/gammapy","html_url":"https://github.com/gammapy","followers_url":"https://api.github.com/users/gammapy/followers","following_url":"https://api.github.com/users/gammapy/following{/other_user}","gists_url":"https://api.github.com/users/gammapy/gists{/gist_id}","starred_url":"https://api.github.com/users/gammapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gammapy/subscriptions","organizations_url":"https://api.github.com/users/gammapy/orgs","repos_url":"https://api.github.com/users/gammapy/repos","events_url":"https://api.github.com/users/gammapy/events{/privacy}","received_events_url":"https://api.github.com/users/gammapy/received_events","type":"Organization","site_admin":false},"repo":{"id":10073640,"name":"gammapy","full_name":"gammapy/gammapy","owner":{"login":"gammapy","id":852764,"avatar_url":"https://avatars.githubusercontent.com/u/852764?v=3","gravatar_id":"","url":"https://api.github.com/users/gammapy","html_url":"https://github.com/gammapy","followers_url":"https://api.github.com/users/gammapy/followers","following_url":"https://api.github.com/users/gammapy/following{/other_user}","gists_url":"https://api.github.com/users/gammapy/gists{/gist_id}","starred_url":"https://api.github.com/users/gammapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gammapy/subscriptions","organizations_url":"https://api.github.com/users/gammapy/orgs","repos_url":"https://api.github.com/users/gammapy/repos","events_url":"https://api.github.com/users/gammapy/events{/privacy}","received_events_url":"https://api.github.com/users/gammapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gammapy/gammapy","description":"A Python package for gamma-ray astronomy","fork":false,"url":"https://api.github.com/repos/gammapy/gammapy","forks_url":"https://api.github.com/repos/gammapy/gammapy/forks","keys_url":"https://api.github.com/repos/gammapy/gammapy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gammapy/gammapy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gammapy/gammapy/teams","hooks_url":"https://api.github.com/repos/gammapy/gammapy/hooks","issue_events_url":"https://api.github.com/repos/gammapy/gammapy/issues/events{/number}","events_url":"https://api.github.com/repos/gammapy/gammapy/events","assignees_url":"https://api.github.com/repos/gammapy/gammapy/assignees{/user}","branches_url":"https://api.github.com/repos/gammapy/gammapy/branches{/branch}","tags_url":"https://api.github.com/repos/gammapy/gammapy/tags","blobs_url":"https://api.github.com/repos/gammapy/gammapy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gammapy/gammapy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gammapy/gammapy/git/refs{/sha}","trees_url":"https://api.github.com/repos/gammapy/gammapy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gammapy/gammapy/statuses/{sha}","languages_url":"https://api.github.com/repos/gammapy/gammapy/languages","stargazers_url":"https://api.github.com/repos/gammapy/gammapy/stargazers","contributors_url":"https://api.github.com/repos/gammapy/gammapy/contributors","subscribers_url":"https://api.github.com/repos/gammapy/gammapy/subscribers","subscription_url":"https://api.github.com/repos/gammapy/gammapy/subscription","commits_url":"https://api.github.com/repos/gammapy/gammapy/commits{/sha}","git_commits_url":"https://api.github.com/repos/gammapy/gammapy/git/commits{/sha}","comments_url":"https://api.github.com/repos/gammapy/gammapy/comments{/number}","issue_comment_url":"https://api.github.com/repos/gammapy/gammapy/issues/comments{/number}","contents_url":"https://api.github.com/repos/gammapy/gammapy/contents/{+path}","compare_url":"https://api.github.com/repos/gammapy/gammapy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gammapy/gammapy/merges","archive_url":"https://api.github.com/repos/gammapy/gammapy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gammapy/gammapy/downloads","issues_url":"https://api.github.com/repos/gammapy/gammapy/issues{/number}","pulls_url":"https://api.github.com/repos/gammapy/gammapy/pulls{/number}","milestones_url":"https://api.github.com/repos/gammapy/gammapy/milestones{/number}","notifications_url":"https://api.github.com/repos/gammapy/gammapy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gammapy/gammapy/labels{/name}","releases_url":"https://api.github.com/repos/gammapy/gammapy/releases{/id}","created_at":"2013-05-15T07:50:40Z","updated_at":"2015-10-07T23:38:31Z","pushed_at":"2015-12-12T17:30:09Z","git_url":"git://github.com/gammapy/gammapy.git","ssh_url":"git@github.com:gammapy/gammapy.git","clone_url":"https://github.com/gammapy/gammapy.git","svn_url":"https://github.com/gammapy/gammapy","homepage":"https://gammapy.readthedocs.org/","size":4961,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":126,"forks":28,"open_issues":126,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/396"},"html":{"href":"https://github.com/gammapy/gammapy/pull/396"},"issue":{"href":"https://api.github.com/repos/gammapy/gammapy/issues/396"},"comments":{"href":"https://api.github.com/repos/gammapy/gammapy/issues/396/comments"},"review_comments":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/396/comments"},"review_comment":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gammapy/gammapy/pulls/396/commits"},"statuses":{"href":"https://api.github.com/repos/gammapy/gammapy/statuses/b224792908ddf66518a26edcb6ddafbe40b97728"}}}}