{"action":"created","issue":{"url":"https://api.github.com/repos/jdherman/SALib/issues/27","labels_url":"https://api.github.com/repos/jdherman/SALib/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/jdherman/SALib/issues/27/comments","events_url":"https://api.github.com/repos/jdherman/SALib/issues/27/events","html_url":"https://github.com/jdherman/SALib/issues/27","id":51323977,"number":27,"title":"Array size off by one in morris optimal trajectories","user":{"login":"jdherman","id":1936620,"avatar_url":"https://avatars.githubusercontent.com/u/1936620?v=3","gravatar_id":"","url":"https://api.github.com/users/jdherman","html_url":"https://github.com/jdherman","followers_url":"https://api.github.com/users/jdherman/followers","following_url":"https://api.github.com/users/jdherman/following{/other_user}","gists_url":"https://api.github.com/users/jdherman/gists{/gist_id}","starred_url":"https://api.github.com/users/jdherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdherman/subscriptions","organizations_url":"https://api.github.com/users/jdherman/orgs","repos_url":"https://api.github.com/users/jdherman/repos","events_url":"https://api.github.com/users/jdherman/events{/privacy}","received_events_url":"https://api.github.com/users/jdherman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-12-08T16:50:56Z","updated_at":"2015-01-30T20:44:03Z","closed_at":null,"body":"From @saroele ...\r\n\r\n```\r\nAnd then I have some bad news: I get a bug when trying ``optimal_trajectories=4``. \r\nWith 2, 3 and 5 it works (the latter takes a LOT of time though, but that is documented).  \r\n\r\n# Generate samples \r\nparam_values = Morris(os.path.join('results','parameters_'+s_id+'.txt'), \r\n                  samples=100,\r\n                  num_levels=num_levels, \r\n                  grid_jump=grid_jump,\r\n                  optimal_trajectories=4)\r\n\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-22-be5a7e2544a6> in <module>()\r\n      4                       num_levels=num_levels,\r\n      5                       grid_jump=grid_jump,\r\n----> 6                       optimal_trajectories=4)\r\n      7 #print param_values\r\n      8 \r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris.pyc in __init__(self, parameter_file, samples, num_levels, grid_jump, group_file, optimal_trajectories)\r\n     62         if self.groups is None:\r\n     63 \r\n---> 64             self.create_sample()\r\n     65 \r\n     66         else:\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris.pyc in create_sample(self)\r\n    129                                                          self.samples,\r\n    130                                                          self.num_vars,\r\n--> 131                                                          self.optimal_trajectories)\r\n    132 \r\n    133         self.output_sample = optimal_sample\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_optimum_trajectories(input_sample, N, num_params, k_choices)\r\n    132                                N,\r\n    133                                num_params,\r\n--> 134                                k_choices)\r\n    135 \r\n    136     index_list = []\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_most_distant(input_sample, N, num_params, k_choices)\r\n     72 \r\n     73     for combos in grouper(chunk, combo_gen):\r\n---> 74         scores[(counter*chunk):((counter+1)*chunk)] = mappable(combos, pairwise, distance_matrix)\r\n     75         counter += 1\r\n     76     return scores\r\n\r\nValueError: could not broadcast input array from shape (921225) into shape (921224)\r\n```\r\n\r\nAnother example ...\r\n\r\n```\r\nSimilar bug with a different combination : \r\n # Generate samples \r\n param_values = Morris(os.path.join('results','parameters_'+s_id+'.txt'), \r\n                  samples=200,\r\n                  num_levels=num_levels, \r\n                  grid_jump=grid_jump,\r\n                  optimal_trajectories=3)\r\n\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-32-40d2028baf35> in <module>()\r\n      4                       num_levels=num_levels,\r\n      5                       grid_jump=grid_jump,\r\n----> 6                       optimal_trajectories=3)\r\n      7 #print param_values\r\n      8 \r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris.pyc in __init__(self, parameter_file, samples, num_levels, grid_jump, group_file, optimal_trajectories)\r\n     62         if self.groups is None:\r\n     63 \r\n---> 64             self.create_sample()\r\n     65 \r\n     66         else:\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris.pyc in create_sample(self)\r\n    129                                                          self.samples,\r\n    130                                                          self.num_vars,\r\n--> 131                                                          self.optimal_trajectories)\r\n    132 \r\n    133         self.output_sample = optimal_sample\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_optimum_trajectories(input_sample, N, num_params, k_choices)\r\n    132                                N,\r\n    133                                num_params,\r\n--> 134                                k_choices)\r\n    135 \r\n    136     index_list = []\r\n\r\n/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_most_distant(input_sample, N, num_params, k_choices)\r\n     72 \r\n     73     for combos in grouper(chunk, combo_gen):\r\n---> 74         scores[(counter*chunk):((counter+1)*chunk)] = mappable(combos, pairwise, distance_matrix)\r\n     75         counter += 1\r\n     76     return scores\r\n\r\nValueError: could not broadcast input array from shape (313400) into shape (313399)\r\n```"},"comment":{"url":"https://api.github.com/repos/jdherman/SALib/issues/comments/72267237","html_url":"https://github.com/jdherman/SALib/issues/27#issuecomment-72267237","issue_url":"https://api.github.com/repos/jdherman/SALib/issues/27","id":72267237,"user":{"login":"jdherman","id":1936620,"avatar_url":"https://avatars.githubusercontent.com/u/1936620?v=3","gravatar_id":"","url":"https://api.github.com/users/jdherman","html_url":"https://github.com/jdherman","followers_url":"https://api.github.com/users/jdherman/followers","following_url":"https://api.github.com/users/jdherman/following{/other_user}","gists_url":"https://api.github.com/users/jdherman/gists{/gist_id}","starred_url":"https://api.github.com/users/jdherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdherman/subscriptions","organizations_url":"https://api.github.com/users/jdherman/orgs","repos_url":"https://api.github.com/users/jdherman/repos","events_url":"https://api.github.com/users/jdherman/events{/privacy}","received_events_url":"https://api.github.com/users/jdherman/received_events","type":"User","site_admin":false},"created_at":"2015-01-30T20:44:03Z","updated_at":"2015-01-30T20:44:03Z","body":"Hi @saroele -- happy new year! Did this array size issue continue to be a problem for you? If so, could you share your parameter file and the inputs you're using for this function call?\r\n```python\r\nparam_values = Morris(os.path.join('results','parameters_'+s_id+'.txt'), \r\n                  samples=100,\r\n                  num_levels=num_levels, \r\n                  grid_jump=grid_jump,\r\n                  optimal_trajectories=4)\r\n```\r\nI'll try to reproduce it. As an aside, the Morris API is back to a single `sample()` function rather than a class. [Here's an example](https://github.com/jdherman/SALib/blob/master/examples/morris/morris.py). Shouldn't have any effect on this bug, though."}}