{"action":"created","comment":{"url":"https://api.github.com/repos/UT-CHG/BET/pulls/comments/67059612","id":67059612,"diff_hunk":"@@ -42,6 +41,150 @@ def loadmat(save_file, disc_name=None, model=None):\n     loaded_sampler = sampler(model, num_samples)    \n     return (loaded_sampler, discretization)\n \n+def random_sample_set(sample_type, input_obj, num_samples,\n+        criterion='center', globalize=True):\n+    \"\"\"\n+    Sampling algorithm with three basic options\n+\n+        * ``random`` (or ``r``) generates ``num_samples`` samples in\n+            ``lam_domain`` assuming a Lebesgue measure.\n+        * ``lhs`` generates a latin hyper cube of samples.\n+\n+    Note: This function is designed only for generalized rectangles and\n+    assumes a Lebesgue measure on the parameter space.\n+   \n+    :param string sample_type: type sampling random (or r),\n+        latin hypercube(lhs), regular grid (rg), or space-filling\n+        curve(TBD)\n+    :param input_obj: :class:`~bet.sample.sample_set` object containing\n+        the dimension/domain to sample from, domain to sample from, or the\n+        dimension\n+    :type input_obj: :class:`~bet.sample.sample_set` or\n+        :class:`numpy.ndarray` of shape (dim, 2) or ``int``\n+    :param string savefile: filename to save discretization\n+    :param int num_samples: N, number of samples \n+    :param string criterion: latin hypercube criterion see \n+        `PyDOE <http://pythonhosted.org/pyDOE/randomized.html>`_\n+    :param bool globalize: Makes local variables global. Only applies if\n+        ``parallel==True``.\n+    \n+    :rtype: :class:`~bet.sample.sample_set`\n+    :returns: :class:`~bet.sample.sample_set` object which contains\n+        input ``num_samples`` \n+\n+    \"\"\"\n+\n+    # check to see what the input object is\n+    if isinstance(input_obj, sample.sample_set):\n+        input_sample_set = input_obj.copy()\n+    elif isinstance(input_obj, int):\n+        input_sample_set = sample.sample_set(input_obj)\n+    elif isinstance(input_obj, np.ndarray):\n+        input_sample_set = sample.sample_set(input_obj.shape[0])\n+        input_sample_set.set_domain(input_obj)\n+\n+    # Create N samples\n+    dim = input_sample_set.get_dim()\n+\n+    if input_sample_set.get_domain() is None:\n+        # create the domain\n+        input_domain = np.array([[0., 1.]]*dim)\n+        input_sample_set.set_domain(input_domain)\n+    # update the bounds based on the number of samples\n+    input_sample_set.update_bounds(num_samples)\n+    input_values = np.copy(input_sample_set._width)\n+     \n+    if sample_type == \"lhs\":\n+        input_values = input_values * lhs(dim,\n+                num_samples, criterion)\n+    elif sample_type == \"random\" or \"r\":\n+        input_values = input_values * np.random.random(input_values.shape) \n+    input_values = input_values + input_sample_set._left\n+    if globalize is True:\n+        input_sample_set.set_values(input_values)\n+    elif globalize is False and \\\n+            (sample_type == \"random\" or sample_type == 'r'):\n+        input_sample_set.set_values_local(input_values)\n+    else:\n+        input_sample_set.set_values(input_values)\n+        input_sample_set.global_to_local()\n+\n+    return input_sample_set\n+\n+def regular_sample_set(input_obj, num_samples_per_dim=1):\n+    \"\"\"\n+    Sampling algorithm for generating a regular grid of samples taken\n+    on the domain present with ``input_obj`` (a default unit hypercube\n+    is used if no domain has been specified)\n+    \n+    :param input_obj: :class:`~bet.sample.sample_set` object containing\n+        the dimension or domain to sample from, the domain to sample from, or\n+        the dimension\n+    :type input_obj: :class:`~bet.sample.sample_set` or :class:`numpy.ndarray`\n+        of shape (dim, 2) or ``int`` \n+    :param num_samples_per_dim: number of samples per dimension\n+    :type num_samples_per_dim: :class:`~numpy.ndarray` of dimension\n+        ``(input_sample_set._dim,)``\n+\n+    :rtype: :class:`~bet.sample.sample_set`\n+    :returns: :class:`~bet.sample.sample_set` object which contains\n+        input ``num_samples``\n+\n+    \"\"\"\n+    # check to see what the input object is\n+    if isinstance(input_obj, sample.sample_set):\n+        input_sample_set = input_obj.copy()\n+    elif isinstance(input_obj, int):\n+        input_sample_set = sample.sample_set(input_obj)\n+    elif isinstance(input_obj, np.ndarray):\n+        input_sample_set = sample.sample_set(input_obj.shape[0])\n+        input_sample_set.set_domain(input_obj)\n+","path":"bet/sampling/basicSampling.py","position":60,"original_position":117,"commit_id":"736575f9dcbab336e4af73c4678497469fb15ba1","original_commit_id":"736575f9dcbab336e4af73c4678497469fb15ba1","user":{"login":"smattis","id":997385,"avatar_url":"https://avatars.githubusercontent.com/u/997385?v=3","gravatar_id":"","url":"https://api.github.com/users/smattis","html_url":"https://github.com/smattis","followers_url":"https://api.github.com/users/smattis/followers","following_url":"https://api.github.com/users/smattis/following{/other_user}","gists_url":"https://api.github.com/users/smattis/gists{/gist_id}","starred_url":"https://api.github.com/users/smattis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smattis/subscriptions","organizations_url":"https://api.github.com/users/smattis/orgs","repos_url":"https://api.github.com/users/smattis/repos","events_url":"https://api.github.com/users/smattis/events{/privacy}","received_events_url":"https://api.github.com/users/smattis/received_events","type":"User","site_admin":false},"body":"else raise exception. See simpleFunP","created_at":"2016-06-14T21:21:22Z","updated_at":"2016-06-14T21:21:22Z","html_url":"https://github.com/UT-CHG/BET/pull/215#discussion_r67059612","pull_request_url":"https://api.github.com/repos/UT-CHG/BET/pulls/215","_links":{"self":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/comments/67059612"},"html":{"href":"https://github.com/UT-CHG/BET/pull/215#discussion_r67059612"},"pull_request":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/215"}}},"pull_request":{"url":"https://api.github.com/repos/UT-CHG/BET/pulls/215","id":72894609,"html_url":"https://github.com/UT-CHG/BET/pull/215","diff_url":"https://github.com/UT-CHG/BET/pull/215.diff","patch_url":"https://github.com/UT-CHG/BET/pull/215.patch","issue_url":"https://api.github.com/repos/UT-CHG/BET/issues/215","number":215,"state":"open","locked":false,"title":"Updates examples and reduces redundancy","user":{"login":"lcgraham","id":3008749,"avatar_url":"https://avatars.githubusercontent.com/u/3008749?v=3","gravatar_id":"","url":"https://api.github.com/users/lcgraham","html_url":"https://github.com/lcgraham","followers_url":"https://api.github.com/users/lcgraham/followers","following_url":"https://api.github.com/users/lcgraham/following{/other_user}","gists_url":"https://api.github.com/users/lcgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/lcgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcgraham/subscriptions","organizations_url":"https://api.github.com/users/lcgraham/orgs","repos_url":"https://api.github.com/users/lcgraham/repos","events_url":"https://api.github.com/users/lcgraham/events{/privacy}","received_events_url":"https://api.github.com/users/lcgraham/received_events","type":"User","site_admin":false},"body":"Reduces redundancy in issue #186, updates examples in issue #167, removes extraneous file to resolve #185.\r\n\r\nIf this passes tests, then I will need to remove ``calculateP.calculateP.emulate_iid_lebesgue`` and update all of the examples accordingly.","created_at":"2016-06-07T15:17:54Z","updated_at":"2016-06-14T21:21:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cbb50ebea6fe86adccac6804b1c03920ae1c6a32","assignee":{"login":"smattis","id":997385,"avatar_url":"https://avatars.githubusercontent.com/u/997385?v=3","gravatar_id":"","url":"https://api.github.com/users/smattis","html_url":"https://github.com/smattis","followers_url":"https://api.github.com/users/smattis/followers","following_url":"https://api.github.com/users/smattis/following{/other_user}","gists_url":"https://api.github.com/users/smattis/gists{/gist_id}","starred_url":"https://api.github.com/users/smattis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smattis/subscriptions","organizations_url":"https://api.github.com/users/smattis/orgs","repos_url":"https://api.github.com/users/smattis/repos","events_url":"https://api.github.com/users/smattis/events{/privacy}","received_events_url":"https://api.github.com/users/smattis/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/UT-CHG/BET/milestones/3","html_url":"https://github.com/UT-CHG/BET/milestones/Release%20Version%202.0","labels_url":"https://api.github.com/repos/UT-CHG/BET/milestones/3/labels","id":1660978,"number":3,"title":"Release Version 2.0","description":"Complete changes to source, test, and examples. Update documentation to match. This is a major non-backward compatible code refactoring.","creator":{"login":"lcgraham","id":3008749,"avatar_url":"https://avatars.githubusercontent.com/u/3008749?v=3","gravatar_id":"","url":"https://api.github.com/users/lcgraham","html_url":"https://github.com/lcgraham","followers_url":"https://api.github.com/users/lcgraham/followers","following_url":"https://api.github.com/users/lcgraham/following{/other_user}","gists_url":"https://api.github.com/users/lcgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/lcgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcgraham/subscriptions","organizations_url":"https://api.github.com/users/lcgraham/orgs","repos_url":"https://api.github.com/users/lcgraham/repos","events_url":"https://api.github.com/users/lcgraham/events{/privacy}","received_events_url":"https://api.github.com/users/lcgraham/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":32,"state":"open","created_at":"2016-03-22T23:12:20Z","updated_at":"2016-06-14T19:00:58Z","due_on":"2016-06-17T06:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/UT-CHG/BET/pulls/215/commits","review_comments_url":"https://api.github.com/repos/UT-CHG/BET/pulls/215/comments","review_comment_url":"https://api.github.com/repos/UT-CHG/BET/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UT-CHG/BET/issues/215/comments","statuses_url":"https://api.github.com/repos/UT-CHG/BET/statuses/736575f9dcbab336e4af73c4678497469fb15ba1","head":{"label":"lcgraham:master","ref":"master","sha":"736575f9dcbab336e4af73c4678497469fb15ba1","user":{"login":"lcgraham","id":3008749,"avatar_url":"https://avatars.githubusercontent.com/u/3008749?v=3","gravatar_id":"","url":"https://api.github.com/users/lcgraham","html_url":"https://github.com/lcgraham","followers_url":"https://api.github.com/users/lcgraham/followers","following_url":"https://api.github.com/users/lcgraham/following{/other_user}","gists_url":"https://api.github.com/users/lcgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/lcgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcgraham/subscriptions","organizations_url":"https://api.github.com/users/lcgraham/orgs","repos_url":"https://api.github.com/users/lcgraham/repos","events_url":"https://api.github.com/users/lcgraham/events{/privacy}","received_events_url":"https://api.github.com/users/lcgraham/received_events","type":"User","site_admin":false},"repo":{"id":31794748,"name":"BET","full_name":"lcgraham/BET","owner":{"login":"lcgraham","id":3008749,"avatar_url":"https://avatars.githubusercontent.com/u/3008749?v=3","gravatar_id":"","url":"https://api.github.com/users/lcgraham","html_url":"https://github.com/lcgraham","followers_url":"https://api.github.com/users/lcgraham/followers","following_url":"https://api.github.com/users/lcgraham/following{/other_user}","gists_url":"https://api.github.com/users/lcgraham/gists{/gist_id}","starred_url":"https://api.github.com/users/lcgraham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcgraham/subscriptions","organizations_url":"https://api.github.com/users/lcgraham/orgs","repos_url":"https://api.github.com/users/lcgraham/repos","events_url":"https://api.github.com/users/lcgraham/events{/privacy}","received_events_url":"https://api.github.com/users/lcgraham/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lcgraham/BET","description":"Butler, Estep, Tavener Method - A python based package for measure-theoretic stochastic inverse and forward problems.","fork":true,"url":"https://api.github.com/repos/lcgraham/BET","forks_url":"https://api.github.com/repos/lcgraham/BET/forks","keys_url":"https://api.github.com/repos/lcgraham/BET/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lcgraham/BET/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lcgraham/BET/teams","hooks_url":"https://api.github.com/repos/lcgraham/BET/hooks","issue_events_url":"https://api.github.com/repos/lcgraham/BET/issues/events{/number}","events_url":"https://api.github.com/repos/lcgraham/BET/events","assignees_url":"https://api.github.com/repos/lcgraham/BET/assignees{/user}","branches_url":"https://api.github.com/repos/lcgraham/BET/branches{/branch}","tags_url":"https://api.github.com/repos/lcgraham/BET/tags","blobs_url":"https://api.github.com/repos/lcgraham/BET/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lcgraham/BET/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lcgraham/BET/git/refs{/sha}","trees_url":"https://api.github.com/repos/lcgraham/BET/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lcgraham/BET/statuses/{sha}","languages_url":"https://api.github.com/repos/lcgraham/BET/languages","stargazers_url":"https://api.github.com/repos/lcgraham/BET/stargazers","contributors_url":"https://api.github.com/repos/lcgraham/BET/contributors","subscribers_url":"https://api.github.com/repos/lcgraham/BET/subscribers","subscription_url":"https://api.github.com/repos/lcgraham/BET/subscription","commits_url":"https://api.github.com/repos/lcgraham/BET/commits{/sha}","git_commits_url":"https://api.github.com/repos/lcgraham/BET/git/commits{/sha}","comments_url":"https://api.github.com/repos/lcgraham/BET/comments{/number}","issue_comment_url":"https://api.github.com/repos/lcgraham/BET/issues/comments{/number}","contents_url":"https://api.github.com/repos/lcgraham/BET/contents/{+path}","compare_url":"https://api.github.com/repos/lcgraham/BET/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lcgraham/BET/merges","archive_url":"https://api.github.com/repos/lcgraham/BET/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lcgraham/BET/downloads","issues_url":"https://api.github.com/repos/lcgraham/BET/issues{/number}","pulls_url":"https://api.github.com/repos/lcgraham/BET/pulls{/number}","milestones_url":"https://api.github.com/repos/lcgraham/BET/milestones{/number}","notifications_url":"https://api.github.com/repos/lcgraham/BET/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lcgraham/BET/labels{/name}","releases_url":"https://api.github.com/repos/lcgraham/BET/releases{/id}","deployments_url":"https://api.github.com/repos/lcgraham/BET/deployments","created_at":"2015-03-07T00:04:04Z","updated_at":"2016-03-29T00:42:28Z","pushed_at":"2016-06-14T18:53:11Z","git_url":"git://github.com/lcgraham/BET.git","ssh_url":"git@github.com:lcgraham/BET.git","clone_url":"https://github.com/lcgraham/BET.git","svn_url":"https://github.com/lcgraham/BET","homepage":"http://ut-chg.github.io/BET","size":9397,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"UT-CHG:master","ref":"master","sha":"1ec3a9d1e133ebb5fd11aeeac2fb3cfde285dd8f","user":{"login":"UT-CHG","id":8753973,"avatar_url":"https://avatars.githubusercontent.com/u/8753973?v=3","gravatar_id":"","url":"https://api.github.com/users/UT-CHG","html_url":"https://github.com/UT-CHG","followers_url":"https://api.github.com/users/UT-CHG/followers","following_url":"https://api.github.com/users/UT-CHG/following{/other_user}","gists_url":"https://api.github.com/users/UT-CHG/gists{/gist_id}","starred_url":"https://api.github.com/users/UT-CHG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UT-CHG/subscriptions","organizations_url":"https://api.github.com/users/UT-CHG/orgs","repos_url":"https://api.github.com/users/UT-CHG/repos","events_url":"https://api.github.com/users/UT-CHG/events{/privacy}","received_events_url":"https://api.github.com/users/UT-CHG/received_events","type":"Organization","site_admin":false},"repo":{"id":18813599,"name":"BET","full_name":"UT-CHG/BET","owner":{"login":"UT-CHG","id":8753973,"avatar_url":"https://avatars.githubusercontent.com/u/8753973?v=3","gravatar_id":"","url":"https://api.github.com/users/UT-CHG","html_url":"https://github.com/UT-CHG","followers_url":"https://api.github.com/users/UT-CHG/followers","following_url":"https://api.github.com/users/UT-CHG/following{/other_user}","gists_url":"https://api.github.com/users/UT-CHG/gists{/gist_id}","starred_url":"https://api.github.com/users/UT-CHG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UT-CHG/subscriptions","organizations_url":"https://api.github.com/users/UT-CHG/orgs","repos_url":"https://api.github.com/users/UT-CHG/repos","events_url":"https://api.github.com/users/UT-CHG/events{/privacy}","received_events_url":"https://api.github.com/users/UT-CHG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UT-CHG/BET","description":"Butler, Estep, Tavener Method - A python based package for measure-theoretic stochastic inverse and forward problems.","fork":false,"url":"https://api.github.com/repos/UT-CHG/BET","forks_url":"https://api.github.com/repos/UT-CHG/BET/forks","keys_url":"https://api.github.com/repos/UT-CHG/BET/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UT-CHG/BET/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UT-CHG/BET/teams","hooks_url":"https://api.github.com/repos/UT-CHG/BET/hooks","issue_events_url":"https://api.github.com/repos/UT-CHG/BET/issues/events{/number}","events_url":"https://api.github.com/repos/UT-CHG/BET/events","assignees_url":"https://api.github.com/repos/UT-CHG/BET/assignees{/user}","branches_url":"https://api.github.com/repos/UT-CHG/BET/branches{/branch}","tags_url":"https://api.github.com/repos/UT-CHG/BET/tags","blobs_url":"https://api.github.com/repos/UT-CHG/BET/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UT-CHG/BET/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UT-CHG/BET/git/refs{/sha}","trees_url":"https://api.github.com/repos/UT-CHG/BET/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UT-CHG/BET/statuses/{sha}","languages_url":"https://api.github.com/repos/UT-CHG/BET/languages","stargazers_url":"https://api.github.com/repos/UT-CHG/BET/stargazers","contributors_url":"https://api.github.com/repos/UT-CHG/BET/contributors","subscribers_url":"https://api.github.com/repos/UT-CHG/BET/subscribers","subscription_url":"https://api.github.com/repos/UT-CHG/BET/subscription","commits_url":"https://api.github.com/repos/UT-CHG/BET/commits{/sha}","git_commits_url":"https://api.github.com/repos/UT-CHG/BET/git/commits{/sha}","comments_url":"https://api.github.com/repos/UT-CHG/BET/comments{/number}","issue_comment_url":"https://api.github.com/repos/UT-CHG/BET/issues/comments{/number}","contents_url":"https://api.github.com/repos/UT-CHG/BET/contents/{+path}","compare_url":"https://api.github.com/repos/UT-CHG/BET/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UT-CHG/BET/merges","archive_url":"https://api.github.com/repos/UT-CHG/BET/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UT-CHG/BET/downloads","issues_url":"https://api.github.com/repos/UT-CHG/BET/issues{/number}","pulls_url":"https://api.github.com/repos/UT-CHG/BET/pulls{/number}","milestones_url":"https://api.github.com/repos/UT-CHG/BET/milestones{/number}","notifications_url":"https://api.github.com/repos/UT-CHG/BET/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UT-CHG/BET/labels{/name}","releases_url":"https://api.github.com/repos/UT-CHG/BET/releases{/id}","deployments_url":"https://api.github.com/repos/UT-CHG/BET/deployments","created_at":"2014-04-15T19:51:31Z","updated_at":"2016-04-17T01:54:29Z","pushed_at":"2016-06-14T19:00:58Z","git_url":"git://github.com/UT-CHG/BET.git","ssh_url":"git@github.com:UT-CHG/BET.git","clone_url":"https://github.com/UT-CHG/BET.git","svn_url":"https://github.com/UT-CHG/BET","homepage":"http://ut-chg.github.io/BET","size":9389,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":17,"forks":11,"open_issues":17,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/215"},"html":{"href":"https://github.com/UT-CHG/BET/pull/215"},"issue":{"href":"https://api.github.com/repos/UT-CHG/BET/issues/215"},"comments":{"href":"https://api.github.com/repos/UT-CHG/BET/issues/215/comments"},"review_comments":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/215/comments"},"review_comment":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UT-CHG/BET/pulls/215/commits"},"statuses":{"href":"https://api.github.com/repos/UT-CHG/BET/statuses/736575f9dcbab336e4af73c4678497469fb15ba1"}}}}
{"actor":{"display_login":"smattis"}}