Skip to content

Commit 223df40

Browse files
Merge pull request #14 from esa/fix/get_extra_info2
fixed array lengths
2 parents 48f0bc1 + 42278a0 commit 223df40

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

pyoptgra/optgra.py

+2-6
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

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = { text = "GPL-3.0 or ESCL-2.4" }
1010
name = "pyoptgra"
1111
readme = "README.rst"
1212
requires-python = ">=3.9"
13-
version = "1.2.0"
13+
version = "1.2.1"
1414

1515
[build-system]
1616
build-backend = "scikit_build_core.build"

0 commit comments

Comments
 (0)