JuliaPy / PythonCall.jl

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

dtype of NumPy array created from Julia array is `object` on Julia nightly #439

Open sethaxen opened 5 months ago

sethaxen commented 5 months ago

Affects: PythonCall

Describe the bug

I'm executing the following code

julia> using PythonCall

pkg> conda add numpy

julia> Py(randn(10)).to_numpy().dtype

I expect the dtype to be a float64, and indeed, on Julia v1.10.0 and earlier, the result is Python: dtype('float64'). On the Julia nightly, the result is Python: dtype('O'), which corresponds to an object dtype.

Your system For v1.10.0:

julia> using CondaPkg, Pkg

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
  Threads: 11 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_EDITOR = code

julia> Pkg.status()
Status `/tmp/jl_lFXo6Z/Project.toml`
  [992eb4ea] CondaPkg v0.2.22
  [6099a3de] PythonCall v0.9.15

julia> CondaPkg.status()
CondaPkg Status /tmp/jl_lFXo6Z/CondaPkg.toml
Environment
  /tmp/jl_lFXo6Z/.CondaPkg/env
Packages
  numpy v1.26.3

For nightly:

julia> using CondaPkg, Pkg

julia> versioninfo()
Julia Version 1.11.0-DEV.1341
Commit 63188d58c09 (2024-01-19 23:30 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, tigerlake)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_EDITOR = code

julia> Pkg.status()
Status `/tmp/jl_oeTJsz/Project.toml`
  [992eb4ea] CondaPkg v0.2.22
  [6099a3de] PythonCall v0.9.15

julia> CondaPkg.status()
CondaPkg Status /tmp/jl_oeTJsz/CondaPkg.toml
Environment
  /tmp/jl_oeTJsz/.CondaPkg/env
Packages
  numpy v1.26.3
MilesCranmer commented 5 months ago

Not sure if my issue was related in #441 but I see similar issue going Python -> Julia.

cjdoris commented 5 months ago

Oof that's a fun one! Personally I'm not going to worry about it until there is a release candidate though.