Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-type specific Julia scalars with JuliaCall #504

Closed
mtsokol opened this issue May 27, 2024 · 2 comments
Closed

data-type specific Julia scalars with JuliaCall #504

mtsokol opened this issue May 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mtsokol
Copy link

mtsokol commented May 27, 2024

Affects: JuliaCall

Describe the bug

I would like to create Julia scalars by calling appropriate data-types (Int8, Int16, etc.), but instead calling specific dtypes just give python builtins (e.g. int for any integer julia dtype). Or is there another way to instantiate them?

from juliacall import Main as jl
import numpy as np

a1 = jl.Int8(0)
type(a1)  # it's just int

a2 = np.int8(0)
type(a2)  # it's numpy.int8

Your system
Please provide detailed information about your system:

In [80]: juliacall.__version__
Out[80]: '0.9.19'
JuliaPkg Status
/Users/.../Library/Caches/pypoetry/virtualenvs/finch-tensor-iqiMydcW-py3.10/julia_env/pyjuliapkg/juliapkg.json
Julia 1.10.0 @ /Users/.../.julia/juliaup/julia-1.10.0+0.x64.apple.darwin14/bin/julia
Packages:
  Finch: {'uuid': '9177782c-1635-4eb9-9bfb-d9dfa25e6bce', 'version': '0.6.30'}
@mtsokol mtsokol added the bug Something isn't working label May 27, 2024
@cjdoris
Copy link
Collaborator

cjdoris commented May 27, 2024

This is due to how values are converted between Python and Julia.

You can do juliacall.convert(jl.Int8, 0) to get an int-like value which wraps the underlying Julia Int8 value. Some of this should be a bit slicker in v1 but that won't be out for a while...

@mtsokol
Copy link
Author

mtsokol commented Jun 3, 2024

Thank you for the clarification!

@mtsokol mtsokol closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants