@@ -405,28 +405,24 @@ def compare(val_a, val_b):
405405 "pop_f, pop_g, expected_indices_options" ,
406406 [
407407 # Two individuals in different ranks
408- (
409- np .array ([[1.0 , 2.0 ], [2.0 , 3.0 ]]),
410- None ,
411- [np .array ([1 , 0 ])]
412- ),
408+ (np .array ([[1.0 , 2.0 ], [2.0 , 3.0 ]]), None , [np .array ([1 , 0 ])]),
413409 # Non-dominated, different crowding distances
414410 (
415411 np .array ([[1.0 , 3.0 ], [2.0 , 2.0 ], [3.0 , 1.0 ]]),
416412 None ,
417- [np .array ([1 , 2 , 0 ]), np .array ([1 , 0 , 2 ])]
413+ [np .array ([1 , 2 , 0 ]), np .array ([1 , 0 , 2 ])],
418414 ),
419415 # NaN values
420416 (
421417 np .array ([[1.0 , 2.0 ], [np .nan , 3.0 ], [2.0 , 1.0 ]]),
422418 None ,
423- [np .array ([1 , 2 , 0 ]), np .array ([1 , 0 , 2 ])]
419+ [np .array ([1 , 2 , 0 ]), np .array ([1 , 0 , 2 ])],
424420 ),
425421 # Constrained
426422 (
427423 np .array ([[2.0 , 2.0 ], [1.0 , 1.0 ]]),
428424 np .array ([[- 1.0 , - 1.0 ], [1.0 , - 1.0 ]]),
429- [np .array ([1 , 0 ])]
425+ [np .array ([1 , 0 ])],
430426 ),
431427 # Multiple individuals with same rank but potentially same crowding distances
432428 (
@@ -437,26 +433,26 @@ def compare(val_a, val_b):
437433 np .array ([1 , 3 , 2 , 0 ]),
438434 np .array ([3 , 1 , 0 , 2 ]),
439435 np .array ([1 , 3 , 0 , 2 ]),
440- ]
436+ ],
441437 ),
442438 # NaN values and constraints
443439 (
444440 np .array ([[1.0 , 2.0 ], [np .nan , 3.0 ], [2.0 , 1.0 ]]),
445441 np .array ([[- 1.0 , - 1.0 , - 1.0 ], [0.0 , 0.0 , 0.0 ], [1.0 , 0.0 , 0.0 ]]),
446- [np .array ([1 , 2 , 0 ])]
442+ [np .array ([1 , 2 , 0 ])],
447443 ),
448444 # All NaN
449445 (
450446 np .array ([[np .nan , np .nan ], [np .nan , np .nan ]]),
451447 None ,
452- [np .array ([0 , 1 ]), np .array ([1 , 0 ])]
448+ [np .array ([0 , 1 ]), np .array ([1 , 0 ])],
453449 ),
454450 ],
455451)
456452def test_crowded_comparison_argsort (pop_f , pop_g , expected_indices_options ):
457453 """
458454 Test the crowded_comparison_argsort function with various explicit input.
459-
455+
460456 Parameters
461457 ----------
462458 pop_f : numpy.ndarray
@@ -468,10 +464,12 @@ def test_crowded_comparison_argsort(pop_f, pop_g, expected_indices_options):
468464 """
469465 # Call the function
470466 result = crowded_comparison_argsort (pop_f , pop_g )
471-
467+
472468 # Check if the result matches any of the expected options
473- matches_any = any (np .array_equal (result , expected ) for expected in expected_indices_options )
474-
469+ matches_any = any (
470+ np .array_equal (result , expected ) for expected in expected_indices_options
471+ )
472+
475473 if not matches_any :
476474 message = (
477475 f"Result { result } doesn't match any expected ordering.\n "
0 commit comments