Skip to content

DeprecationWarning: __array__ implementation doesn't accept a copy keyword #706

@oyamad

Description

@oyamad
import numpy as np
from juliacall import Main as jl
a = jl.seval('[1//2, 2//3]')
np.array(a)

raises a warning:

<python-input-0>:4: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments. To learn more, see the migration guide https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword
array([Fraction(1, 2), Fraction(2, 3)], dtype=object)

But the following do not:

>>> a.to_numpy()
array([Fraction(1, 2), Fraction(2, 3)], dtype=object)
>>> a.__array__()
array([Fraction(1, 2), Fraction(2, 3)], dtype=object)

And other numeric eltypes seem not:

>>> b = jl.seval('[1, 2, 3]')
>>> np.array(b)
array([1, 2, 3])

>>> np.__version__
'2.3.3'
>>> import juliacall; juliacall.__version__
'0.9.28'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions