GitHub PullRequestReviewCommentEvent at 2014-03-31 08:39:34
Repository: oq-engine
Actor: nastasi-oq
Payload: {"comment":{"url":"https://api.github.com/repos/gem/oq-engine/pulls/comments/11107332","id":11107332,"diff_hunk":"@@ -858,6 +859,58 @@ def sites_affected_by(self, src):\n                 self.maximum_distance, self.site_collection)\n         return self.site_collection\n \n+    def gen_ruptures(self, sources, monitor, site_coll=None):\n+        \"\"\"\n+        Yield (source, rupture, affected_sites) for each rupture\n+        generated by the given sources.\n+\n+        :param sources: a sequence of sources\n+        :param monitor: a Monitor object\n+        \"\"\"\n+        site_coll = site_coll or self.site_collection\n+        filtsources = monitor.copy('filtering sources')\n+        genruptures = monitor.copy('generating ruptures')\n+        filtruptures = monitor.copy('filtering ruptures')\n+        for src in sources:\n+            with filtsources:\n+                s_sites = src.filter_sites_by_distance_to_source(\n+                    self.maximum_distance, site_coll\n+                ) if self.maximum_distance else site_coll\n+                if s_sites is None:\n+                    continue\n+\n+            with genruptures:\n+                ruptures = list(src.iter_ruptures())\n+            if not ruptures:\n+                continue\n+\n+            for rupture in ruptures:\n+                with filtruptures:\n+                    r_sites = rupture.source_typology.\\\n+                        filter_sites_by_distance_to_rupture(\n+                            rupture, self.maximum_distance, s_sites\n+                        ) if self.maximum_distance else s_sites\n+                    if r_sites is None:\n+                        continue\n+                yield src, rupture, r_sites\n+        filtsources.flush()\n+        genruptures.flush()\n+        filtruptures.flush()\n+\n+    def gen_ruptures_for_site(self, site, sources, monitor):\n+        \"\"\"\n+        Yield source, <ruptures close to site>\n+\n+        :param site: a Site object\n+        :param sources: a sequence of sources\n+        :param monitor: a Monitor object\n+        \"\"\"\n+        source_rupture_sites = self.gen_ruptures(\n+            sources, monitor, SiteCollection([site]))\n+        for src, rows in itertools.groupby(\n+                source_rupture_sites, key=operator.itemgetter(0)):\n+            yield src, [row[1] for row in rows]\n+","path":"openquake/engine/db/models.py","position":63,"original_position":63,"commit_id":"902221ee96696597c202edec6ca0db5a32913a8a","original_commit_id":"902221ee96696597c202edec6ca0db5a32913a8a","user":{"login":"nastasi-oq","id":1670278,"avatar_url":"https://avatars.githubusercontent.com/u/1670278?","gravatar_id":"5085c12bc798ebde4a974768ab50e61a","url":"https://api.github.com/users/nastasi-oq","html_url":"https://github.com/nastasi-oq","followers_url":"https://api.github.com/users/nastasi-oq/followers","following_url":"https://api.github.com/users/nastasi-oq/following{/other_user}","gists_url":"https://api.github.com/users/nastasi-oq/gists{/gist_id}","starred_url":"https://api.github.com/users/nastasi-oq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nastasi-oq/subscriptions","organizations_url":"https://api.github.com/users/nastasi-oq/orgs","repos_url":"https://api.github.com/users/nastasi-oq/repos","events_url":"https://api.github.com/users/nastasi-oq/events{/privacy}","received_events_url":"https://api.github.com/users/nastasi-oq/received_events","type":"User","site_admin":false},"body":"Instead of use raw indexes we could use \"enum\" like approach or named tuples to be more clear.","created_at":"2014-03-31T08:39:34Z","updated_at":"2014-03-31T08:39:34Z","html_url":"https://github.com/gem/oq-engine/pull/1390#discussion_r11107332","pull_request_url":"https://api.github.com/repos/gem/oq-engine/pulls/1390","_links":{"self":{"href":"https://api.github.com/repos/gem/oq-engine/pulls/comments/11107332"},"html":{"href":"https://github.com/gem/oq-engine/pull/1390#discussion_r11107332"},"pull_request":{"href":"https://api.github.com/repos/gem/oq-engine/pulls/1390"}}}}