{"action":"created","comment":{"url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/comments/60350223","id":60350223,"diff_hunk":"@@ -0,0 +1,146 @@\n+#!/usr/bin/python\n+# -*- coding: utf-8 -*-\n+##\n+# test_abstract_model.py: Checks that Model works properly.\n+##\n+# © 2014 Chris Ferrie (csferrie@gmail.com) and\n+#        Christopher E. Granade (cgranade@gmail.com)\n+#     \n+# This file is a part of the Qinfer project.\n+# Licensed under the AGPL version 3.\n+##\n+# This program is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU Affero General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU Affero General Public License for more details.\n+#\n+# You should have received a copy of the GNU Affero General Public License\n+# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+##\n+\n+## FEATURES ###################################################################\n+\n+from __future__ import division # Ensures that a/b is always a float.\n+from __future__ import absolute_import\n+## IMPORTS ####################################################################\n+\n+import numpy as np\n+from numpy.testing import assert_equal, assert_almost_equal, assert_array_less\n+\n+from qinfer.tests.base_test import DerandomizedTestCase\n+from qinfer.abstract_model import (\n+    Model)\n+from qinfer import ScoreMixin, SimplePrecessionModel, UniformDistribution\n+\n+from qinfer.smc import SMCUpdater,SMCUpdaterBCRB\n+\n+# replace analytical score with numerical\n+class NumericalSimplePrecessionModel(ScoreMixin, SimplePrecessionModel):\n+    pass\n+\n+\n+\n+class TestSMCUpdater(DerandomizedTestCase):\n+\t# True model parameter for test\n+\tMODELPARAMS = np.array([1,])\n+\tTEST_EXPPARAMS = np.linspace(1.,10.,100,dtype=np.float)\n+\tPRIOR = UniformDistribution([[0,2]])\n+\tN_PARTICLES = 10000\n+\n+\tTEST_TARGET_COV = np.array([[0.01]])\n+\n+\tdef setUp(self):\n+\n+\t\tsuper(TestSMCUpdater,self).setUp()\n+\t\tself.precession_model = SimplePrecessionModel()\n+\t\tself.num_precession_model = NumericalSimplePrecessionModel() \n+\t\tself.expparams = TestSMCUpdater.TEST_EXPPARAMS.reshape(-1,1)\n+\t\tself.outcomes = self.precession_model.simulate_experiment(TestSMCUpdater.MODELPARAMS,\n+\t\t\t\tTestSMCUpdater.TEST_EXPPARAMS,repeat=1 ).reshape(-1,1)\n+\n+\t\tself.updater = SMCUpdater(self.precession_model,\n+\t\t\t\tTestSMCUpdater.N_PARTICLES,TestSMCUpdater.PRIOR)\n+\t\tself.updater_bayes = SMCUpdaterBCRB(self.precession_model,\n+\t\t\t\tTestSMCUpdater.N_PARTICLES,TestSMCUpdater.PRIOR,adaptive=True)\n+\t\tself.num_updater = SMCUpdater(self.num_precession_model,\n+\t\t\t\tTestSMCUpdater.N_PARTICLES,TestSMCUpdater.PRIOR)\n+\t\tself.num_updater_bayes = SMCUpdaterBCRB(self.num_precession_model,\n+\t\t\t\tTestSMCUpdater.N_PARTICLES,TestSMCUpdater.PRIOR,adaptive=True)\n+\n+\n+\tdef test_smc_fitting(self):\n+\t\t\"\"\"\n+\t\tChecks that the fitters converge on true value on simple precession_model. Is a stochastic\n+\t\ttest but I ran 100 times and there were no fails, with these parameters.\n+\t\t\"\"\"\n+\n+\t\tself.updater.batch_update(self.outcomes,self.expparams)\n+\t\tself.updater_bayes.batch_update(self.outcomes,self.expparams)\n+\t\tself.num_updater.batch_update(self.outcomes,self.expparams)\n+\t\tself.num_updater_bayes.batch_update(self.outcomes,self.expparams)\n+\n+\t\t#Assert that models have learned true model parameters from data \n+\t\tassert_almost_equal(self.updater.est_mean(),TestSMCUpdater.MODELPARAMS,2)\n+\t\tassert_almost_equal(self.updater_bayes.est_mean(),TestSMCUpdater.MODELPARAMS,2)\n+\t\tassert_almost_equal(self.num_updater.est_mean(),TestSMCUpdater.MODELPARAMS,2)\n+\t\tassert_almost_equal(self.num_updater_bayes.est_mean(),TestSMCUpdater.MODELPARAMS,2)\n+\n+\n+\t\t#test means\n+\t\tassert_almost_equal(self.updater.est_mean(),TestSMCUpdater.MODELPARAMS,2)","path":"src/qinfer/tests/precession_model_test.py","position":95,"original_position":95,"commit_id":"ca0481529103f5db8ddc522ec8148fd126ae7448","original_commit_id":"ca0481529103f5db8ddc522ec8148fd126ae7448","user":{"login":"whitewhim2718","id":1553846,"avatar_url":"https://avatars.githubusercontent.com/u/1553846?v=3","gravatar_id":"","url":"https://api.github.com/users/whitewhim2718","html_url":"https://github.com/whitewhim2718","followers_url":"https://api.github.com/users/whitewhim2718/followers","following_url":"https://api.github.com/users/whitewhim2718/following{/other_user}","gists_url":"https://api.github.com/users/whitewhim2718/gists{/gist_id}","starred_url":"https://api.github.com/users/whitewhim2718/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitewhim2718/subscriptions","organizations_url":"https://api.github.com/users/whitewhim2718/orgs","repos_url":"https://api.github.com/users/whitewhim2718/repos","events_url":"https://api.github.com/users/whitewhim2718/events{/privacy}","received_events_url":"https://api.github.com/users/whitewhim2718/received_events","type":"User","site_admin":false},"body":"yup. ","created_at":"2016-04-20T04:50:06Z","updated_at":"2016-04-20T04:50:06Z","html_url":"https://github.com/QInfer/python-qinfer/pull/46#discussion_r60350223","pull_request_url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/comments/60350223"},"html":{"href":"https://github.com/QInfer/python-qinfer/pull/46#discussion_r60350223"},"pull_request":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46","id":66714914,"html_url":"https://github.com/QInfer/python-qinfer/pull/46","diff_url":"https://github.com/QInfer/python-qinfer/pull/46.diff","patch_url":"https://github.com/QInfer/python-qinfer/pull/46.patch","issue_url":"https://api.github.com/repos/QInfer/python-qinfer/issues/46","number":46,"state":"open","locked":false,"title":"Smc fixes","user":{"login":"whitewhim2718","id":1553846,"avatar_url":"https://avatars.githubusercontent.com/u/1553846?v=3","gravatar_id":"","url":"https://api.github.com/users/whitewhim2718","html_url":"https://github.com/whitewhim2718","followers_url":"https://api.github.com/users/whitewhim2718/followers","following_url":"https://api.github.com/users/whitewhim2718/following{/other_user}","gists_url":"https://api.github.com/users/whitewhim2718/gists{/gist_id}","starred_url":"https://api.github.com/users/whitewhim2718/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitewhim2718/subscriptions","organizations_url":"https://api.github.com/users/whitewhim2718/orgs","repos_url":"https://api.github.com/users/whitewhim2718/repos","events_url":"https://api.github.com/users/whitewhim2718/events{/privacy}","received_events_url":"https://api.github.com/users/whitewhim2718/received_events","type":"User","site_admin":false},"body":"Made changes as discussed in Issue #41. Also added test case to test both the changes I made, and the SMC updater as a whole on the SimplePrecessionModel. Tests are stochastic, but for 100 runs with the test parameters, there were no fails. ","created_at":"2016-04-15T22:44:37Z","updated_at":"2016-04-20T04:50:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b895422029ea957d9e6719a62ed4d1a16ca10702","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46/commits","review_comments_url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46/comments","review_comment_url":"https://api.github.com/repos/QInfer/python-qinfer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/QInfer/python-qinfer/issues/46/comments","statuses_url":"https://api.github.com/repos/QInfer/python-qinfer/statuses/ca0481529103f5db8ddc522ec8148fd126ae7448","head":{"label":"whitewhim2718:smc_fixes","ref":"smc_fixes","sha":"ca0481529103f5db8ddc522ec8148fd126ae7448","user":{"login":"whitewhim2718","id":1553846,"avatar_url":"https://avatars.githubusercontent.com/u/1553846?v=3","gravatar_id":"","url":"https://api.github.com/users/whitewhim2718","html_url":"https://github.com/whitewhim2718","followers_url":"https://api.github.com/users/whitewhim2718/followers","following_url":"https://api.github.com/users/whitewhim2718/following{/other_user}","gists_url":"https://api.github.com/users/whitewhim2718/gists{/gist_id}","starred_url":"https://api.github.com/users/whitewhim2718/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitewhim2718/subscriptions","organizations_url":"https://api.github.com/users/whitewhim2718/orgs","repos_url":"https://api.github.com/users/whitewhim2718/repos","events_url":"https://api.github.com/users/whitewhim2718/events{/privacy}","received_events_url":"https://api.github.com/users/whitewhim2718/received_events","type":"User","site_admin":false},"repo":{"id":53606503,"name":"python-qinfer","full_name":"whitewhim2718/python-qinfer","owner":{"login":"whitewhim2718","id":1553846,"avatar_url":"https://avatars.githubusercontent.com/u/1553846?v=3","gravatar_id":"","url":"https://api.github.com/users/whitewhim2718","html_url":"https://github.com/whitewhim2718","followers_url":"https://api.github.com/users/whitewhim2718/followers","following_url":"https://api.github.com/users/whitewhim2718/following{/other_user}","gists_url":"https://api.github.com/users/whitewhim2718/gists{/gist_id}","starred_url":"https://api.github.com/users/whitewhim2718/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitewhim2718/subscriptions","organizations_url":"https://api.github.com/users/whitewhim2718/orgs","repos_url":"https://api.github.com/users/whitewhim2718/repos","events_url":"https://api.github.com/users/whitewhim2718/events{/privacy}","received_events_url":"https://api.github.com/users/whitewhim2718/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/whitewhim2718/python-qinfer","description":"Library for Bayesian inference via sequential Monte Carlo for quantum parameter estimation.","fork":true,"url":"https://api.github.com/repos/whitewhim2718/python-qinfer","forks_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/forks","keys_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/teams","hooks_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/hooks","issue_events_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/issues/events{/number}","events_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/events","assignees_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/assignees{/user}","branches_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/branches{/branch}","tags_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/tags","blobs_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/git/refs{/sha}","trees_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/statuses/{sha}","languages_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/languages","stargazers_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/stargazers","contributors_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/contributors","subscribers_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/subscribers","subscription_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/subscription","commits_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/commits{/sha}","git_commits_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/git/commits{/sha}","comments_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/comments{/number}","issue_comment_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/issues/comments{/number}","contents_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/contents/{+path}","compare_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/merges","archive_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/downloads","issues_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/issues{/number}","pulls_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/pulls{/number}","milestones_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/milestones{/number}","notifications_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/labels{/name}","releases_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/releases{/id}","deployments_url":"https://api.github.com/repos/whitewhim2718/python-qinfer/deployments","created_at":"2016-03-10T18:14:19Z","updated_at":"2016-03-10T18:14:20Z","pushed_at":"2016-04-16T17:08:12Z","git_url":"git://github.com/whitewhim2718/python-qinfer.git","ssh_url":"git@github.com:whitewhim2718/python-qinfer.git","clone_url":"https://github.com/whitewhim2718/python-qinfer.git","svn_url":"https://github.com/whitewhim2718/python-qinfer","homepage":"","size":1370,"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":"QInfer:master","ref":"master","sha":"c5ff7cfb7a1b213058f581b3158fb48d77d40c44","user":{"login":"QInfer","id":16830480,"avatar_url":"https://avatars.githubusercontent.com/u/16830480?v=3","gravatar_id":"","url":"https://api.github.com/users/QInfer","html_url":"https://github.com/QInfer","followers_url":"https://api.github.com/users/QInfer/followers","following_url":"https://api.github.com/users/QInfer/following{/other_user}","gists_url":"https://api.github.com/users/QInfer/gists{/gist_id}","starred_url":"https://api.github.com/users/QInfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QInfer/subscriptions","organizations_url":"https://api.github.com/users/QInfer/orgs","repos_url":"https://api.github.com/users/QInfer/repos","events_url":"https://api.github.com/users/QInfer/events{/privacy}","received_events_url":"https://api.github.com/users/QInfer/received_events","type":"Organization","site_admin":false},"repo":{"id":5420581,"name":"python-qinfer","full_name":"QInfer/python-qinfer","owner":{"login":"QInfer","id":16830480,"avatar_url":"https://avatars.githubusercontent.com/u/16830480?v=3","gravatar_id":"","url":"https://api.github.com/users/QInfer","html_url":"https://github.com/QInfer","followers_url":"https://api.github.com/users/QInfer/followers","following_url":"https://api.github.com/users/QInfer/following{/other_user}","gists_url":"https://api.github.com/users/QInfer/gists{/gist_id}","starred_url":"https://api.github.com/users/QInfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QInfer/subscriptions","organizations_url":"https://api.github.com/users/QInfer/orgs","repos_url":"https://api.github.com/users/QInfer/repos","events_url":"https://api.github.com/users/QInfer/events{/privacy}","received_events_url":"https://api.github.com/users/QInfer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QInfer/python-qinfer","description":"Library for Bayesian inference via sequential Monte Carlo for quantum parameter estimation.","fork":false,"url":"https://api.github.com/repos/QInfer/python-qinfer","forks_url":"https://api.github.com/repos/QInfer/python-qinfer/forks","keys_url":"https://api.github.com/repos/QInfer/python-qinfer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QInfer/python-qinfer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QInfer/python-qinfer/teams","hooks_url":"https://api.github.com/repos/QInfer/python-qinfer/hooks","issue_events_url":"https://api.github.com/repos/QInfer/python-qinfer/issues/events{/number}","events_url":"https://api.github.com/repos/QInfer/python-qinfer/events","assignees_url":"https://api.github.com/repos/QInfer/python-qinfer/assignees{/user}","branches_url":"https://api.github.com/repos/QInfer/python-qinfer/branches{/branch}","tags_url":"https://api.github.com/repos/QInfer/python-qinfer/tags","blobs_url":"https://api.github.com/repos/QInfer/python-qinfer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QInfer/python-qinfer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QInfer/python-qinfer/git/refs{/sha}","trees_url":"https://api.github.com/repos/QInfer/python-qinfer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QInfer/python-qinfer/statuses/{sha}","languages_url":"https://api.github.com/repos/QInfer/python-qinfer/languages","stargazers_url":"https://api.github.com/repos/QInfer/python-qinfer/stargazers","contributors_url":"https://api.github.com/repos/QInfer/python-qinfer/contributors","subscribers_url":"https://api.github.com/repos/QInfer/python-qinfer/subscribers","subscription_url":"https://api.github.com/repos/QInfer/python-qinfer/subscription","commits_url":"https://api.github.com/repos/QInfer/python-qinfer/commits{/sha}","git_commits_url":"https://api.github.com/repos/QInfer/python-qinfer/git/commits{/sha}","comments_url":"https://api.github.com/repos/QInfer/python-qinfer/comments{/number}","issue_comment_url":"https://api.github.com/repos/QInfer/python-qinfer/issues/comments{/number}","contents_url":"https://api.github.com/repos/QInfer/python-qinfer/contents/{+path}","compare_url":"https://api.github.com/repos/QInfer/python-qinfer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QInfer/python-qinfer/merges","archive_url":"https://api.github.com/repos/QInfer/python-qinfer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QInfer/python-qinfer/downloads","issues_url":"https://api.github.com/repos/QInfer/python-qinfer/issues{/number}","pulls_url":"https://api.github.com/repos/QInfer/python-qinfer/pulls{/number}","milestones_url":"https://api.github.com/repos/QInfer/python-qinfer/milestones{/number}","notifications_url":"https://api.github.com/repos/QInfer/python-qinfer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QInfer/python-qinfer/labels{/name}","releases_url":"https://api.github.com/repos/QInfer/python-qinfer/releases{/id}","deployments_url":"https://api.github.com/repos/QInfer/python-qinfer/deployments","created_at":"2012-08-15T01:02:45Z","updated_at":"2016-03-23T07:14:57Z","pushed_at":"2016-04-16T17:08:12Z","git_url":"git://github.com/QInfer/python-qinfer.git","ssh_url":"git@github.com:QInfer/python-qinfer.git","clone_url":"https://github.com/QInfer/python-qinfer.git","svn_url":"https://github.com/QInfer/python-qinfer","homepage":"","size":1361,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":13,"forks":11,"open_issues":13,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46"},"html":{"href":"https://github.com/QInfer/python-qinfer/pull/46"},"issue":{"href":"https://api.github.com/repos/QInfer/python-qinfer/issues/46"},"comments":{"href":"https://api.github.com/repos/QInfer/python-qinfer/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/QInfer/python-qinfer/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/QInfer/python-qinfer/statuses/ca0481529103f5db8ddc522ec8148fd126ae7448"}}}}