-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes a couple of bugs on negative and multiobjective black boxes (#164)
- Loading branch information
1 parent
1f5e92a
commit 33c6ae7
Showing
3 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/poli/tests/registry/test_multi_objective_and_negative.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import numpy as np | ||
|
||
|
||
def test_multi_objective_instantiation(): | ||
from poli.objective_repository import AlohaBlackBox | ||
from poli.core.multi_objective_black_box import MultiObjectiveBlackBox | ||
|
||
f_aloha = AlohaBlackBox() | ||
|
||
f = MultiObjectiveBlackBox( | ||
objective_functions=[f_aloha, f_aloha], | ||
) | ||
|
||
assert f.objective_functions == [f_aloha, f_aloha] | ||
|
||
x0 = np.array([["A", "B", "C", "D", "E"]]) | ||
y0 = f(x0) | ||
|
||
assert y0.shape == (1, 2) | ||
|
||
|
||
def test_negative_black_boxes(): | ||
from poli.objective_repository import AlohaBlackBox | ||
|
||
f = AlohaBlackBox() | ||
g = -f | ||
|
||
x0 = np.array([["A", "B", "C", "D", "E"]]) | ||
|
||
f0 = f(x0) | ||
g0 = g(x0) | ||
|
||
assert f0 == -g0 |