Repository: salib/salib
Issue: Array size off by one in morris optimal trajectories

From @saroele ...

```
And then I have some bad news: I get a bug when trying ``optimal_trajectories=4``. 
With 2, 3 and 5 it works (the latter takes a LOT of time though, but that is documented).  

# Generate samples 
param_values = Morris(os.path.join('results','parameters_'+s_id+'.txt'), 
                  samples=100,
                  num_levels=num_levels, 
                  grid_jump=grid_jump,
                  optimal_trajectories=4)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-be5a7e2544a6> in <module>()
      4                       num_levels=num_levels,
      5                       grid_jump=grid_jump,
----> 6                       optimal_trajectories=4)
      7 #print param_values
      8 

/home/roel/data/work/SALib/SALib/sample/morris.pyc in __init__(self, parameter_file, samples, num_levels, grid_jump, group_file, optimal_trajectories)
     62         if self.groups is None:
     63 
---> 64             self.create_sample()
     65 
     66         else:

/home/roel/data/work/SALib/SALib/sample/morris.pyc in create_sample(self)
    129                                                          self.samples,
    130                                                          self.num_vars,
--> 131                                                          self.optimal_trajectories)
    132 
    133         self.output_sample = optimal_sample

/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_optimum_trajectories(input_sample, N, num_params, k_choices)
    132                                N,
    133                                num_params,
--> 134                                k_choices)
    135 
    136     index_list = []

/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_most_distant(input_sample, N, num_params, k_choices)
     72 
     73     for combos in grouper(chunk, combo_gen):
---> 74         scores[(counter*chunk):((counter+1)*chunk)] = mappable(combos, pairwise, distance_matrix)
     75         counter += 1
     76     return scores

ValueError: could not broadcast input array from shape (921225) into shape (921224)
```

Another example ...

```
Similar bug with a different combination : 
 # Generate samples 
 param_values = Morris(os.path.join('results','parameters_'+s_id+'.txt'), 
                  samples=200,
                  num_levels=num_levels, 
                  grid_jump=grid_jump,
                  optimal_trajectories=3)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-32-40d2028baf35> in <module>()
      4                       num_levels=num_levels,
      5                       grid_jump=grid_jump,
----> 6                       optimal_trajectories=3)
      7 #print param_values
      8 

/home/roel/data/work/SALib/SALib/sample/morris.pyc in __init__(self, parameter_file, samples, num_levels, grid_jump, group_file, optimal_trajectories)
     62         if self.groups is None:
     63 
---> 64             self.create_sample()
     65 
     66         else:

/home/roel/data/work/SALib/SALib/sample/morris.pyc in create_sample(self)
    129                                                          self.samples,
    130                                                          self.num_vars,
--> 131                                                          self.optimal_trajectories)
    132 
    133         self.output_sample = optimal_sample

/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_optimum_trajectories(input_sample, N, num_params, k_choices)
    132                                N,
    133                                num_params,
--> 134                                k_choices)
    135 
    136     index_list = []

/home/roel/data/work/SALib/SALib/sample/morris_optimal.pyc in find_most_distant(input_sample, N, num_params, k_choices)
     72 
     73     for combos in grouper(chunk, combo_gen):
---> 74         scores[(counter*chunk):((counter+1)*chunk)] = mappable(combos, pairwise, distance_matrix)
     75         counter += 1
     76     return scores

ValueError: could not broadcast input array from shape (313400) into shape (313399)
```


Changed files:
setup.py

diff --git a/setup.py b/setup.py
index 3e133fe..4ef8488 100644
--- a/setup.py
+++ b/setup.py
@@ -35,7 +35,7 @@ def setup_package():
         license=open('LICENSE.md').read(),
         tests_require=['nose'],
         install_requires=[
-            "numpy",
+            "numpy>1.7",
             "scipy",
         ],
         # Two arguments required by Versioneer