{"action":"created","comment":{"url":"https://api.github.com/repos/gem/oq-risklib/pulls/comments/48234691","id":48234691,"diff_hunk":"@@ -151,43 +155,43 @@ def classical(sources, sitecol, rlzs_assoc, monitor):\n     truncation_level = monitor.oqparam.truncation_level\n     imtls = monitor.oqparam.imtls\n     trt_model_id = sources[0].trt_model_id\n+    # sanity check: the trt_model must be the same for all sources\n+    for src in sources[1:]:\n+        assert src.trt_model_id == trt_model_id\n     gsims = rlzs_assoc.gsims_by_trt_id[trt_model_id]\n-    for smodel in rlzs_assoc.csm_info.source_models:\n-        for trt_model in smodel.trt_models:\n-            if trt_model.id == trt_model_id:\n-                sm_id = smodel.ordinal\n-                break\n \n+    dic = AccumDict()\n+    dic.siteslice = slice(siteidx, siteidx + len(sitecol))\n     if monitor.oqparam.poes_disagg:\n-        bbs = [BoundingBox(sm_id, sid) for sid in sitecol.sids]\n+        sm_id = rlzs_assoc.get_sm_id(trt_model_id)\n+        dic.bbs = [BoundingBox(sm_id, sid) for sid in sitecol.sids]\n     else:\n-        bbs = []\n+        dic.bbs = []\n     # NB: the source_site_filter below is ESSENTIAL for performance inside\n     # hazard_curves_per_trt, since it reduces the full site collection\n     # to a filtered one *before* doing the rupture filtering\n     curves_by_gsim = hazard_curves_per_trt(\n         sources, sitecol, imtls, gsims, truncation_level,\n         source_site_filter=source_site_distance_filter(max_dist),\n-        maximum_distance=max_dist, bbs=bbs, monitor=monitor)\n-    dic = dict(calc_times=monitor.calc_times, bbs=bbs)\n+        maximum_distance=max_dist, bbs=dic.bbs, monitor=monitor)\n+    dic.calc_times = monitor.calc_times  # added by hazard_curves_per_trt\n     for gsim, curves in zip(gsims, curves_by_gsim):\n         dic[trt_model_id, str(gsim)] = curves\n     return dic\n \n \n-def agg_dicts(acc, val):\n+def expand(array, n, aslice):\n     \"\"\"\n-    Aggregate dictionaries of hazard curves by updating the accumulator\n+    Expand a short array to size n by adding zeros outside of the slice","path":"openquake/calculators/classical.py","position":98,"original_position":98,"commit_id":"b8d3b26f3ff8619459c941f1970b6629c9c3e0ba","original_commit_id":"b8d3b26f3ff8619459c941f1970b6629c9c3e0ba","user":{"login":"ptormene","id":350930,"avatar_url":"https://avatars.githubusercontent.com/u/350930?v=3","gravatar_id":"","url":"https://api.github.com/users/ptormene","html_url":"https://github.com/ptormene","followers_url":"https://api.github.com/users/ptormene/followers","following_url":"https://api.github.com/users/ptormene/following{/other_user}","gists_url":"https://api.github.com/users/ptormene/gists{/gist_id}","starred_url":"https://api.github.com/users/ptormene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptormene/subscriptions","organizations_url":"https://api.github.com/users/ptormene/orgs","repos_url":"https://api.github.com/users/ptormene/repos","events_url":"https://api.github.com/users/ptormene/events{/privacy}","received_events_url":"https://api.github.com/users/ptormene/received_events","type":"User","site_admin":false},"body":"A simple example would make this more intuitive","created_at":"2015-12-22T09:18:08Z","updated_at":"2015-12-22T09:18:08Z","html_url":"https://github.com/gem/oq-risklib/pull/601#discussion_r48234691","pull_request_url":"https://api.github.com/repos/gem/oq-risklib/pulls/601","_links":{"self":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/comments/48234691"},"html":{"href":"https://github.com/gem/oq-risklib/pull/601#discussion_r48234691"},"pull_request":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/601"}}},"pull_request":{"url":"https://api.github.com/repos/gem/oq-risklib/pulls/601","id":54231796,"html_url":"https://github.com/gem/oq-risklib/pull/601","diff_url":"https://github.com/gem/oq-risklib/pull/601.diff","patch_url":"https://github.com/gem/oq-risklib/pull/601.patch","issue_url":"https://api.github.com/repos/gem/oq-risklib/issues/601","number":601,"state":"open","locked":false,"title":"Refactored the classical tiling calculator","user":{"login":"micheles","id":2463856,"avatar_url":"https://avatars.githubusercontent.com/u/2463856?v=3","gravatar_id":"","url":"https://api.github.com/users/micheles","html_url":"https://github.com/micheles","followers_url":"https://api.github.com/users/micheles/followers","following_url":"https://api.github.com/users/micheles/following{/other_user}","gists_url":"https://api.github.com/users/micheles/gists{/gist_id}","starred_url":"https://api.github.com/users/micheles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheles/subscriptions","organizations_url":"https://api.github.com/users/micheles/orgs","repos_url":"https://api.github.com/users/micheles/repos","events_url":"https://api.github.com/users/micheles/events{/privacy}","received_events_url":"https://api.github.com/users/micheles/received_events","type":"User","site_admin":false},"body":"This is more efficient than before, it logs correctly on the controller node and it does not instantiate GSIMs on the worker nodes. This requires https://github.com/gem/oq-hazardlib/pull/406. The tests are green: https://ci.openquake.org/job/zdevel_oq-risklib/1269","created_at":"2015-12-21T08:37:43Z","updated_at":"2015-12-22T09:18:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"456da25be4e6565c7faf7781555aea60b0fe0266","assignee":{"login":"ptormene","id":350930,"avatar_url":"https://avatars.githubusercontent.com/u/350930?v=3","gravatar_id":"","url":"https://api.github.com/users/ptormene","html_url":"https://github.com/ptormene","followers_url":"https://api.github.com/users/ptormene/followers","following_url":"https://api.github.com/users/ptormene/following{/other_user}","gists_url":"https://api.github.com/users/ptormene/gists{/gist_id}","starred_url":"https://api.github.com/users/ptormene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptormene/subscriptions","organizations_url":"https://api.github.com/users/ptormene/orgs","repos_url":"https://api.github.com/users/ptormene/repos","events_url":"https://api.github.com/users/ptormene/events{/privacy}","received_events_url":"https://api.github.com/users/ptormene/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/gem/oq-risklib/milestones/4","html_url":"https://github.com/gem/oq-risklib/milestones/Engine%201.8.0","labels_url":"https://api.github.com/repos/gem/oq-risklib/milestones/4/labels","id":1458641,"number":4,"title":"Engine 1.8.0","description":"","creator":{"login":"micheles","id":2463856,"avatar_url":"https://avatars.githubusercontent.com/u/2463856?v=3","gravatar_id":"","url":"https://api.github.com/users/micheles","html_url":"https://github.com/micheles","followers_url":"https://api.github.com/users/micheles/followers","following_url":"https://api.github.com/users/micheles/following{/other_user}","gists_url":"https://api.github.com/users/micheles/gists{/gist_id}","starred_url":"https://api.github.com/users/micheles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micheles/subscriptions","organizations_url":"https://api.github.com/users/micheles/orgs","repos_url":"https://api.github.com/users/micheles/repos","events_url":"https://api.github.com/users/micheles/events{/privacy}","received_events_url":"https://api.github.com/users/micheles/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":20,"state":"open","created_at":"2015-12-14T08:46:15Z","updated_at":"2015-12-22T09:00:19Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/gem/oq-risklib/pulls/601/commits","review_comments_url":"https://api.github.com/repos/gem/oq-risklib/pulls/601/comments","review_comment_url":"https://api.github.com/repos/gem/oq-risklib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gem/oq-risklib/issues/601/comments","statuses_url":"https://api.github.com/repos/gem/oq-risklib/statuses/b8d3b26f3ff8619459c941f1970b6629c9c3e0ba","head":{"label":"gem:classical_tiling","ref":"classical_tiling","sha":"b8d3b26f3ff8619459c941f1970b6629c9c3e0ba","user":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"repo":{"id":5856509,"name":"oq-risklib","full_name":"gem/oq-risklib","owner":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gem/oq-risklib","description":"OpenQuake Risk Library","fork":false,"url":"https://api.github.com/repos/gem/oq-risklib","forks_url":"https://api.github.com/repos/gem/oq-risklib/forks","keys_url":"https://api.github.com/repos/gem/oq-risklib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gem/oq-risklib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gem/oq-risklib/teams","hooks_url":"https://api.github.com/repos/gem/oq-risklib/hooks","issue_events_url":"https://api.github.com/repos/gem/oq-risklib/issues/events{/number}","events_url":"https://api.github.com/repos/gem/oq-risklib/events","assignees_url":"https://api.github.com/repos/gem/oq-risklib/assignees{/user}","branches_url":"https://api.github.com/repos/gem/oq-risklib/branches{/branch}","tags_url":"https://api.github.com/repos/gem/oq-risklib/tags","blobs_url":"https://api.github.com/repos/gem/oq-risklib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gem/oq-risklib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gem/oq-risklib/git/refs{/sha}","trees_url":"https://api.github.com/repos/gem/oq-risklib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gem/oq-risklib/statuses/{sha}","languages_url":"https://api.github.com/repos/gem/oq-risklib/languages","stargazers_url":"https://api.github.com/repos/gem/oq-risklib/stargazers","contributors_url":"https://api.github.com/repos/gem/oq-risklib/contributors","subscribers_url":"https://api.github.com/repos/gem/oq-risklib/subscribers","subscription_url":"https://api.github.com/repos/gem/oq-risklib/subscription","commits_url":"https://api.github.com/repos/gem/oq-risklib/commits{/sha}","git_commits_url":"https://api.github.com/repos/gem/oq-risklib/git/commits{/sha}","comments_url":"https://api.github.com/repos/gem/oq-risklib/comments{/number}","issue_comment_url":"https://api.github.com/repos/gem/oq-risklib/issues/comments{/number}","contents_url":"https://api.github.com/repos/gem/oq-risklib/contents/{+path}","compare_url":"https://api.github.com/repos/gem/oq-risklib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gem/oq-risklib/merges","archive_url":"https://api.github.com/repos/gem/oq-risklib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gem/oq-risklib/downloads","issues_url":"https://api.github.com/repos/gem/oq-risklib/issues{/number}","pulls_url":"https://api.github.com/repos/gem/oq-risklib/pulls{/number}","milestones_url":"https://api.github.com/repos/gem/oq-risklib/milestones{/number}","notifications_url":"https://api.github.com/repos/gem/oq-risklib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gem/oq-risklib/labels{/name}","releases_url":"https://api.github.com/repos/gem/oq-risklib/releases{/id}","created_at":"2012-09-18T13:07:14Z","updated_at":"2015-11-05T16:05:21Z","pushed_at":"2015-12-22T05:32:10Z","git_url":"git://github.com/gem/oq-risklib.git","ssh_url":"git@github.com:gem/oq-risklib.git","clone_url":"https://github.com/gem/oq-risklib.git","svn_url":"https://github.com/gem/oq-risklib","homepage":"http://www.globalquakemodel.org/openquake/","size":29294,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":32,"forks":15,"open_issues":32,"watchers":10,"default_branch":"master"}},"base":{"label":"gem:master","ref":"master","sha":"c8687b27e7f09a8436595cd9bce062f83ed3b526","user":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"repo":{"id":5856509,"name":"oq-risklib","full_name":"gem/oq-risklib","owner":{"login":"gem","id":316546,"avatar_url":"https://avatars.githubusercontent.com/u/316546?v=3","gravatar_id":"","url":"https://api.github.com/users/gem","html_url":"https://github.com/gem","followers_url":"https://api.github.com/users/gem/followers","following_url":"https://api.github.com/users/gem/following{/other_user}","gists_url":"https://api.github.com/users/gem/gists{/gist_id}","starred_url":"https://api.github.com/users/gem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gem/subscriptions","organizations_url":"https://api.github.com/users/gem/orgs","repos_url":"https://api.github.com/users/gem/repos","events_url":"https://api.github.com/users/gem/events{/privacy}","received_events_url":"https://api.github.com/users/gem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gem/oq-risklib","description":"OpenQuake Risk Library","fork":false,"url":"https://api.github.com/repos/gem/oq-risklib","forks_url":"https://api.github.com/repos/gem/oq-risklib/forks","keys_url":"https://api.github.com/repos/gem/oq-risklib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gem/oq-risklib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gem/oq-risklib/teams","hooks_url":"https://api.github.com/repos/gem/oq-risklib/hooks","issue_events_url":"https://api.github.com/repos/gem/oq-risklib/issues/events{/number}","events_url":"https://api.github.com/repos/gem/oq-risklib/events","assignees_url":"https://api.github.com/repos/gem/oq-risklib/assignees{/user}","branches_url":"https://api.github.com/repos/gem/oq-risklib/branches{/branch}","tags_url":"https://api.github.com/repos/gem/oq-risklib/tags","blobs_url":"https://api.github.com/repos/gem/oq-risklib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gem/oq-risklib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gem/oq-risklib/git/refs{/sha}","trees_url":"https://api.github.com/repos/gem/oq-risklib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gem/oq-risklib/statuses/{sha}","languages_url":"https://api.github.com/repos/gem/oq-risklib/languages","stargazers_url":"https://api.github.com/repos/gem/oq-risklib/stargazers","contributors_url":"https://api.github.com/repos/gem/oq-risklib/contributors","subscribers_url":"https://api.github.com/repos/gem/oq-risklib/subscribers","subscription_url":"https://api.github.com/repos/gem/oq-risklib/subscription","commits_url":"https://api.github.com/repos/gem/oq-risklib/commits{/sha}","git_commits_url":"https://api.github.com/repos/gem/oq-risklib/git/commits{/sha}","comments_url":"https://api.github.com/repos/gem/oq-risklib/comments{/number}","issue_comment_url":"https://api.github.com/repos/gem/oq-risklib/issues/comments{/number}","contents_url":"https://api.github.com/repos/gem/oq-risklib/contents/{+path}","compare_url":"https://api.github.com/repos/gem/oq-risklib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gem/oq-risklib/merges","archive_url":"https://api.github.com/repos/gem/oq-risklib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gem/oq-risklib/downloads","issues_url":"https://api.github.com/repos/gem/oq-risklib/issues{/number}","pulls_url":"https://api.github.com/repos/gem/oq-risklib/pulls{/number}","milestones_url":"https://api.github.com/repos/gem/oq-risklib/milestones{/number}","notifications_url":"https://api.github.com/repos/gem/oq-risklib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gem/oq-risklib/labels{/name}","releases_url":"https://api.github.com/repos/gem/oq-risklib/releases{/id}","created_at":"2012-09-18T13:07:14Z","updated_at":"2015-11-05T16:05:21Z","pushed_at":"2015-12-22T05:32:10Z","git_url":"git://github.com/gem/oq-risklib.git","ssh_url":"git@github.com:gem/oq-risklib.git","clone_url":"https://github.com/gem/oq-risklib.git","svn_url":"https://github.com/gem/oq-risklib","homepage":"http://www.globalquakemodel.org/openquake/","size":29294,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":32,"forks":15,"open_issues":32,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/601"},"html":{"href":"https://github.com/gem/oq-risklib/pull/601"},"issue":{"href":"https://api.github.com/repos/gem/oq-risklib/issues/601"},"comments":{"href":"https://api.github.com/repos/gem/oq-risklib/issues/601/comments"},"review_comments":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/601/comments"},"review_comment":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gem/oq-risklib/pulls/601/commits"},"statuses":{"href":"https://api.github.com/repos/gem/oq-risklib/statuses/b8d3b26f3ff8619459c941f1970b6629c9c3e0ba"}}}}