Skip to content

Commit

Permalink
Merge pull request scipy#8177 from andyfaff/gh8152
Browse files Browse the repository at this point in the history
MAINT: diffev small speedup in ensure constraint
  • Loading branch information
andyfaff authored Nov 20, 2017
2 parents 73f723a + c8d9cdc commit 018ff7a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions scipy/optimize/_differentialevolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,8 @@ def _ensure_constraint(self, trial):
"""
make sure the parameters lie between the limits
"""
for index, param in enumerate(trial):
if param > 1 or param < 0:
trial[index] = self.random_number_generator.rand()
for index in np.where((trial < 0) | (trial > 1))[0]:
trial[index] = self.random_number_generator.rand()

def _mutate(self, candidate):
"""
Expand Down

0 comments on commit 018ff7a

Please sign in to comment.