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 content types #62

Merged
merged 53 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ee0d3e1
feat: add a method to convert `PyIterable`
ianna Dec 11, 2023
e3c09a5
feat: add auto conversion rules
ianna Dec 12, 2023
5ab4335
fix: update conversion rules
ianna Dec 14, 2023
7af724d
feat: define __init__ function
ianna Jan 17, 2024
009bcaf
fix: move convert out of the __init__ function
ianna Jan 17, 2024
d6000ab
test: add a test passing a Python array to a Julia function
ianna Jan 17, 2024
f2b1406
feat: define conversion rules
ianna Jan 23, 2024
11fe5d5
fix: remove convertion of an iterable
ianna Jan 23, 2024
11c7c46
feat: add rules and register
ianna Jan 23, 2024
3b8663e
fix: leave it to a user to invoke pyconvert
ianna Jan 23, 2024
9ea8d9c
test: test pyconvert of an awkward array
ianna Jan 23, 2024
34f33a7
tests: add tests
ianna Jan 24, 2024
c396ae7
fix: use Vector in convert to avoid problems with BitMasked buffers
ianna Jan 24, 2024
1cc71e5
feat: convert to an awkward type
ianna Jan 24, 2024
f193bf4
fix: add dtypes
ianna Jan 24, 2024
7d2c696
fix: more dtypes
ianna Jan 24, 2024
6687140
feat: add content types
ianna Jan 30, 2024
5973237
Merge branch 'main' into ianna/add_content_types
ianna Feb 1, 2024
15b11a8
fix: add tuple behaviour
ianna Feb 5, 2024
1f53fb8
test: separate from_iter tests
ianna Feb 6, 2024
a69f2b0
fix: eltype of UnionArray
ianna Feb 6, 2024
8825ea4
fix: cleanup
ianna Feb 6, 2024
09aa996
test: comment out a test of from_iter on union
ianna Feb 6, 2024
0de6fca
test: comment out another test
ianna Feb 6, 2024
9f9b4d2
test: add a test
ianna Feb 6, 2024
fe720aa
test: comment out a test
ianna Feb 6, 2024
fa4d5d1
fix: tests
ianna Feb 7, 2024
440a2d6
fix: add a test
ianna Feb 7, 2024
fba439e
fix: add a test
ianna Feb 7, 2024
a6e9936
debug: add print statements in the failing test
ianna Feb 7, 2024
5041269
test: add debug statements
ianna Feb 8, 2024
c8891bc
fix: add test
ianna Feb 8, 2024
e69f907
fix: test
ianna Feb 8, 2024
a719729
fix: cleanup debug statements
ianna Feb 9, 2024
01cb941
feat: add eltype
ianna Feb 21, 2024
3343c94
tests: cleanup
ianna Feb 21, 2024
edee010
feat: set empty eltype as union
ianna Feb 21, 2024
defc61a
fix: use bottom type
ianna Feb 21, 2024
6ef15d5
Update src/all_implementations.jl
ianna Feb 23, 2024
a694657
Update src/all_implementations.jl
ianna Feb 24, 2024
6a93325
Update src/all_implementations.jl
ianna Feb 24, 2024
f9475b1
Update src/all_implementations.jl
ianna Feb 24, 2024
051a2d9
Update src/all_implementations.jl
ianna Feb 24, 2024
6056cb0
fix: tests
ianna Feb 24, 2024
46391cb
feat: unionarray eltype
ianna Feb 26, 2024
8e611f7
fix: cleanup
ianna Feb 26, 2024
4d3ae8d
test: add record eltype test
ianna Feb 26, 2024
95ad897
test: add more tests
ianna Feb 26, 2024
44d196c
test: add more test coverage
ianna Feb 26, 2024
f74515a
test: more tests and fixes
ianna Feb 28, 2024
b6d3a1d
cleanup: remove debug printout
ianna Feb 28, 2024
a70f26f
test: more tests
ianna Feb 28, 2024
6769ac1
cleanup
ianna Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/AwkwardArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
include("./AwkwardPythonCallExt.jl")
using .AwkwardPythonCallExt: convert

Base.eltype(::RecordArray{FIELDS,CONTENTS,BEHAVIOR}) where {FIELDS,CONTENTS,BEHAVIOR} = Record{FIELDS,CONTENTS,BEHAVIOR}
Base.eltype(::Record{FIELDS,CONTENTS,BEHAVIOR}) where {FIELDS,CONTENTS,BEHAVIOR} = CONTENTS

Check warning on line 13 in src/AwkwardArray.jl

View check run for this annotation

Codecov / codecov/patch

src/AwkwardArray.jl#L13

Added line #L13 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

Does a Record (a scalar object, not an array) even have an eltype?

Copy link
Member

Choose a reason for hiding this comment

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

