{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10928","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10928/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10928/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10928/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/10928","id":311901591,"number":10928,"title":"Single, non-sequence element in dict leads to non-iterable ParameterGrid","user":{"login":"elDan101","id":8281969,"avatar_url":"https://avatars2.githubusercontent.com/u/8281969?v=4","gravatar_id":"","url":"https://api.github.com/users/elDan101","html_url":"https://github.com/elDan101","followers_url":"https://api.github.com/users/elDan101/followers","following_url":"https://api.github.com/users/elDan101/following{/other_user}","gists_url":"https://api.github.com/users/elDan101/gists{/gist_id}","starred_url":"https://api.github.com/users/elDan101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elDan101/subscriptions","organizations_url":"https://api.github.com/users/elDan101/orgs","repos_url":"https://api.github.com/users/elDan101/repos","events_url":"https://api.github.com/users/elDan101/events{/privacy}","received_events_url":"https://api.github.com/users/elDan101/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-06T09:08:42Z","updated_at":"2018-04-09T08:28:26Z","closed_at":null,"author_association":"NONE","body":"#### Description\r\nIf one element of the dict passed to ParameterGrid is not a sequence, then the object ParameterGrid is not iterable any more. I suggest that single elements are simply treated as an iterable (e.g. list) of 1 element -- unless there are good reasons for the current behavior I'm not aware of.    \r\n\r\n#### Steps/Code to Reproduce\r\n\r\n```python\r\nfrom sklearn.model_selection import ParameterGrid\r\n\r\n# normal behavior for comparison:\r\ng1 = ParameterGrid({\"x1\":[0,1,2], \"x2\":[0]})\r\nprint(g1.param_grid)\r\nprint(list(g1))\r\n\r\n# output:\r\n# [{'x1': [0, 1, 2], 'x2': [0]}]\r\n# [{'x1': 0, 'x2': 0}, {'x1': 1, 'x2': 0}, {'x1': 2, 'x2': 0}]\r\n\r\ng2 = ParameterGrid({\"x1\":[0,1,2], \"x2\":0})  # NOTE: the 0 is not in a list any more\r\nprint(g2.param_grid)\r\nprint(list(g2))\r\n\r\n# Output\r\n#[{'x1': [0, 1, 2], 'x2': 0}]\r\n\r\n#---------------------------------------------------------------------------\r\n#TypeError                                 Traceback (most recent call last)\r\n#<ipython-input-13-2bc4dd133ce1> in <module>()\r\n#     1 g2 = ParameterGrid({\"x1\":[0,1,2], \"x2\":0})\r\n#      2 print(g2.param_grid)\r\n#----> 3 print(list(g2))\r\n#\r\n#/usr/local/lib/python3.6/site-packages/sklearn/model_selection/_search.py in __iter__(self)\r\n#    113             else:\r\n#    114                 keys, values = zip(*items)\r\n#--> 115                 for v in product(*values):\r\n#    116                     params = dict(zip(keys, v))\r\n#    117                     yield params\r\n#\r\n#TypeError: 'int' object is not iterable\r\n```\r\n\r\n#### Expected Results\r\nI expect the same result for the second case as for the first case. The ParamGrid is not iterable any more in the second case and I expect it to be at least iterable. \r\n\r\n#### Versions\r\nLinux-4.13.0-38-generic-x86_64-with-debian-stretch-sid\r\nPython 3.6.1 (default, Jun 16 2017, 16:00:03) \r\n[GCC 5.4.0 20160609]\r\nNumPy 1.13.1\r\nSciPy 0.19.1\r\nScikit-Learn 0.19.1\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/379674908","html_url":"https://github.com/scikit-learn/scikit-learn/issues/10928#issuecomment-379674908","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/10928","id":379674908,"user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars2.githubusercontent.com/u/78827?v=4","gravatar_id":"","url":"https://api.github.com/users/jnothman","html_url":"https://github.com/jnothman","followers_url":"https://api.github.com/users/jnothman/followers","following_url":"https://api.github.com/users/jnothman/following{/other_user}","gists_url":"https://api.github.com/users/jnothman/gists{/gist_id}","starred_url":"https://api.github.com/users/jnothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jnothman/subscriptions","organizations_url":"https://api.github.com/users/jnothman/orgs","repos_url":"https://api.github.com/users/jnothman/repos","events_url":"https://api.github.com/users/jnothman/events{/privacy}","received_events_url":"https://api.github.com/users/jnothman/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T08:28:26Z","updated_at":"2018-04-09T08:28:26Z","author_association":"OWNER","body":"Lists and arrays are similarly ambiguous. I am -1. Explicit is better than implicit."}}
{"actor":{"display_login":"jnothman"}}