Skip to content

Commit 94c4bd9

Browse files
fixed array lengths
1 parent 48f0bc1 commit 94c4bd9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

pyoptgra/optgra.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def _get_constraint_violation(
6262
eq_cons = np.array(f[1 : (nec + 1)])
6363
ineq_cons = np.array(f[(nec + 1) :])
6464
# extract corresponding tolerances
65-
eq_con_tol = con_tol_array[1 : (nec + 1)]
66-
ineq_con_tol = con_tol_array[(nec + 1) :]
65+
eq_con_tol = con_tol_array[0:nec]
66+
ineq_con_tol = con_tol_array[nec:]
6767

6868
# determine maximum constraint violation
6969
violations = np.concatenate(
@@ -110,7 +110,6 @@ class optgra:
110110

111111
@staticmethod
112112
def _constraint_types_from_box_bounds(problem):
113-
114113
lb, ub = problem.get_bounds()
115114
# all box-derived constraints are positive
116115
finite_lb = sum(isfinite(elem) for elem in lb)
@@ -129,7 +128,6 @@ def _wrap_fitness_func(
129128
lb, ub = problem.get_bounds()
130129

131130
def wrapped_fitness(x):
132-
133131
# we are using vectorisation internally -> convert to ndarray
134132
x = np.asarray(x, dtype=np.float64)
135133
_assert_finite(x, "decision vector") # catch nan values
@@ -169,7 +167,6 @@ def _wrap_gradient_func(
169167
force_bounds=False,
170168
khanf: Optional[base_khan_function] = None,
171169
):
172-
173170
# get the sparsity pattern to index the sparse gradients
174171
sparsity_pattern = problem.gradient_sparsity()
175172
f_indices, x_indices = sparsity_pattern.T # Unpack indices
@@ -178,7 +175,6 @@ def _wrap_gradient_func(
178175
shape = (problem.get_nf(), problem.get_nx())
179176

180177
def wrapped_gradient(x):
181-
182178
# we are using vectorisation internally -> convert to ndarray
183179
x = np.asarray(x, dtype=np.float64)
184180
_assert_finite(x, "decision vector") # catch nan values

0 commit comments

Comments
 (0)