{"action":"created","comment":{"url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/comments/28430245","id":28430245,"diff_hunk":"@@ -0,0 +1,61 @@\n+import numpy as np\n+from pyspeckit import SpectralCube\n+from pyspeckit.spectrum.units import SpectroscopicAxis\n+from pyspeckit.spectrum.models.inherited_gaussfitter import gaussian_fitter\n+from astropy import units as u\n+import matplotlib.pyplot as plt\n+import pytest\n+\n+strict_assert = True\n+xarr = SpectroscopicAxis(np.linspace(-100, 100, 200), unit=u.dimensionless_unscaled)\n+gf = gaussian_fitter()\n+params = [1.0, 2.0, 5.0]\n+parameter_error_amplitude = [50., 5., 5.]\n+assertion_list = []\n+passes = {'passes': [0,0,0], 'avg_difference': [0,0,0]}\n+fails = {'fails': [0,0,0], 'avg_difference': [0, 0, 0]}\n+\n+\n+@pytest.mark.parametrize((\"rawdata\", \"noise\"), [\n+\t\t\t\t\t\t (gf.n_modelfunc(pars=params)(xarr.value), \n+\t\t\t\t\t\t  np.random.randn(xarr.value.size)/100.)])\n+def test_fiteach(rawdata, noise):\n+\tfor i in range(10):\n+\t\tpassed = True\n+\t\tparameter_noise = [params[0] + abs(np.random.randn()) * parameter_error_amplitude[0], \n+\t\t                   params[1] + abs(np.random.randn()) * parameter_error_amplitude[1],\n+\t\t                   params[2] + abs(np.random.randn()) * parameter_error_amplitude[2]]\n+\t\tguesses = np.array(params)+parameter_noise\n+\t\terrspec = np.ones(xarr.size)\n+\t\tdata = rawdata + noise\n+\t\tcube = [[[x for x in data] for y in range(2)] for z in range(2)]\n+\t\tcube = np.array(cube)\n+\t\tcube = np.rollaxis(cube, 2, 0)\n+\t\tsp = SpectralCube.Cube(xarr=xarr, cube=cube, unit='Hz')\n+\t\tsp.fiteach(guesses=guesses, errspec=errspec, signal_cut=0, fitkwargs={'guesses':guesses})\n+\t\t# sp.plotter(axis=plt.gca())\n+\t\t# plt.show()\n+\t\tresult_cube = sp.parcube\n+\t\tprint 'sp.parcube:',sp.parcube\n+\t\tfor i in range(2):\n+\t\t\tfor j in range(2):\n+\t\t\t\tassertion = ((np.array(result_cube[:,i,j])-np.array(params))/parameter_noise)**2\n+\t\t\t\tfor k,result in enumerate(assertion):\n+\t\t\t\t\tif strict_assert:\n+\t\t\t\t\t\tassert result < 2\n+\t\t\t\t\tif result >= 2: \n+\t\t\t\t\t\tpassed = False\n+\t\t\t\t\t\tcontinue\n+\t\t\t\tif passed:\n+\t\t\t\t\tfor k in range(3):\n+\t\t\t\t\t\tpasses['passes'][k]+=1\n+\t\t\t\t\t\tpasses['avg_difference'][k] += abs(result_cube[:,i,j][k] - params[k]).tolist()\n+\t\t\t\telse:\n+\t\t\t\t\tfor k in range(3):\n+\t\t\t\t\t\tfails['fails'][k]+=1\n+\t\t\t\t\t\tfails['avg_difference'][k] += abs(result_cube[:,i,j][k] - params[k]).tolist()\n+\t\t\t\tassertion_list.append(assertion)\n+\n+\tprint 'assertion_list:', np.array(assertion_list)\n+\tprint 'passes:', passes\n+\tprint 'fails:', fails","path":"test_Cube_fiteach.py","position":61,"original_position":61,"commit_id":"594a8b027a729087df65ce5a7619d5cdb965a789","original_commit_id":"137170adee2509a575872fe3c96318c004cb0f69","user":{"login":"keflavich","id":143715,"avatar_url":"https://avatars.githubusercontent.com/u/143715?v=3","gravatar_id":"","url":"https://api.github.com/users/keflavich","html_url":"https://github.com/keflavich","followers_url":"https://api.github.com/users/keflavich/followers","following_url":"https://api.github.com/users/keflavich/following{/other_user}","gists_url":"https://api.github.com/users/keflavich/gists{/gist_id}","starred_url":"https://api.github.com/users/keflavich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keflavich/subscriptions","organizations_url":"https://api.github.com/users/keflavich/orgs","repos_url":"https://api.github.com/users/keflavich/repos","events_url":"https://api.github.com/users/keflavich/events{/privacy}","received_events_url":"https://api.github.com/users/keflavich/received_events","type":"User","site_admin":false},"body":"No, for tests a simple assertion is fine, as long as it's clear what the test is doing.  Clear error messages are meant for users of the code; tests are really more to make sure it works and we understand why it doesn't if it doesn't","created_at":"2015-04-15T15:25:07Z","updated_at":"2015-04-15T15:25:07Z","html_url":"https://github.com/pyspeckit/pyspeckit-tests/pull/7#discussion_r28430245","pull_request_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/comments/28430245"},"html":{"href":"https://github.com/pyspeckit/pyspeckit-tests/pull/7#discussion_r28430245"},"pull_request":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7","id":33360989,"html_url":"https://github.com/pyspeckit/pyspeckit-tests/pull/7","diff_url":"https://github.com/pyspeckit/pyspeckit-tests/pull/7.diff","patch_url":"https://github.com/pyspeckit/pyspeckit-tests/pull/7.patch","issue_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/7","number":7,"state":"open","locked":false,"title":"Test spectroscopic axis","user":{"login":"dinossimpson","id":1566093,"avatar_url":"https://avatars.githubusercontent.com/u/1566093?v=3","gravatar_id":"","url":"https://api.github.com/users/dinossimpson","html_url":"https://github.com/dinossimpson","followers_url":"https://api.github.com/users/dinossimpson/followers","following_url":"https://api.github.com/users/dinossimpson/following{/other_user}","gists_url":"https://api.github.com/users/dinossimpson/gists{/gist_id}","starred_url":"https://api.github.com/users/dinossimpson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinossimpson/subscriptions","organizations_url":"https://api.github.com/users/dinossimpson/orgs","repos_url":"https://api.github.com/users/dinossimpson/repos","events_url":"https://api.github.com/users/dinossimpson/events{/privacy}","received_events_url":"https://api.github.com/users/dinossimpson/received_events","type":"User","site_admin":false},"body":"Added test_spectroscopicAxis.py and test_Cube_fit.py\r\ntest_spectroscopicAxis.py runs a loop creating spectroscopicAxis instances with fake data+noise,\r\nruns Spectrum.specfit on them and asserts that the resulting parameters are close to the Axis' parameters.\r\ntest_Cube_fit.py follows the same concept but instantiates SpectralCubes instead and runs their fiteach() method.","created_at":"2015-04-15T14:38:57Z","updated_at":"2015-04-15T15:25:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47272074a012750ef43e4dce2d355f3cd664b1cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7/commits","review_comments_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7/comments","review_comment_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/7/comments","statuses_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/statuses/594a8b027a729087df65ce5a7619d5cdb965a789","head":{"label":"dinossimpson:test_spectroscopicAxis","ref":"test_spectroscopicAxis","sha":"594a8b027a729087df65ce5a7619d5cdb965a789","user":{"login":"dinossimpson","id":1566093,"avatar_url":"https://avatars.githubusercontent.com/u/1566093?v=3","gravatar_id":"","url":"https://api.github.com/users/dinossimpson","html_url":"https://github.com/dinossimpson","followers_url":"https://api.github.com/users/dinossimpson/followers","following_url":"https://api.github.com/users/dinossimpson/following{/other_user}","gists_url":"https://api.github.com/users/dinossimpson/gists{/gist_id}","starred_url":"https://api.github.com/users/dinossimpson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinossimpson/subscriptions","organizations_url":"https://api.github.com/users/dinossimpson/orgs","repos_url":"https://api.github.com/users/dinossimpson/repos","events_url":"https://api.github.com/users/dinossimpson/events{/privacy}","received_events_url":"https://api.github.com/users/dinossimpson/received_events","type":"User","site_admin":false},"repo":{"id":31966096,"name":"pyspeckit-tests","full_name":"dinossimpson/pyspeckit-tests","owner":{"login":"dinossimpson","id":1566093,"avatar_url":"https://avatars.githubusercontent.com/u/1566093?v=3","gravatar_id":"","url":"https://api.github.com/users/dinossimpson","html_url":"https://github.com/dinossimpson","followers_url":"https://api.github.com/users/dinossimpson/followers","following_url":"https://api.github.com/users/dinossimpson/following{/other_user}","gists_url":"https://api.github.com/users/dinossimpson/gists{/gist_id}","starred_url":"https://api.github.com/users/dinossimpson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinossimpson/subscriptions","organizations_url":"https://api.github.com/users/dinossimpson/orgs","repos_url":"https://api.github.com/users/dinossimpson/repos","events_url":"https://api.github.com/users/dinossimpson/events{/privacy}","received_events_url":"https://api.github.com/users/dinossimpson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dinossimpson/pyspeckit-tests","description":"Tests for pyspeckit (including large data files)","fork":true,"url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests","forks_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/forks","keys_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/teams","hooks_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/hooks","issue_events_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/issues/events{/number}","events_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/events","assignees_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/assignees{/user}","branches_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/branches{/branch}","tags_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/tags","blobs_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/languages","stargazers_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/stargazers","contributors_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/contributors","subscribers_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/subscribers","subscription_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/subscription","commits_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/contents/{+path}","compare_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/merges","archive_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/downloads","issues_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/issues{/number}","pulls_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/labels{/name}","releases_url":"https://api.github.com/repos/dinossimpson/pyspeckit-tests/releases{/id}","created_at":"2015-03-10T15:46:05Z","updated_at":"2015-03-10T15:46:07Z","pushed_at":"2015-04-15T15:19:13Z","git_url":"git://github.com/dinossimpson/pyspeckit-tests.git","ssh_url":"git@github.com:dinossimpson/pyspeckit-tests.git","clone_url":"https://github.com/dinossimpson/pyspeckit-tests.git","svn_url":"https://github.com/dinossimpson/pyspeckit-tests","homepage":null,"size":26796,"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":"pyspeckit:master","ref":"master","sha":"62153cb2dbff2cffda1a9c8f626ac4e1549f8532","user":{"login":"pyspeckit","id":2507522,"avatar_url":"https://avatars.githubusercontent.com/u/2507522?v=3","gravatar_id":"","url":"https://api.github.com/users/pyspeckit","html_url":"https://github.com/pyspeckit","followers_url":"https://api.github.com/users/pyspeckit/followers","following_url":"https://api.github.com/users/pyspeckit/following{/other_user}","gists_url":"https://api.github.com/users/pyspeckit/gists{/gist_id}","starred_url":"https://api.github.com/users/pyspeckit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyspeckit/subscriptions","organizations_url":"https://api.github.com/users/pyspeckit/orgs","repos_url":"https://api.github.com/users/pyspeckit/repos","events_url":"https://api.github.com/users/pyspeckit/events{/privacy}","received_events_url":"https://api.github.com/users/pyspeckit/received_events","type":"User","site_admin":false},"repo":{"id":9843761,"name":"pyspeckit-tests","full_name":"pyspeckit/pyspeckit-tests","owner":{"login":"pyspeckit","id":2507522,"avatar_url":"https://avatars.githubusercontent.com/u/2507522?v=3","gravatar_id":"","url":"https://api.github.com/users/pyspeckit","html_url":"https://github.com/pyspeckit","followers_url":"https://api.github.com/users/pyspeckit/followers","following_url":"https://api.github.com/users/pyspeckit/following{/other_user}","gists_url":"https://api.github.com/users/pyspeckit/gists{/gist_id}","starred_url":"https://api.github.com/users/pyspeckit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyspeckit/subscriptions","organizations_url":"https://api.github.com/users/pyspeckit/orgs","repos_url":"https://api.github.com/users/pyspeckit/repos","events_url":"https://api.github.com/users/pyspeckit/events{/privacy}","received_events_url":"https://api.github.com/users/pyspeckit/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pyspeckit/pyspeckit-tests","description":"Tests for pyspeckit (including large data files)","fork":false,"url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests","forks_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/forks","keys_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/teams","hooks_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/hooks","issue_events_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/events{/number}","events_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/events","assignees_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/assignees{/user}","branches_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/branches{/branch}","tags_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/tags","blobs_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/statuses/{sha}","languages_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/languages","stargazers_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/stargazers","contributors_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/contributors","subscribers_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/subscribers","subscription_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/subscription","commits_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/contents/{+path}","compare_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/merges","archive_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/downloads","issues_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues{/number}","pulls_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls{/number}","milestones_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/milestones{/number}","notifications_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/labels{/name}","releases_url":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/releases{/id}","created_at":"2013-05-03T20:13:45Z","updated_at":"2015-04-07T16:22:17Z","pushed_at":"2015-04-15T15:19:14Z","git_url":"git://github.com/pyspeckit/pyspeckit-tests.git","ssh_url":"git@github.com:pyspeckit/pyspeckit-tests.git","clone_url":"https://github.com/pyspeckit/pyspeckit-tests.git","svn_url":"https://github.com/pyspeckit/pyspeckit-tests","homepage":null,"size":27137,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7"},"html":{"href":"https://github.com/pyspeckit/pyspeckit-tests/pull/7"},"issue":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/7"},"comments":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/pyspeckit/pyspeckit-tests/statuses/594a8b027a729087df65ce5a7619d5cdb965a789"}}}}