Skip to content

Commit 31e9a8c

Browse files
committed
fixup! Fix arguments for ArrayValue.__array__()
1 parent 9ac67bd commit 31e9a8c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/JlWrap/array.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,14 @@ function init_array()
357357
# convert to an array-like object
358358
arr = self
359359
if not (hasattr(arr, "__array_interface__") or hasattr(arr, "__array_struct__")):
360-
# the second attempt collects into a PyObjectArray
361-
arr = self._jl_callmethod($(pyjl_methodnum(pyjlarray_array__pyobjectarray)))
360+
if copy is False:
361+
raise ValueError("copy=False is not supported when collecting ArrayValue data")
362+
# the first attempt collects into an Array
363+
arr = self._jl_callmethod($(pyjl_methodnum(pyjlarray_array__array)))
364+
if not (hasattr(arr, "__array_interface__") or hasattr(arr, "__array_struct__")):
365+
# the second attempt collects into a PyObjectArray
366+
arr = self._jl_callmethod($(pyjl_methodnum(pyjlarray_array__pyobjectarray)))
367+
362368
# convert to a numpy array if numpy is available
363369
try:
364370
import numpy
@@ -369,7 +375,7 @@ function init_array()
369375
major_version = int(numpy.__version__.split(".")[0])
370376
if major_version < 2 and copy is None:
371377
copy = False
372-
return numpy.array(arr, dtype=dtype, copy=copy)
378+
arr = numpy.array(arr, dtype=dtype, copy=copy)
373379
return arr
374380
def to_numpy(self, dtype=None, copy=True, order="K"):
375381
import numpy

0 commit comments

Comments
 (0)