{"action":"opened","issue":{"url":"https://api.github.com/repos/numenta/nupic/issues/1950","labels_url":"https://api.github.com/repos/numenta/nupic/issues/1950/labels{/name}","comments_url":"https://api.github.com/repos/numenta/nupic/issues/1950/comments","events_url":"https://api.github.com/repos/numenta/nupic/issues/1950/events","html_url":"https://github.com/numenta/nupic/issues/1950","id":64326332,"number":1950,"title":"Add type checks with better error messages for encoders","user":{"login":"scottpurdy","id":239726,"avatar_url":"https://avatars.githubusercontent.com/u/239726?v=3","gravatar_id":"","url":"https://api.github.com/users/scottpurdy","html_url":"https://github.com/scottpurdy","followers_url":"https://api.github.com/users/scottpurdy/followers","following_url":"https://api.github.com/users/scottpurdy/following{/other_user}","gists_url":"https://api.github.com/users/scottpurdy/gists{/gist_id}","starred_url":"https://api.github.com/users/scottpurdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottpurdy/subscriptions","organizations_url":"https://api.github.com/users/scottpurdy/orgs","repos_url":"https://api.github.com/users/scottpurdy/repos","events_url":"https://api.github.com/users/scottpurdy/events{/privacy}","received_events_url":"https://api.github.com/users/scottpurdy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numenta/nupic/labels/cleanup","name":"cleanup","color":"c7def8"},{"url":"https://api.github.com/repos/numenta/nupic/labels/encoder","name":"encoder","color":"bfdadc"},{"url":"https://api.github.com/repos/numenta/nupic/labels/newbie","name":"newbie","color":"bfe5bf"},{"url":"https://api.github.com/repos/numenta/nupic/labels/P3","name":"P3","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-25T17:27:57Z","updated_at":"2015-03-25T17:27:57Z","closed_at":null,"body":"The encoders should check the format of the input and raise exceptions with clear descriptions of what the proper format is if the input isn't formatted correctly or doesn't use the right types. Here is an email chain from a NuPIC user that had trouble figuring out the input format for encoders:\r\n\r\n>Thanks Scott,\r\n>\r\n>The same if toy put ints but, as far as the audiostream is concerned, it uses it with float inpyts aparently, so that solution cant work. And it works if turned the input in\r\nto a list instaed of an numpy.array() ( it give another kind of error though, saying that the input isnt correct because of the window definition ).\r\n>\r\n>I already sent it to the mailing list ;). You can see the whole output there. Tell me if you recieved it in you mailing list ;)\r\n>\r\n>\r\n>2015-03-25 16:23 GMT+01:00 Scott Purdy <scott@fer.io>:\r\n>The input must contain booleans. So something like this:\r\n>\r\n>e = SparsePassThroughEncoder(51, 1)\r\n>input = numpy.zeros(51, dtype=\"bool\")\r\n>input[0] = 1\r\n>input[1] = 1\r\n>encoded = e.encode(input)\r\n>\r\n>And I'd recommend you send questions to the list since you will probably get much quicker responses.\r\n>\r\n>Best of luck!\r\n>\r\n>On Wed, Mar 25, 2015 at 5:16 AM, miguel angel rodriguez <duckfrost@gmail.com> wrote:\r\n>Hi,\r\n>\r\n>I started useing the NUPIC infraestructure some weeks ago and I just run into a problem that you might help:\r\n>\r\n>I executed the example audiostream and it gave me the error:\r\n>IndexError: arrays used as indices must be of integer (or boolean) type\r\n>\r\n>And I pinpointed the error to the line:\r\n>actualInt = self.e.encode(ufs)\r\n>So I executed just the SparsePassThroughEncoder but I cant make it work\r\n>properly either:\r\n>>>from nupic.encoders.sparse_pass_through_encoder import SparsePassThroughEncoder\r\n>>>e = SparsePassThroughEncoder(51, 1)\r\n>>>input = numpy.zeros(51)\r\n>>>input[0] = 2\r\n>>>input[1] = 12\r\n>>>actualInt = e.encode(input)\r\n>IndexError: arrays used as indices must be of integer (or boolean) type\r\n>\r\n>Any thoughts? Any insight would be much appreciated, thanks\r\n>\r\n>Miguel Angel Rodriguez"}}