JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
715 stars 61 forks source link

np.bool_ does not convert to julia Bool #502

Closed willow-ahrens closed 1 month ago

willow-ahrens commented 1 month ago

Affects: Both

Describe the bug We expected np.bool_ to convert to julia Bool, just like all the other np.int32 and np.float64, but instead we get an Array{Bool, 0}

>>> import juliacall

>>> jl.println(np.int_(1))
1
>>> jl.println(int(1))
1
>>> jl.println(np.True_)
fill(true)
>>> jl.println(True)
true

Your system juliacall = "^0.9.15", several operating systems

Additional context Thank you for maintaining such an awesome piece of software. This occurs in https://github.com/willow-ahrens/finch-tensor/issues/54

willow-ahrens commented 1 month ago

Happy to file a PR if you point me where to look

willow-ahrens commented 1 month ago

is this just because bool is missing from https://github.com/JuliaPy/PythonCall.jl/blob/875c34d2e8ba54036b035ed26fe414e55256b8a1/src/Convert/numpy.jl#L14?

cjdoris commented 1 month ago

Thanks - it was indeed an oversight. I've fixed it on main now.

willow-ahrens commented 1 month ago

Thanks so much for the quick fix! I'll let my team know!