Skip to content

Don't understand how to pass numpy arrays to Julia function #28

Closed
@arbenede

Description

@arbenede

Let's consider the code fragment

import numpy as np

X = np.ones((10,10))
Y = np.ones((10,10))

x, y = jl.MyModule.compute_something(X, Y, -1.0, 1.0, -1.0, 1.0)

where I call a Julia function defined in the MyModule module. I am getting the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Julia: MethodError: no method matching compute_something(::PythonCall.PyArray{Float64, 2, Float64, true, false}, ::PythonCall.PyArray{Float64, 2, Float64, true, false}, ::Float64, ::Float64, ::Float64, ::Float64)
Closest candidates are:
  compute_something(!Matched::Matrix{T}, !Matched::Matrix{T}, ::T, ::T, ::T, ::T) where T<:Real at /opt/julia/compute_something:362

Does this mean that I need to define a new method for compute_something() with ::PythonCall.PyArray arguments? Can I avoid doing that? From the documentation it is not clear what to do in this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions