Skip to content

Commit

Permalink
Fix ambiguities (#228)
Browse files Browse the repository at this point in the history
* fix ambiguities

* cleanup

* cleanup
  • Loading branch information
rafaqz authored Feb 6, 2025
1 parent c1873df commit 74fdfa4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.9'
- '1.10'
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
Expand Down Expand Up @@ -45,4 +45,4 @@ jobs:
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
file: lcov.info
5 changes: 2 additions & 3 deletions src/array.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

macro implement_array_methods(t)
t = esc(t)
quote
Expand All @@ -23,8 +22,8 @@ macro implement_array_methods(t)
return $_copyto!(dest, Rdest, src, Rsrc)
end
# For ambiguity
copyto!(dest::PermutedDimsArray, src::$t) = DiskArrays._copyto!(dest, src)
function copyto!(dest::PermutedDimsArray{T,N}, src::$t{T,N}) where {T,N}
Base.copyto!(dest::PermutedDimsArray, src::$t) = DiskArrays._copyto!(dest, src)
function Base.copyto!(dest::PermutedDimsArray{T,N}, src::$t{T,N}) where {T,N}
return $_copyto!(dest, src)
end

Expand Down
1 change: 1 addition & 0 deletions src/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ macro implement_generator(t)
t = esc(t)
quote
Base.Generator(f, A::$t) = $DiskGenerator(f, A)
Base.Generator(::Type{T}, A::$t) where T = $DiskGenerator(T, A)
end
end
33 changes: 15 additions & 18 deletions src/zip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@
struct DiskZip{Is<:Tuple}
is::Is
end
Base.iterate(dz::DiskZip) = Base.iterate(Iterators.Zip(dz.is))
Base.iterate(dz::DiskZip, i) = Base.iterate(Iterators.Zip(dz.is), i)
Base.first(dz::DiskZip) = Base.first(Iterators.Zip(dz.is))
Base.last(dz::DiskZip) = Base.last(Iterators.Zip(dz.is))
Base.length(dz::DiskZip) = Base.length(Iterators.Zip(dz.is))
Base.size(dz::DiskZip) = Base.size(Iterators.Zip(dz.is))
function Base.IteratorSize(::Type{DiskZip{Is}}) where {Is<:Tuple}
return Base.IteratorSize(Iterators.Zip{Is})
end
function Base.IteratorEltype(::Type{DiskZip{Is}}) where {Is<:Tuple}
return Base.IteratorEltype(Iterators.Zip{Is})
end

# Rechunk using the chunks of the first Chunked array
# This forces the iteration order to be the same for
# all arrays.

function DiskZip(As::AbstractArray...)
map(As) do A
size(A) == size(first(As)) ||
Expand All @@ -41,7 +24,21 @@ function DiskZip(As::AbstractArray...)
return DiskZip(rechunked)
end
end
# # For now we only allow zip on exact same-sized arrays

Base.iterate(dz::DiskZip) = Base.iterate(Iterators.Zip(dz.is))
Base.iterate(dz::DiskZip, i) = Base.iterate(Iterators.Zip(dz.is), i)
Base.first(dz::DiskZip) = Base.first(Iterators.Zip(dz.is))
Base.last(dz::DiskZip) = Base.last(Iterators.Zip(dz.is))
Base.length(dz::DiskZip) = Base.length(Iterators.Zip(dz.is))
Base.size(dz::DiskZip) = Base.size(Iterators.Zip(dz.is))
function Base.IteratorSize(::Type{DiskZip{Is}}) where {Is<:Tuple}
return Base.IteratorSize(Iterators.Zip{Is})
end
function Base.IteratorEltype(::Type{DiskZip{Is}}) where {Is<:Tuple}
return Base.IteratorEltype(Iterators.Zip{Is})
end

# For now we only allow zip on exact same-sized arrays

# Collect zipped disk arrays in the right order
function Base.collect(dz::DiskZip)
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ using Aqua
# JET.report_package(DiskArrays)

if VERSION >= v"1.9.0"
# These dont resolve even though the suggested methods exist
# Aqua.test_ambiguities([DiskArrays, Base, Core])
Aqua.test_ambiguities([DiskArrays, Base, Core])
Aqua.test_unbound_args(DiskArrays)
Aqua.test_stale_deps(DiskArrays)
Aqua.test_undefined_exports(DiskArrays)
Expand Down

0 comments on commit 74fdfa4

Please sign in to comment.