Skip to content

Commit

Permalink
[cocoex] fix array(copy=True) for numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nikohansen committed Jul 22, 2024
1 parent 72d5ac2 commit 12c2e37
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions code-experiments/build/python/src/cocoex/interface.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ cdef class Problem:
# or should we return `[]` for zero constraints?
# `[]` is more likely to produce quietly unexpected result?
cdef np.ndarray[double, ndim=1, mode="c"] _x
x = np.array(x, copy=False, dtype=np.double, order='C')
x = np.asarray(x, dtype=np.double, order='C')
if np.size(x) != self.number_of_variables:
raise ValueError(
"Dimension, `np.size(x)==%d`, of input `x` does " % np.size(x) +
Expand All @@ -596,7 +596,7 @@ cdef class Problem:
for the assessment of the algorithm.
"""
cdef np.ndarray[double, ndim=1, mode="c"] _x
x = np.array(arx, copy=False, dtype=np.double, order='C')
x = np.asarray(arx, dtype=np.double, order='C')
if np.size(x) != self.number_of_variables:
raise ValueError(
"Dimension, `np.size(x)==%d`, of input `x` does " % np.size(x) +
Expand All @@ -618,7 +618,7 @@ cdef class Problem:
"""
cdef size_t _evaluation = evaluation # "conversion" to size_t
cdef np.ndarray[double, ndim=1, mode="c"] _y
y = np.array(y, copy=False, dtype=np.double, order='C')
y = np.asarray(y, dtype=np.double, order='C')
if np.size(y) != self.number_of_objectives:
raise ValueError(
"Dimension, `np.size(y)==%d`, of input `y` does " % np.size(y) +
Expand Down Expand Up @@ -815,7 +815,7 @@ cdef class Problem:
"""return objective function value of input `x`"""
cdef np.ndarray[double, ndim=1, mode="c"] _x
assert self.initialized
x = np.array(x, copy=False, dtype=np.double, order='C')
x = np.asarray(x, dtype=np.double, order='C')
if np.size(x) != self.number_of_variables:
raise ValueError(
"Dimension, `np.size(x)==%d`, of input `x` does " % np.size(x) +
Expand Down

0 comments on commit 12c2e37

Please sign in to comment.