Skip to content

Commit

Permalink
TST: vectorised violation call
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfaff committed Feb 8, 2024
1 parent 2972a0d commit 13739fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scipy/optimize/_differentialevolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ def fun(x):
if x.ndim == 1 and res.ndim == 2:
# deal with case that constraint.A is an np.matrix
# see gh20041
res = np.squeeze(np.asarray(res[:, 0]))
res = np.asarray(res)[:, 0]

return res
elif isinstance(constraint, Bounds):
Expand Down
5 changes: 5 additions & 0 deletions scipy/optimize/tests/test__differential_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,11 @@ def test_matrix_linear_constraint(self):
# of constraints applied.
assert cw.violation(x0).shape == (2,)

# let's try a vectorised violation call.
xtrial = np.arange(4 * 5).reshape(4, 5)
assert cw.violation(xtrial).shape == (2, 5)


def test_L1(self):
# Lampinen ([5]) test problem 1

Expand Down

0 comments on commit 13739fb

Please sign in to comment.