I think it depends on if you model the Record as an indexable thing. For me at least, I think event-based table semantically as a row table, so the eltype is whatever the type an "event" would give you

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if it makes sense to separate FIELDS and CONTENTS, but perhaps there is a usecase for it?

julia> typeof(layout[3])
AwkwardArray.Record{(:a, :b), Tuple{AwkwardArray.PrimitiveArray{Int64, Vector{Int64}, :default}, AwkwardArray.ListOffsetArray{Vector{Int64}, AwkwardArray.PrimitiveArray{Float64, Vector{Float64}, :default}, :default}}, :default}

julia> r = layout[3]
{a: 3, b: [4.4, 5.5]}

julia> eltype(r)
Tuple{AwkwardArray.PrimitiveArray{Int64, Vector{Int64}, :default}, AwkwardArray.ListOffsetArray{Vector{Int64}, AwkwardArray.PrimitiveArray{Float64, Vector{Float64}, :default}, :default}}

Base.eltype(::TupleArray{CONTENTS,BEHAVIOR}) where {CONTENTS,BEHAVIOR} = Tuple{CONTENTS,BEHAVIOR}
Base.eltype(::UnionArray{TAGS,INDEX,CONTENTS}) where {TAGS,INDEX,CONTENTS} = CONTENTS
ianna marked this conversation as resolved.
Show resolved Hide resolved

end # module AwkwardArray
8 changes: 7 additions & 1 deletion src/all_implementations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Base.length(layout::EmptyArray) = 0
Base.firstindex(layout::EmptyArray) = 1
Base.lastindex(layout::EmptyArray) = 0

Base.eltype(layout::EmptyArray) = nothing
Base.eltype(layout::EmptyArray) = Union{}
ianna marked this conversation as resolved.
Show resolved Hide resolved
Base.getindex(layout::EmptyArray, i::Int) = throw(BoundsError(layout, i))

function Base.getindex(layout::EmptyArray, r::UnitRange{Int})
Expand Down Expand Up @@ -1447,6 +1447,7 @@ function is_valid(layout::IndexedArray)
return is_valid(layout.content)
end

Base.eltype(layout::IndexedArray) = eltype(layout.content)
Base.length(layout::IndexedArray) = length(layout.index)
Base.firstindex(layout::IndexedArray) = firstindex(layout.index)
Base.lastindex(layout::IndexedArray) = lastindex(layout.index)
Expand Down Expand Up @@ -1585,6 +1586,7 @@ function is_valid(layout::IndexedOptionArray)
return is_valid(layout.content)
end

Base.eltype(layout::IndexedOptionArray) = eltype(layout.content)
ianna marked this conversation as resolved.
Show resolved Hide resolved
Base.length(layout::IndexedOptionArray) = length(layout.index)
Base.firstindex(layout::IndexedOptionArray) = firstindex(layout.index)
Base.lastindex(layout::IndexedOptionArray) = lastindex(layout.index)
Expand Down Expand Up @@ -1731,6 +1733,7 @@ function is_valid(layout::ByteMaskedArray)
return is_valid(layout.content)
end

Base.eltype(layout::ByteMaskedArray) = eltype(layout.content)
ianna marked this conversation as resolved.
Show resolved Hide resolved
Base.length(layout::ByteMaskedArray) = length(layout.mask)
Base.firstindex(layout::ByteMaskedArray) = firstindex(layout.mask)
Base.lastindex(layout::ByteMaskedArray) = lastindex(layout.mask)
Expand Down Expand Up @@ -1884,6 +1887,7 @@ function is_valid(layout::BitMaskedArray)
return is_valid(layout.content)
end

Base.eltype(layout::BitMaskedArray) = eltype(layout.content)
ianna marked this conversation as resolved.
Show resolved Hide resolved
Base.length(layout::BitMaskedArray) = length(layout.mask)
Base.firstindex(layout::BitMaskedArray) = firstindex(layout.mask)
Base.lastindex(layout::BitMaskedArray) = lastindex(layout.mask)
Expand Down Expand Up @@ -2006,6 +2010,7 @@ end

is_valid(layout::UnmaskedArray) = is_valid(layout.content)

Base.eltype(layout::UnmaskedArray) = eltype(layout.content)
ianna marked this conversation as resolved.
Show resolved Hide resolved
Base.length(layout::UnmaskedArray) = length(layout.content)
Base.firstindex(layout::UnmaskedArray) = firstindex(layout.content)
Base.lastindex(layout::UnmaskedArray) = lastindex(layout.content)
Expand Down Expand Up @@ -2284,6 +2289,7 @@ end
### from_iter ############################################################

function layout_for(ItemType)

ianna marked this conversation as resolved.
Show resolved Hide resolved
if ItemType <: Number # || ItemType <: Dates.DateTime || ItemType <: Dates.TimePeriod
PrimitiveArray{ItemType}

Expand Down
Loading
Loading