{"action":"created","issue":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6855","repository_url":"https://api.github.com/repos/scikit-learn/scikit-learn","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6855/labels{/name}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6855/comments","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6855/events","html_url":"https://github.com/scikit-learn/scikit-learn/issues/6855","id":158268828,"number":6855,"title":"base.clone fails if estimator has dia_matrix as parametr","user":{"login":"nileracecrew","id":12072865,"avatar_url":"https://avatars.githubusercontent.com/u/12072865?v=3","gravatar_id":"","url":"https://api.github.com/users/nileracecrew","html_url":"https://github.com/nileracecrew","followers_url":"https://api.github.com/users/nileracecrew/followers","following_url":"https://api.github.com/users/nileracecrew/following{/other_user}","gists_url":"https://api.github.com/users/nileracecrew/gists{/gist_id}","starred_url":"https://api.github.com/users/nileracecrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nileracecrew/subscriptions","organizations_url":"https://api.github.com/users/nileracecrew/orgs","repos_url":"https://api.github.com/users/nileracecrew/repos","events_url":"https://api.github.com/users/nileracecrew/events{/privacy}","received_events_url":"https://api.github.com/users/nileracecrew/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-03T00:35:07Z","updated_at":"2016-06-03T02:11:26Z","closed_at":null,"body":"<!--\r\nIf your issue is a usage question, submit it here instead:\r\n- StackOverflow with the scikit-learn tag: http://stackoverflow.com/questions/tagged/scikit-learn\r\n- Mailing List: https://mail.python.org/mailman/listinfo/scikit-learn\r\nFor more information, see User Questions: http://scikit-learn.org/stable/support.html#user-questions\r\n-->\r\n\r\n<!-- Instructions For Filing a Bug: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#filing-bugs -->\r\n\r\n#### Description\r\n<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluate_every > 0-->\r\n\r\nIf an estimator has a scipy.sparse.dia_matrix as a parameter, the equality test in clone fails. It looks like this is because dia_matrix.data is a (1,n) ndarray, while most (all?) other sparse types are (n,) ndarrays.\r\n\r\n#### Steps/Code to Reproduce\r\n\r\n```\r\nimport sklearn.base\r\nimport scipy.sparse\r\nimport numpy as np\r\n\r\nclass DiaEstimator(sklearn.base.BaseEstimator):\r\n\tdef __init__(self, p=None):\r\n\t\tself.p = p\r\n\r\n\tdef transform(self, X, y=None):\r\n\t\treturn X\r\n\r\n\tdef fit(self, X, y=None):\r\n\t\treturn self\r\n\r\nM = scipy.sparse.csr_matrix(np.diag([1,2,3]))\r\ne = DiaEstimator(p=M)\r\n# works fine\r\nsklearn.base.clone(e)\r\n\r\nM = scipy.sparse.dia_matrix(np.diag([1,2,3]))\r\ne = DiaEstimator(p=M)\r\n# fails\r\nsklearn.base.clone(e)\r\n\r\n\"\"\"\r\nTraceback (most recent call last):\r\n  File \"diabug.py\", line 23, in <module>\r\n    sklearn.base.clone(e)\r\n  File \"/Users/elawrence/anaconda/lib/python2.7/site-packages/sklearn/base.py\", line 90, in clone\r\n    and param1.data[0] == param2.data[0]\r\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\r\n\"\"\"\r\n```\r\n\r\n#### Versions\r\n```\r\nIn [7]: import platform; print(platform.platform())\r\nDarwin-15.5.0-x86_64-i386-64bit\r\n\r\nIn [8]: import sys; print(\"Python\", sys.version)\r\n('Python', '2.7.11 |Anaconda custom (x86_64)| (default, Dec  6 2015, 18:57:58) \\n[GCC 4.2.1 (Apple Inc. build 5577)]')\r\n\r\nIn [9]: import numpy; print(\"NumPy\", numpy.__version__)\r\n('NumPy', '1.10.4')\r\n\r\nIn [10]: import scipy; print(\"SciPy\", scipy.__version__)\r\n('SciPy', '0.17.0')\r\n\r\nIn [11]: import sklearn; print(\"Scikit-Learn\", sklearn.__version__)\r\n('Scikit-Learn', '0.17')\r\n```"},"comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments/223473840","html_url":"https://github.com/scikit-learn/scikit-learn/issues/6855#issuecomment-223473840","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/6855","id":223473840,"user":{"login":"jnothman","id":78827,"avatar_url":"https://avatars.githubusercontent.com/u/78827?v=3","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":"2016-06-03T02:11:26Z","updated_at":"2016-06-03T02:11:26Z","body":"Could use param.data.flat here to include diagonal and bsr matrices. That fix won't suffice, I think, for LIL or DOK."}}
{"actor":{"display_login":"jnothman"}}