{"action":"created","comment":{"url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/comments/86069990","pull_request_review_id":6746390,"id":86069990,"diff_hunk":"@@ -175,46 +179,58 @@ def __init__(self, estimator, param_domains, n_iter=10, scoring=None,\n     def _create_sigopt_exp(self, conn):\n         est_name = self.estimator.__class__.__name__\n         exp_name = est_name + ' (sklearn)'\n+        # NOTE(Sam): This is not actually safe. There's no reason to believe that len(est_name) <= 50 in general.\n         if len(exp_name) > 50:\n             exp_name = est_name\n \n         if self.verbose > 0:\n             print('Creating SigOpt experiment: ', exp_name)\n \n-        # generate sigopt experiment parameters\n-        parameters = []\n-        for param_name in self.param_domains:\n-            bounds = self.param_domains[param_name]\n-            all_ints = all(isinstance(x, int) for x in bounds)\n-            all_floats = all(isinstance(x, float) for x in bounds)\n-            any_floats = any(isinstance(x, float) for x in bounds)\n-            all_strings = all(isinstance(x, str) for x in bounds)\n-\n-            # convert entire bounds to floats if one is present\n-            if any_floats:\n-                bounds = [float(b) for b in bounds]\n-                all_floats = True\n-\n-            types = ['double', 'int', 'categorical']\n-            bound_types = [all_floats, all_ints, all_strings]\n-            param_type = types[bound_types.index(True)]\n-\n-            param_dict = {}\n-            param_dict['name'] = param_name\n-            param_dict['type'] = param_type\n-\n-            if param_type == 'categorical':\n-                cat_vals = []\n-                for str_name in bounds:\n-                    cat_vals.append({'name': str_name})\n-                param_dict['categorical_values'] = cat_vals\n+        def _transform_param(param_name, param_bounds):\n+            \"\"\"Transform a parameter name and its bounds into a form that can be sent to the API layer.\"\"\"\n+            def _check_bounds():\n+                \"\"\"Check that min/max bounds are well formed.\"\"\"\n+                if len(param_bounds) != 2:\n+                    raise Exception('Parameter bounds must be specified with two numbers! Not sure what to do with {}.'\n+                                    .format(param_bounds))\n+                if not isinstance(param_bounds, tuple):\n+                    warnings.warn('Parameter bounds should be specified as a tuple in the form (min, max).')\n+\n+            param_dict = {'name': param_name}\n+            if isinstance(param_bounds, dict):\n+                # This is a categorical with mappings between strings and values\n+                param_dict['type'] = 'categorical'\n+                param_dict['categorical_values'] = [{'name': k} for k in param_bounds.keys()]\n+\n+                # Add this mapping to our set of categorical string mappings\n+                self.categorical_mappings_[param_name] = param_bounds\n+\n+            elif all(isinstance(x, str) for x in param_bounds):\n+                # This is a categorical with a list of strings naming each category\n+                param_dict['type'] = 'categorical'\n+                param_dict['categorical_values'] = [{'name': k} for k in param_bounds]\n+\n+            elif all(isinstance(x, int) for x in param_bounds):\n+                # This is an integer parameter\n+                _check_bounds()\n+                param_dict['type'] = 'int'\n+                param_dict['bounds'] = {'min': param_bounds[0], 'max': param_bounds[1]}\n+\n+            elif any(isinstance(x, float) for x in param_bounds):\n+                # This is a continuous parameter. Note that we use `any` since the user may pass some combination of\n+                # float and integer parameters, e.g. (0, 0.1).\n+                _check_bounds()\n+                param_dict['type'] = 'double'\n+                param_dict['bounds'] = {'min': param_bounds[0], 'max': param_bounds[1]}\n+\n             else:\n-                bmin = min(bounds)\n-                bmax = max(bounds)\n-                param_dict['bounds'] = {'min': bmin, 'max': bmax}\n+                # Not sure what the user gave us here\n+                raise Exception('Bad parameter range {}.'.format(param_bounds))","path":"sigopt_sklearn/search.py","position":107,"original_position":107,"commit_id":"4203b26d6a0eb7f218617831388516d5ea443794","original_commit_id":"4203b26d6a0eb7f218617831388516d5ea443794","user":{"login":"pfhayes","id":403100,"avatar_url":"https://avatars.githubusercontent.com/u/403100?v=3","gravatar_id":"","url":"https://api.github.com/users/pfhayes","html_url":"https://github.com/pfhayes","followers_url":"https://api.github.com/users/pfhayes/followers","following_url":"https://api.github.com/users/pfhayes/following{/other_user}","gists_url":"https://api.github.com/users/pfhayes/gists{/gist_id}","starred_url":"https://api.github.com/users/pfhayes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfhayes/subscriptions","organizations_url":"https://api.github.com/users/pfhayes/orgs","repos_url":"https://api.github.com/users/pfhayes/repos","events_url":"https://api.github.com/users/pfhayes/events{/privacy}","received_events_url":"https://api.github.com/users/pfhayes/received_events","type":"User","site_admin":false},"body":"might be worth checking that it's iterable before here, otherwise we'll get an exception when we call `all` or `any`","created_at":"2016-11-02T03:58:48Z","updated_at":"2016-11-02T04:00:32Z","html_url":"https://github.com/sigopt/sigopt_sklearn/pull/13#discussion_r86069990","pull_request_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/comments/86069990"},"html":{"href":"https://github.com/sigopt/sigopt_sklearn/pull/13#discussion_r86069990"},"pull_request":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13","id":91894306,"html_url":"https://github.com/sigopt/sigopt_sklearn/pull/13","diff_url":"https://github.com/sigopt/sigopt_sklearn/pull/13.diff","patch_url":"https://github.com/sigopt/sigopt_sklearn/pull/13.patch","issue_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/13","number":13,"state":"open","locked":false,"title":"Allow passing str -> value categoricals","user":{"login":"samuela","id":226872,"avatar_url":"https://avatars.githubusercontent.com/u/226872?v=3","gravatar_id":"","url":"https://api.github.com/users/samuela","html_url":"https://github.com/samuela","followers_url":"https://api.github.com/users/samuela/followers","following_url":"https://api.github.com/users/samuela/following{/other_user}","gists_url":"https://api.github.com/users/samuela/gists{/gist_id}","starred_url":"https://api.github.com/users/samuela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuela/subscriptions","organizations_url":"https://api.github.com/users/samuela/orgs","repos_url":"https://api.github.com/users/samuela/repos","events_url":"https://api.github.com/users/samuela/events{/privacy}","received_events_url":"https://api.github.com/users/samuela/received_events","type":"User","site_admin":false},"body":"re https://app.asana.com/0/38684300131201/204422011494821\r\ncc @pfhayes @alexandraj777 @iandewancker ","created_at":"2016-11-02T01:21:36Z","updated_at":"2016-11-02T04:00:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"879ec8f17f7db61cfa341e70628d3214293f13a7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13/commits","review_comments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13/comments","review_comment_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/13/comments","statuses_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/statuses/4203b26d6a0eb7f218617831388516d5ea443794","head":{"label":"sigopt:nonstring_cats","ref":"nonstring_cats","sha":"4203b26d6a0eb7f218617831388516d5ea443794","user":{"login":"sigopt","id":8949269,"avatar_url":"https://avatars.githubusercontent.com/u/8949269?v=3","gravatar_id":"","url":"https://api.github.com/users/sigopt","html_url":"https://github.com/sigopt","followers_url":"https://api.github.com/users/sigopt/followers","following_url":"https://api.github.com/users/sigopt/following{/other_user}","gists_url":"https://api.github.com/users/sigopt/gists{/gist_id}","starred_url":"https://api.github.com/users/sigopt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigopt/subscriptions","organizations_url":"https://api.github.com/users/sigopt/orgs","repos_url":"https://api.github.com/users/sigopt/repos","events_url":"https://api.github.com/users/sigopt/events{/privacy}","received_events_url":"https://api.github.com/users/sigopt/received_events","type":"Organization","site_admin":false},"repo":{"id":56349398,"name":"sigopt_sklearn","full_name":"sigopt/sigopt_sklearn","owner":{"login":"sigopt","id":8949269,"avatar_url":"https://avatars.githubusercontent.com/u/8949269?v=3","gravatar_id":"","url":"https://api.github.com/users/sigopt","html_url":"https://github.com/sigopt","followers_url":"https://api.github.com/users/sigopt/followers","following_url":"https://api.github.com/users/sigopt/following{/other_user}","gists_url":"https://api.github.com/users/sigopt/gists{/gist_id}","starred_url":"https://api.github.com/users/sigopt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigopt/subscriptions","organizations_url":"https://api.github.com/users/sigopt/orgs","repos_url":"https://api.github.com/users/sigopt/repos","events_url":"https://api.github.com/users/sigopt/events{/privacy}","received_events_url":"https://api.github.com/users/sigopt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sigopt/sigopt_sklearn","description":"SigOpt wrappers for scikit-learn methods","fork":false,"url":"https://api.github.com/repos/sigopt/sigopt_sklearn","forks_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/forks","keys_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/teams","hooks_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/hooks","issue_events_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/events{/number}","events_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/events","assignees_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/assignees{/user}","branches_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/branches{/branch}","tags_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/tags","blobs_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/statuses/{sha}","languages_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/languages","stargazers_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/stargazers","contributors_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/contributors","subscribers_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/subscribers","subscription_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/subscription","commits_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/contents/{+path}","compare_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/merges","archive_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/downloads","issues_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues{/number}","pulls_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls{/number}","milestones_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/milestones{/number}","notifications_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/labels{/name}","releases_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/releases{/id}","deployments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/deployments","created_at":"2016-04-15T20:58:39Z","updated_at":"2016-10-17T06:48:09Z","pushed_at":"2016-11-02T01:21:36Z","git_url":"git://github.com/sigopt/sigopt_sklearn.git","ssh_url":"git@github.com:sigopt/sigopt_sklearn.git","clone_url":"https://github.com/sigopt/sigopt_sklearn.git","svn_url":"https://github.com/sigopt/sigopt_sklearn","homepage":"","size":77,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":37,"default_branch":"master"}},"base":{"label":"sigopt:master","ref":"master","sha":"ecbd7eebaa22e5d0dd6e3c08bf8edc93c804d579","user":{"login":"sigopt","id":8949269,"avatar_url":"https://avatars.githubusercontent.com/u/8949269?v=3","gravatar_id":"","url":"https://api.github.com/users/sigopt","html_url":"https://github.com/sigopt","followers_url":"https://api.github.com/users/sigopt/followers","following_url":"https://api.github.com/users/sigopt/following{/other_user}","gists_url":"https://api.github.com/users/sigopt/gists{/gist_id}","starred_url":"https://api.github.com/users/sigopt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigopt/subscriptions","organizations_url":"https://api.github.com/users/sigopt/orgs","repos_url":"https://api.github.com/users/sigopt/repos","events_url":"https://api.github.com/users/sigopt/events{/privacy}","received_events_url":"https://api.github.com/users/sigopt/received_events","type":"Organization","site_admin":false},"repo":{"id":56349398,"name":"sigopt_sklearn","full_name":"sigopt/sigopt_sklearn","owner":{"login":"sigopt","id":8949269,"avatar_url":"https://avatars.githubusercontent.com/u/8949269?v=3","gravatar_id":"","url":"https://api.github.com/users/sigopt","html_url":"https://github.com/sigopt","followers_url":"https://api.github.com/users/sigopt/followers","following_url":"https://api.github.com/users/sigopt/following{/other_user}","gists_url":"https://api.github.com/users/sigopt/gists{/gist_id}","starred_url":"https://api.github.com/users/sigopt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigopt/subscriptions","organizations_url":"https://api.github.com/users/sigopt/orgs","repos_url":"https://api.github.com/users/sigopt/repos","events_url":"https://api.github.com/users/sigopt/events{/privacy}","received_events_url":"https://api.github.com/users/sigopt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sigopt/sigopt_sklearn","description":"SigOpt wrappers for scikit-learn methods","fork":false,"url":"https://api.github.com/repos/sigopt/sigopt_sklearn","forks_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/forks","keys_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/teams","hooks_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/hooks","issue_events_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/events{/number}","events_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/events","assignees_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/assignees{/user}","branches_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/branches{/branch}","tags_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/tags","blobs_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/statuses/{sha}","languages_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/languages","stargazers_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/stargazers","contributors_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/contributors","subscribers_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/subscribers","subscription_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/subscription","commits_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/contents/{+path}","compare_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/merges","archive_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/downloads","issues_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues{/number}","pulls_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls{/number}","milestones_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/milestones{/number}","notifications_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/labels{/name}","releases_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/releases{/id}","deployments_url":"https://api.github.com/repos/sigopt/sigopt_sklearn/deployments","created_at":"2016-04-15T20:58:39Z","updated_at":"2016-10-17T06:48:09Z","pushed_at":"2016-11-02T01:21:36Z","git_url":"git://github.com/sigopt/sigopt_sklearn.git","ssh_url":"git@github.com:sigopt/sigopt_sklearn.git","clone_url":"https://github.com/sigopt/sigopt_sklearn.git","svn_url":"https://github.com/sigopt/sigopt_sklearn","homepage":"","size":77,"stargazers_count":37,"watchers_count":37,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13"},"html":{"href":"https://github.com/sigopt/sigopt_sklearn/pull/13"},"issue":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/13"},"comments":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/sigopt/sigopt_sklearn/statuses/4203b26d6a0eb7f218617831388516d5ea443794"}}}}
{"actor":{"display_login":"pfhayes"}}