{"action":"created","comment":{"url":"https://api.github.com/repos/ihmeuw/cascade/pulls/comments/211059644","pull_request_review_id":147413831,"id":211059644,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTA1OTY0NA==","diff_hunk":"@@ -0,0 +1,178 @@\n+from functools import total_ordering\n+\n+\n+@total_ordering\n+class _Prior:\n+    \"\"\"The base for all Priors\n+    \"\"\"\n+\n+    density = None\n+\n+    def __init__(self, name=None):\n+        self.name = name\n+\n+    def _parameters(self):\n+        raise NotImplementedError()\n+\n+    def parameters(self):\n+        return dict(density=self.density, **self._parameters())\n+\n+    def __hash__(self):\n+        return hash((frozenset(self.parameters().items()), self.name))\n+\n+    def __eq__(self, other):\n+        return isinstance(other, _Prior) and self.name == other.name and self.parameters() == other.parameters()\n+\n+    def __lt__(self, other):\n+        if not isinstance(other, _Prior):\n+            return NotImplemented\n+        return list(dict(name=self.name, **self.parameters()).items()) < list(\n+            dict(name=other.name, **other.parameters()).items()\n+        )\n+\n+    def __repr__(self):\n+        return f\"<{type(self).__name__} {self.parameters()}>\"\n+\n+\n+def _validate_bounds(lower, mean, upper):\n+    if not lower <= mean <= upper:\n+        raise ValueError(\"Bounds are inconsistent\")\n+\n+\n+def _validate_standard_deviation(standard_deviation):\n+    if standard_deviation < 0:\n+        raise ValueError(\"Standard deviation must be positive\")\n+\n+\n+def _validate_nu(nu):\n+    if nu < 0:\n+        raise ValueError(\"Nu must be positive\")\n+\n+\n+class UniformPrior(_Prior):\n+    density = \"uniform\"\n+\n+    def __init__(self, lower, upper, mean=None, name=None):\n+        super().__init__(name=name)\n+        if mean is None:\n+            mean = (upper - lower) / 2 + lower\n+        _validate_bounds(lower, mean, upper)\n+\n+        self.lower = lower\n+        self.upper = upper\n+        self.mean = mean\n+\n+    def _parameters(self):\n+        return {\"lower\": self.lower, \"upper\": self.upper, \"mean\": self.mean}\n+\n+\n+class ConstantPrior(_Prior):\n+    density = \"uniform\"\n+\n+    def __init__(self, value, name=None):\n+        super().__init__(name=name)\n+        self.value = value\n+\n+    def _parameters(self):\n+        return {\"lower\": self.value, \"upper\": self.value, \"mean\": self.value}\n+\n+\n+class GaussianPrior(_Prior):\n+    density = \"gaussian\"\n+\n+    def __init__(self, mean, standard_deviation, lower=float(\"-inf\"), upper=float(\"inf\"), name=None):\n+        super().__init__(name=name)\n+        _validate_bounds(lower, mean, upper)\n+        _validate_standard_deviation(standard_deviation)\n+\n+        self.lower = lower\n+        self.upper = upper\n+        self.mean = mean\n+        self.standard_deviation = standard_deviation\n+\n+    def _parameters(self):\n+        return {\"lower\": self.lower, \"upper\": self.upper, \"mean\": self.mean, \"std\": self.standard_deviation}\n+\n+\n+class LaplacePrior(GaussianPrior):\n+    density = \"laplace\"\n+\n+\n+class StudentsTPrior(_Prior):\n+    density = \"students\"\n+\n+    def __init__(self, mean, standard_deviation, nu, lower=float(\"-inf\"), upper=float(\"inf\"), name=None):\n+        super().__init__(name=name)\n+        _validate_bounds(lower, mean, upper)\n+        _validate_standard_deviation(standard_deviation)\n+        _validate_nu(nu)\n+\n+        self.lower = lower\n+        self.upper = upper\n+        self.mean = mean\n+        self.standard_deviation = standard_deviation\n+        self.nu = nu\n+\n+    def _parameters(self):\n+        return {\n+            \"lower\": self.lower,\n+            \"upper\": self.upper,\n+            \"mean\": self.mean,\n+            \"std\": self.standard_deviation,\n+            \"nu\": self.nu,\n+        }\n+\n+\n+class LogGaussianPrior(_Prior):\n+    density = \"log_gaussian\"\n+\n+    def __init__(self, mean, standard_deviation, eta, lower=float(\"-inf\"), upper=float(\"inf\"), name=None):\n+        super().__init__(name=name)\n+        _validate_bounds(lower, mean, upper)\n+        _validate_standard_deviation(standard_deviation)","path":"src/cascade/model/priors.py","position":132,"original_position":132,"commit_id":"a54401453cbc346f53426da3d2f8ed88c5defc03","original_commit_id":"a54401453cbc346f53426da3d2f8ed88c5defc03","user":{"login":"adolgert","id":760985,"node_id":"MDQ6VXNlcjc2MDk4NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/760985?v=4","gravatar_id":"","url":"https://api.github.com/users/adolgert","html_url":"https://github.com/adolgert","followers_url":"https://api.github.com/users/adolgert/followers","following_url":"https://api.github.com/users/adolgert/following{/other_user}","gists_url":"https://api.github.com/users/adolgert/gists{/gist_id}","starred_url":"https://api.github.com/users/adolgert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adolgert/subscriptions","organizations_url":"https://api.github.com/users/adolgert/orgs","repos_url":"https://api.github.com/users/adolgert/repos","events_url":"https://api.github.com/users/adolgert/events{/privacy}","received_events_url":"https://api.github.com/users/adolgert/received_events","type":"User","site_admin":false},"body":"This is also nicer than the validations in Alex's code b/c they are validated in logically-related places, as opposed to a long list. Less brittle this way.","created_at":"2018-08-18T00:55:27Z","updated_at":"2018-08-18T00:55:27Z","html_url":"https://github.com/ihmeuw/cascade/pull/25#discussion_r211059644","pull_request_url":"https://api.github.com/repos/ihmeuw/cascade/pulls/25","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/comments/211059644"},"html":{"href":"https://github.com/ihmeuw/cascade/pull/25#discussion_r211059644"},"pull_request":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/25"}},"in_reply_to_id":211056152},"pull_request":{"url":"https://api.github.com/repos/ihmeuw/cascade/pulls/25","id":209269226,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5MjY5MjI2","html_url":"https://github.com/ihmeuw/cascade/pull/25","diff_url":"https://github.com/ihmeuw/cascade/pull/25.diff","patch_url":"https://github.com/ihmeuw/cascade/pull/25.patch","issue_url":"https://api.github.com/repos/ihmeuw/cascade/issues/25","number":25,"state":"open","locked":false,"title":"Backend for smoothing API and other internal model -> dismodfile translation","user":{"login":"alec-deason","id":419770,"node_id":"MDQ6VXNlcjQxOTc3MA==","avatar_url":"https://avatars3.githubusercontent.com/u/419770?v=4","gravatar_id":"","url":"https://api.github.com/users/alec-deason","html_url":"https://github.com/alec-deason","followers_url":"https://api.github.com/users/alec-deason/followers","following_url":"https://api.github.com/users/alec-deason/following{/other_user}","gists_url":"https://api.github.com/users/alec-deason/gists{/gist_id}","starred_url":"https://api.github.com/users/alec-deason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alec-deason/subscriptions","organizations_url":"https://api.github.com/users/alec-deason/orgs","repos_url":"https://api.github.com/users/alec-deason/repos","events_url":"https://api.github.com/users/alec-deason/events{/privacy}","received_events_url":"https://api.github.com/users/alec-deason/received_events","type":"User","site_admin":false},"body":"This adds a backend for the API in https://github.com/ihmeuw/cascade/pull/15 and integrates it with a lightly cleaned up version of Drew's Dismodfile builder. There is a lot of work to be done on making that part of the system clear and robust, but this starts it.","created_at":"2018-08-17T22:12:57Z","updated_at":"2018-08-18T00:55:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce49ea551e224e5c035bcb4fdd160c943fdc281f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ihmeuw/cascade/pulls/25/commits","review_comments_url":"https://api.github.com/repos/ihmeuw/cascade/pulls/25/comments","review_comment_url":"https://api.github.com/repos/ihmeuw/cascade/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ihmeuw/cascade/issues/25/comments","statuses_url":"https://api.github.com/repos/ihmeuw/cascade/statuses/a54401453cbc346f53426da3d2f8ed88c5defc03","head":{"label":"alec-deason:feature/DISMODAT-267-smoothers-to-dismodfile","ref":"feature/DISMODAT-267-smoothers-to-dismodfile","sha":"a54401453cbc346f53426da3d2f8ed88c5defc03","user":{"login":"alec-deason","id":419770,"node_id":"MDQ6VXNlcjQxOTc3MA==","avatar_url":"https://avatars3.githubusercontent.com/u/419770?v=4","gravatar_id":"","url":"https://api.github.com/users/alec-deason","html_url":"https://github.com/alec-deason","followers_url":"https://api.github.com/users/alec-deason/followers","following_url":"https://api.github.com/users/alec-deason/following{/other_user}","gists_url":"https://api.github.com/users/alec-deason/gists{/gist_id}","starred_url":"https://api.github.com/users/alec-deason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alec-deason/subscriptions","organizations_url":"https://api.github.com/users/alec-deason/orgs","repos_url":"https://api.github.com/users/alec-deason/repos","events_url":"https://api.github.com/users/alec-deason/events{/privacy}","received_events_url":"https://api.github.com/users/alec-deason/received_events","type":"User","site_admin":false},"repo":{"id":141180882,"node_id":"MDEwOlJlcG9zaXRvcnkxNDExODA4ODI=","name":"cascade","full_name":"alec-deason/cascade","owner":{"login":"alec-deason","id":419770,"node_id":"MDQ6VXNlcjQxOTc3MA==","avatar_url":"https://avatars3.githubusercontent.com/u/419770?v=4","gravatar_id":"","url":"https://api.github.com/users/alec-deason","html_url":"https://github.com/alec-deason","followers_url":"https://api.github.com/users/alec-deason/followers","following_url":"https://api.github.com/users/alec-deason/following{/other_user}","gists_url":"https://api.github.com/users/alec-deason/gists{/gist_id}","starred_url":"https://api.github.com/users/alec-deason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alec-deason/subscriptions","organizations_url":"https://api.github.com/users/alec-deason/orgs","repos_url":"https://api.github.com/users/alec-deason/repos","events_url":"https://api.github.com/users/alec-deason/events{/privacy}","received_events_url":"https://api.github.com/users/alec-deason/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alec-deason/cascade","description":"Multi-stage hierarchical estimation of disease processes on demographic observations","fork":true,"url":"https://api.github.com/repos/alec-deason/cascade","forks_url":"https://api.github.com/repos/alec-deason/cascade/forks","keys_url":"https://api.github.com/repos/alec-deason/cascade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alec-deason/cascade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alec-deason/cascade/teams","hooks_url":"https://api.github.com/repos/alec-deason/cascade/hooks","issue_events_url":"https://api.github.com/repos/alec-deason/cascade/issues/events{/number}","events_url":"https://api.github.com/repos/alec-deason/cascade/events","assignees_url":"https://api.github.com/repos/alec-deason/cascade/assignees{/user}","branches_url":"https://api.github.com/repos/alec-deason/cascade/branches{/branch}","tags_url":"https://api.github.com/repos/alec-deason/cascade/tags","blobs_url":"https://api.github.com/repos/alec-deason/cascade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alec-deason/cascade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alec-deason/cascade/git/refs{/sha}","trees_url":"https://api.github.com/repos/alec-deason/cascade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alec-deason/cascade/statuses/{sha}","languages_url":"https://api.github.com/repos/alec-deason/cascade/languages","stargazers_url":"https://api.github.com/repos/alec-deason/cascade/stargazers","contributors_url":"https://api.github.com/repos/alec-deason/cascade/contributors","subscribers_url":"https://api.github.com/repos/alec-deason/cascade/subscribers","subscription_url":"https://api.github.com/repos/alec-deason/cascade/subscription","commits_url":"https://api.github.com/repos/alec-deason/cascade/commits{/sha}","git_commits_url":"https://api.github.com/repos/alec-deason/cascade/git/commits{/sha}","comments_url":"https://api.github.com/repos/alec-deason/cascade/comments{/number}","issue_comment_url":"https://api.github.com/repos/alec-deason/cascade/issues/comments{/number}","contents_url":"https://api.github.com/repos/alec-deason/cascade/contents/{+path}","compare_url":"https://api.github.com/repos/alec-deason/cascade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alec-deason/cascade/merges","archive_url":"https://api.github.com/repos/alec-deason/cascade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alec-deason/cascade/downloads","issues_url":"https://api.github.com/repos/alec-deason/cascade/issues{/number}","pulls_url":"https://api.github.com/repos/alec-deason/cascade/pulls{/number}","milestones_url":"https://api.github.com/repos/alec-deason/cascade/milestones{/number}","notifications_url":"https://api.github.com/repos/alec-deason/cascade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alec-deason/cascade/labels{/name}","releases_url":"https://api.github.com/repos/alec-deason/cascade/releases{/id}","deployments_url":"https://api.github.com/repos/alec-deason/cascade/deployments","created_at":"2018-07-16T18:56:40Z","updated_at":"2018-07-16T18:56:42Z","pushed_at":"2018-08-17T22:09:25Z","git_url":"git://github.com/alec-deason/cascade.git","ssh_url":"git@github.com:alec-deason/cascade.git","clone_url":"https://github.com/alec-deason/cascade.git","svn_url":"https://github.com/alec-deason/cascade","homepage":null,"size":269,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ihmeuw:develop","ref":"develop","sha":"eb81dc7d1533ab1048009266ff1e0c76ff437706","user":{"login":"ihmeuw","id":4683173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2ODMxNzM=","avatar_url":"https://avatars1.githubusercontent.com/u/4683173?v=4","gravatar_id":"","url":"https://api.github.com/users/ihmeuw","html_url":"https://github.com/ihmeuw","followers_url":"https://api.github.com/users/ihmeuw/followers","following_url":"https://api.github.com/users/ihmeuw/following{/other_user}","gists_url":"https://api.github.com/users/ihmeuw/gists{/gist_id}","starred_url":"https://api.github.com/users/ihmeuw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ihmeuw/subscriptions","organizations_url":"https://api.github.com/users/ihmeuw/orgs","repos_url":"https://api.github.com/users/ihmeuw/repos","events_url":"https://api.github.com/users/ihmeuw/events{/privacy}","received_events_url":"https://api.github.com/users/ihmeuw/received_events","type":"Organization","site_admin":false},"repo":{"id":140491515,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA0OTE1MTU=","name":"cascade","full_name":"ihmeuw/cascade","owner":{"login":"ihmeuw","id":4683173,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ2ODMxNzM=","avatar_url":"https://avatars1.githubusercontent.com/u/4683173?v=4","gravatar_id":"","url":"https://api.github.com/users/ihmeuw","html_url":"https://github.com/ihmeuw","followers_url":"https://api.github.com/users/ihmeuw/followers","following_url":"https://api.github.com/users/ihmeuw/following{/other_user}","gists_url":"https://api.github.com/users/ihmeuw/gists{/gist_id}","starred_url":"https://api.github.com/users/ihmeuw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ihmeuw/subscriptions","organizations_url":"https://api.github.com/users/ihmeuw/orgs","repos_url":"https://api.github.com/users/ihmeuw/repos","events_url":"https://api.github.com/users/ihmeuw/events{/privacy}","received_events_url":"https://api.github.com/users/ihmeuw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ihmeuw/cascade","description":"Multi-stage hierarchical estimation of disease processes on demographic observations","fork":false,"url":"https://api.github.com/repos/ihmeuw/cascade","forks_url":"https://api.github.com/repos/ihmeuw/cascade/forks","keys_url":"https://api.github.com/repos/ihmeuw/cascade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ihmeuw/cascade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ihmeuw/cascade/teams","hooks_url":"https://api.github.com/repos/ihmeuw/cascade/hooks","issue_events_url":"https://api.github.com/repos/ihmeuw/cascade/issues/events{/number}","events_url":"https://api.github.com/repos/ihmeuw/cascade/events","assignees_url":"https://api.github.com/repos/ihmeuw/cascade/assignees{/user}","branches_url":"https://api.github.com/repos/ihmeuw/cascade/branches{/branch}","tags_url":"https://api.github.com/repos/ihmeuw/cascade/tags","blobs_url":"https://api.github.com/repos/ihmeuw/cascade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ihmeuw/cascade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ihmeuw/cascade/git/refs{/sha}","trees_url":"https://api.github.com/repos/ihmeuw/cascade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ihmeuw/cascade/statuses/{sha}","languages_url":"https://api.github.com/repos/ihmeuw/cascade/languages","stargazers_url":"https://api.github.com/repos/ihmeuw/cascade/stargazers","contributors_url":"https://api.github.com/repos/ihmeuw/cascade/contributors","subscribers_url":"https://api.github.com/repos/ihmeuw/cascade/subscribers","subscription_url":"https://api.github.com/repos/ihmeuw/cascade/subscription","commits_url":"https://api.github.com/repos/ihmeuw/cascade/commits{/sha}","git_commits_url":"https://api.github.com/repos/ihmeuw/cascade/git/commits{/sha}","comments_url":"https://api.github.com/repos/ihmeuw/cascade/comments{/number}","issue_comment_url":"https://api.github.com/repos/ihmeuw/cascade/issues/comments{/number}","contents_url":"https://api.github.com/repos/ihmeuw/cascade/contents/{+path}","compare_url":"https://api.github.com/repos/ihmeuw/cascade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ihmeuw/cascade/merges","archive_url":"https://api.github.com/repos/ihmeuw/cascade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ihmeuw/cascade/downloads","issues_url":"https://api.github.com/repos/ihmeuw/cascade/issues{/number}","pulls_url":"https://api.github.com/repos/ihmeuw/cascade/pulls{/number}","milestones_url":"https://api.github.com/repos/ihmeuw/cascade/milestones{/number}","notifications_url":"https://api.github.com/repos/ihmeuw/cascade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ihmeuw/cascade/labels{/name}","releases_url":"https://api.github.com/repos/ihmeuw/cascade/releases{/id}","deployments_url":"https://api.github.com/repos/ihmeuw/cascade/deployments","created_at":"2018-07-10T22:01:19Z","updated_at":"2018-08-17T16:06:17Z","pushed_at":"2018-08-17T23:13:00Z","git_url":"git://github.com/ihmeuw/cascade.git","ssh_url":"git@github.com:ihmeuw/cascade.git","clone_url":"https://github.com/ihmeuw/cascade.git","svn_url":"https://github.com/ihmeuw/cascade","homepage":"https://cascade.readthedocs.io/en/latest/","size":204,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":4,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/25"},"html":{"href":"https://github.com/ihmeuw/cascade/pull/25"},"issue":{"href":"https://api.github.com/repos/ihmeuw/cascade/issues/25"},"comments":{"href":"https://api.github.com/repos/ihmeuw/cascade/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ihmeuw/cascade/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/ihmeuw/cascade/statuses/a54401453cbc346f53426da3d2f8ed88c5defc03"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"adolgert"}}