-
Notifications
You must be signed in to change notification settings - Fork 41
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
add Aqua.jl
tests and fix ambiguity
#283
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,12 +289,13 @@ for type in ( | |
:(Tuple{Union{Integer, AbstractUnitRange}, Vararg{Union{Integer, AbstractUnitRange}}}), | ||
# disambiguation with Base | ||
:(Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}), | ||
:(Tuple{Integer, Vararg{Integer}}), | ||
) | ||
@eval function Base.similar(::Type{<:StructArray{T, N, C}}, sz::$(type)) where {T, N, C} | ||
return buildfromschema(typ -> similar(typ, sz), T, C) | ||
end | ||
|
||
@eval function Base.similar(s::StructArray, S::Type, sz::$(type)) | ||
@eval function Base.similar(s::StructArray, S::Type{T}, sz::$(type)) where T | ||
return _similar(s, S, sz) | ||
end | ||
end | ||
|
@@ -469,8 +470,10 @@ for type in ( | |
:(Tuple{Union{Integer, AbstractUnitRange, Colon}, Vararg{Union{Integer, AbstractUnitRange, Colon}}}), | ||
# disambiguation with Base | ||
:(Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}), | ||
:(Tuple{Union{Colon, Integer}, Vararg{Union{Colon, Integer}}}), | ||
:(Tuple{Vararg{Union{Colon, Integer}}}), | ||
:(Tuple{Vararg{Union{Colon, Int}}}), | ||
:(Tuple{Integer, Vararg{Integer}}), | ||
:(Tuple{Colon}), | ||
) | ||
@eval function Base.reshape(s::StructArray{T}, d::$(type)) where {T} | ||
|
@@ -512,6 +515,12 @@ function BroadcastStyle(b::AbstractArrayStyle{M}, a::StructArrayStyle{S, N}) whe | |
S′ = Broadcast.result_style(S(), b) | ||
return S′ isa StructArrayStyle ? typeof(S′)(Val{N′}()) : StructArrayStyle{typeof(S′), N′}() | ||
end | ||
function BroadcastStyle( | ||
::Union{SparseArrays.HigherOrderFns.SparseMatStyle, SparseArrays.HigherOrderFns.SparseVecStyle}, | ||
::StructArrays.StructArrayStyle{S, 0} | ||
) | ||
return Unknown() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure what's the correct style here, but before it would result in ambiguity error so this isn't regression There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like that. Ambiguity errors exist for a reason. If it is truly ambiguous then somebody who understands what is going on needs to disambiguate it, setting it to |
||
end | ||
BroadcastStyle(::StructArrayStyle, ::DefaultArrayStyle) = Unknown() | ||
|
||
@inline combine_style_types(::Type{A}, args...) where {A<:AbstractArray} = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using Aqua | ||
|
||
@testset "Aqua.jl" begin | ||
Aqua.test_all(StructArrays) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aqua addition looks good to me. CI is all red here, even when it was green on master Saying something about "SparseArrays" not found. That should probably get fixed. Maybe this line?
I have not reviewed the changes to src/structarray.jl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I import SparseArrays here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a bad idea to add SparseArrays as a dependency just for this. Maybe a weak dependency if necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a
SparseArrays
extension now, so this may be moved to that?