Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 20, 2025
1 parent 3aee573 commit 732fc15
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions python/src/moocore/_moocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,9 @@ def eafdiff(
"""
x = np.asarray(x, dtype=float)
y = np.asarray(y, dtype=float)
assert (
x.shape[1] == y.shape[1]
), "'x' and 'y' must have the same number of columns"
assert x.shape[1] == y.shape[1], (
"'x' and 'y' must have the same number of columns"
)
nobj = x.shape[1] - 1
assert nobj == 2
maximise = _parse_maximise(maximise, nobj=nobj)
Expand Down
36 changes: 18 additions & 18 deletions python/tests/test_moocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def test_read_datasets_data(test_datapath):

def check_testdata(testpath, expected_name, expected_shape):
testdata = moocore.read_datasets(testpath)
assert (
testdata.shape == expected_shape
), f"Read data array has incorrect shape, should be {expected_shape} but is {testdata.shape}"
assert testdata.shape == expected_shape, (
f"Read data array has incorrect shape, should be {expected_shape} but is {testdata.shape}"
)
if expected_name != "":
check_data = np.loadtxt(
test_datapath(f"expected_output/read_datasets/{expected_name}")
Expand Down Expand Up @@ -98,26 +98,26 @@ def test_hv_output(self, test_datapath):
X = self.input1
dat = X[X[:, 2] == 1, :2]
hv = moocore.hypervolume(dat, ref=np.array([10, 10]))
assert math.isclose(
hv, 90.46272765
), "input1.dat hypervolume produces wrong output"
assert math.isclose(hv, 90.46272765), (
"input1.dat hypervolume produces wrong output"
)

hv_ind = moocore.Hypervolume(ref=[10, 10])
hv = hv_ind(dat)
assert math.isclose(
hv, 90.46272765
), "input1.dat Hypervolume(ref = [10,10]) produces wrong output"
assert math.isclose(hv, 90.46272765), (
"input1.dat Hypervolume(ref = [10,10]) produces wrong output"
)

dat = X[X[:, 2] == 2, :2]
hv = moocore.hypervolume(dat, ref=[10, 10])
assert math.isclose(
hv, 53.969708954
), "input1.dat hypervolume produces wrong output"
assert math.isclose(hv, 53.969708954), (
"input1.dat hypervolume produces wrong output"
)

hv = hv_ind(dat)
assert math.isclose(
hv, 53.969708954
), "input1.dat Hypervolume(ref = [10,10]) produces wrong output"
assert math.isclose(hv, 53.969708954), (
"input1.dat Hypervolume(ref = [10,10]) produces wrong output"
)

X = moocore.read_datasets(test_datapath("duplicated3.inp"))[:, :-1]
hv = moocore.hypervolume(
Expand Down Expand Up @@ -282,9 +282,9 @@ def test_eaf(test_datapath):
expected_eaf_pct_result = np.loadtxt(
test_datapath(f"expected_output/eaf/pct_{expected_eaf_name}")
)
assert (
eaf_test.shape == expected_eaf_result.shape
), f"Shapes of {test_name} and {expected_eaf_name} do not match"
assert eaf_test.shape == expected_eaf_result.shape, (
f"Shapes of {test_name} and {expected_eaf_name} do not match"
)
assert_allclose(
eaf_test,
expected_eaf_result,
Expand Down

0 comments on commit 732fc15

Please sign in to comment.