1+ import numpy as np
2+ from spotpython .mo .pareto import is_pareto_efficient
3+
4+ def test_is_pareto_efficient_minimize ():
5+ costs = np .array ([[1 , 2 ], [2 , 1 ], [3 , 3 ], [1.5 , 1.5 ]])
6+ expected = np .array ([True , True , False , True ])
7+ result = is_pareto_efficient (costs , minimize = True )
8+ assert np .array_equal (result , expected ), f"Expected { expected } , but got { result } "
9+
10+ def test_is_pareto_efficient_maximize ():
11+ costs = np .array ([[1 , 2 ], [2 , 1 ], [3 , 3 ], [1.5 , 1.5 ]])
12+ expected = np .array ([False , False , True , False ])
13+ result = is_pareto_efficient (costs , minimize = False )
14+ assert np .array_equal (result , expected ), f"Expected { expected } , but got { result } "
15+
16+ def test_is_pareto_efficient_single_point ():
17+ costs = np .array ([[1 , 2 ]])
18+ expected = np .array ([True ])
19+ result = is_pareto_efficient (costs , minimize = True )
20+ assert np .array_equal (result , expected ), f"Expected { expected } , but got { result } "
21+
22+ def test_is_pareto_efficient_identical_points ():
23+ costs = np .array ([[1 , 2 ], [1 , 2 ], [1 , 2 ]])
24+ expected = np .array ([True , False , False ])
25+ result = is_pareto_efficient (costs , minimize = True )
26+ assert np .array_equal (result , expected ), f"Expected { expected } , but got { result } "
27+
28+ def test_is_pareto_efficient_empty_input ():
29+ costs = np .array ([])
30+ expected = np .array ([])
31+ result = is_pareto_efficient (costs , minimize = True )
32+ assert np .array_equal (result , expected ), f"Expected { expected } , but got { result } "
0 commit comments