Skip to content

Commit 4d0dd91

Browse files
committed
add condition
1 parent a802d28 commit 4d0dd91

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/gradient_free_optimizers/_array_backend/_c_extension.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
def _c_result(raw_bytes, shape):
2121
data = _array_mod.array(_DOUBLE)
2222
_frombytes(data, raw_bytes)
23-
return GFOArray._from_raw(data, shape)
23+
return _CGFOArray._from_raw(data, shape)
2424

2525

2626
class _CGFOArray(GFOArray):
@@ -31,6 +31,7 @@ def __add__(self, other):
3131
isinstance(other, GFOArray)
3232
and isinstance(self._data, _array_mod.array)
3333
and isinstance(other._data, _array_mod.array)
34+
and len(self._data) == len(other._data)
3435
):
3536
return _c_result(_fast_ops.vec_add(self._data, other._data), self._shape)
3637
if isinstance(other, int | float) and isinstance(self._data, _array_mod.array):
@@ -48,6 +49,7 @@ def __sub__(self, other):
4849
isinstance(other, GFOArray)
4950
and isinstance(self._data, _array_mod.array)
5051
and isinstance(other._data, _array_mod.array)
52+
and len(self._data) == len(other._data)
5153
):
5254
return _c_result(_fast_ops.vec_sub(self._data, other._data), self._shape)
5355
if isinstance(other, int | float) and isinstance(self._data, _array_mod.array):
@@ -62,6 +64,7 @@ def __mul__(self, other):
6264
isinstance(other, GFOArray)
6365
and isinstance(self._data, _array_mod.array)
6466
and isinstance(other._data, _array_mod.array)
67+
and len(self._data) == len(other._data)
6568
):
6669
return _c_result(_fast_ops.vec_mul(self._data, other._data), self._shape)
6770
if isinstance(other, int | float) and isinstance(self._data, _array_mod.array):

0 commit comments

Comments
 (0)