Skip to content

Commit

Permalink
add Aqua and fix ambiguity
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Oct 24, 2023
1 parent 99f0556 commit a784af4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
Adapt = "1, 2, 3"
Aqua = "0.7"
ConstructionBase = "1"
DataAPI = "1"
GPUArraysCore = "0.1.2"
Expand All @@ -21,6 +22,7 @@ Tables = "1"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Expand All @@ -32,4 +34,4 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"

[targets]
test = ["Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter", "SparseArrays"]
test = ["Aqua", "Test", "JLArrays", "StaticArrays", "OffsetArrays", "PooledArrays", "TypedTables", "WeakRefStrings", "Documenter", "SparseArrays"]
5 changes: 4 additions & 1 deletion src/structarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions test/Aqua.jl
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
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if Base.VERSION >= v"1.6" && Int === Int64
doctest(StructArrays)
end

include("Aqua.jl")

# Most types should not be viewed as equivalent merely
# because they have the same field names. (Exception:
# NamedTuples are distinguished only by field names, so they
Expand Down

0 comments on commit a784af4

Please sign in to comment.