1414
1515import re
1616from math import isfinite
17- from typing import List , Optional , Tuple , Union
17+ from typing import List , Optional , Tuple , Union , Any
1818
1919import numpy as np
2020from pygmo import s_policy , select_best
3535
3636
3737def _get_constraint_violation (
38- f : Union [list , np .array ], nec : int , con_tol : float = 1e-6
38+ f : Union [list , np .ndarray ], nec : int , con_tol : float = 1e-6
3939) -> Tuple [float , int ]:
4040 """Get the constraints violation norm from the fitness vector.
4141
@@ -51,7 +51,7 @@ def _get_constraint_violation(
5151
5252 Returns
5353 -------
54- float, int
54+ Tuple[ float, int]
5555 Constraint violation norm in ``f``
5656 Number of violated constraints
5757 """
@@ -72,7 +72,7 @@ def _get_constraint_violation(
7272 np .abs (np .heaviside (ineq_cons - ineq_con_tol , 0 ) * np .array (ineq_cons )),
7373 ]
7474 )
75- violation_norm = np .linalg .norm (violations ) if violations .size else 0.0
75+ violation_norm = float ( np .linalg .norm (violations ) ) if violations .size else 0.0
7676 num_violations = int (sum (np .heaviside (violations , 0 )))
7777
7878 return violation_norm , num_violations
@@ -380,7 +380,7 @@ def __init__(
380380 )
381381
382382 # dictionary to store last optimisation result for get_extra_info()
383- self .__last_result = {}
383+ self .__last_result : dict [ str , Any ] = {}
384384
385385 def set_verbosity (self , verbosity : int ) -> None :
386386 """
0 commit comments