Skip to content

Commit 845e849

Browse files
fixing tests
1 parent f00cb9c commit 845e849

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pyoptgra/optgra.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import re
1616
from math import isfinite
17-
from typing import List, Optional, Tuple, Union
17+
from typing import List, Optional, Tuple, Union, Any
1818

1919
import numpy as np
2020
from pygmo import s_policy, select_best
@@ -35,7 +35,7 @@
3535

3636

3737
def _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

Comments
 (0)