Skip to content

Inconsistent broadcasting behavior of Py arrays #392

Closed
@LilithHafner

Description

@LilithHafner

Affects: Both (easier to reproduce with PythonCall, but I actually hit it using JuliaCall)

Describe the bug
x .* y where x is a Py wrapping a numpy array and y is a Matrix gives strange (buggy) results. Converting to a PyArray is a workaround:

julia> pyexec("import numpy as np", Main)

julia> x = pyeval("np.array([[1,2],[3,4]])", Main)
Python:
array([[1, 2],
       [3, 4]])

julia> y = rand(2,2);

julia> x .* y # BUG
2×2 Matrix{Py}:
 array([0.58564244, 1.17128489])  array([0.33111401, 0.66222801])
 array([2.77225103, 3.69633471])  array([0.94132148, 1.25509531])

julia> pyconvert(Any, x) .* y
2×2 Matrix{Float64}:
 0.585642  0.662228
 2.77225   1.2551

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions