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

feat: add rules to auto convert Awkward types #57

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ianna
Copy link
Member

@ianna ianna commented Dec 11, 2023

Here is an example of using from in Python:

>>> import awkward as ak
>>> from juliacall import Main as jl
>>> array = ak.Array([[1.1, 2.2, 3.3], [], [4.4, 5.5]])
>>> jl.AwkwardArray.convert(array)
Julia:
3-element AwkwardArray.ListOffsetArray{SubArray{Int64, 1, PyArray{Int64, 1, true, true, Int64}, Tuple{UnitRange{Int64}}, true}, AwkwardArray.PrimitiveArray{Float64, SubArray{Float64, 1, PyArray{Float64, 1, true, true, Float64}, Tuple{UnitRange{Int64}}, true}, :default}, :default}:
 [1.1, 2.2, 3.3]
 0-element AwkwardArray.PrimitiveArray{Float64, Vector{Float64}, :default}
 [4.4, 5.5]

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (ea089c2) 72.03% compared to head (009bcaf) 71.66%.
Report is 2 commits behind head on main.

❗ Current head 009bcaf differs from pull request most recent head d6000ab. Consider uploading reports for the commit d6000ab to get more accurate results

Files Patch % Lines
ext/AwkwardPythonCallExt/AwkwardPythonCallExt.jl 40.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
- Coverage   72.03%   71.66%   -0.38%     
==========================================
  Files           4        4              
  Lines        1613     1648      +35     
==========================================
+ Hits         1162     1181      +19     
- Misses        451      467      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ianna ianna marked this pull request as draft December 11, 2023 12:27
@ianna ianna marked this pull request as ready for review December 12, 2023 14:43
@ianna ianna marked this pull request as draft December 13, 2023 17:10
@ianna ianna changed the title feat: add a method to convert PyIterable feat: add rules to auto convert Awkward types Dec 15, 2023
Copy link
Member Author

@ianna ianna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom conversion rules define a function to do the conversion. The pyconvert_add_rule function is called to register it.

ext/AwkwardPythonCallExt/AwkwardPythonCallExt.jl Outdated Show resolved Hide resolved
Copy link
Member Author

@ianna ianna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from Julia docs: if you define a function __init__() in a module, then Julia will call __init__() immediately after the module is loaded (e.g., by import, using, or require) at runtime for the first time (i.e., __init__ is only called once, and only after all statements in the module have been executed). Because it is called after the module is fully imported, any submodules or other imported modules have their __init__ functions called before the __init__ of the enclosing module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant