{"action":"created","issue":{"url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/585","labels_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/585/labels{/name}","comments_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/585/comments","events_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/585/events","html_url":"https://github.com/markovmodel/PyEMMA/issues/585","id":113049033,"number":585,"title":"featurizer._pair_wise_input uses itertools.combinations","user":{"login":"marscher","id":170287,"avatar_url":"https://avatars.githubusercontent.com/u/170287?v=3","gravatar_id":"","url":"https://api.github.com/users/marscher","html_url":"https://github.com/marscher","followers_url":"https://api.github.com/users/marscher/followers","following_url":"https://api.github.com/users/marscher/following{/other_user}","gists_url":"https://api.github.com/users/marscher/gists{/gist_id}","starred_url":"https://api.github.com/users/marscher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marscher/subscriptions","organizations_url":"https://api.github.com/users/marscher/orgs","repos_url":"https://api.github.com/users/marscher/repos","events_url":"https://api.github.com/users/marscher/events{/privacy}","received_events_url":"https://api.github.com/users/marscher/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/markovmodel/PyEMMA/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-23T15:58:56Z","updated_at":"2015-10-27T15:15:22Z","closed_at":null,"body":"This function is intended to iterate over the output (generator pattern), but to create an index array it is prohibitively memory consuming, since the intermediate has to be converted to a Python list (which will create a Python object for every index involved in the pairing).\r\n\r\nThere must be a simple pure numpy solution to this."},"comment":{"url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/comments/151536750","html_url":"https://github.com/markovmodel/PyEMMA/issues/585#issuecomment-151536750","issue_url":"https://api.github.com/repos/markovmodel/PyEMMA/issues/585","id":151536750,"user":{"login":"marscher","id":170287,"avatar_url":"https://avatars.githubusercontent.com/u/170287?v=3","gravatar_id":"","url":"https://api.github.com/users/marscher","html_url":"https://github.com/marscher","followers_url":"https://api.github.com/users/marscher/followers","following_url":"https://api.github.com/users/marscher/following{/other_user}","gists_url":"https://api.github.com/users/marscher/gists{/gist_id}","starred_url":"https://api.github.com/users/marscher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marscher/subscriptions","organizations_url":"https://api.github.com/users/marscher/orgs","repos_url":"https://api.github.com/users/marscher/repos","events_url":"https://api.github.com/users/marscher/events{/privacy}","received_events_url":"https://api.github.com/users/marscher/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T15:15:22Z","updated_at":"2015-10-27T15:15:22Z","body":"``` python\r\ncontact_pairs_npy = np.transpose([np.tile(x, len(y)), numpy.repeat(y, len(x))])\r\ncontact_pairs_iter =  np.array([pair for pair in itertools.product(x,y)])\r\n\r\nassert np.all( contact_pairs_npy == contact_pairs_iter)\r\n\r\n%timeit np.transpose([np.tile(x, len(y)), numpy.repeat(y, len(x))])\r\n1000 loops, best of 3: 1.83 ms per loop\r\n\r\n%timeit contact_pairs_iter =  np.array([pair for pair in itertools.product(x,y)])\r\n10 loops, best of 3: 59.8 ms per loop\r\n```\r\n\r\nThe timing is negligible but the memory consumption of the numpy version is much lower than the pythonic one.\r\n\r\n\r\n"}}