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

Support Julia 1.6 #5

Merged
merged 4 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ authors = ["Takafumi Arakaki <aka.tkf@gmail.com>"]
version = "0.1.0"

[deps]
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"

[compat]
Expand Down
2 changes: 1 addition & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[UnionArrays]]
deps = ["Transducers"]
deps = ["Setfield", "Transducers"]
path = ".."
uuid = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
version = "0.1.0"
14 changes: 11 additions & 3 deletions src/impl/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ struct UnionArray{T, N, P} <: Abstract.UnionArray{T, N}

function UnionArray(parent::P) where {T, N, P <: AbstractArray{T, N}}
# Make sure that `A.parent` is not a UnionArray/Vector
P <: UnionArrayImpls && throw(MethodError(UnionArray, (A,)))
P <: UnionArrayImpls && throw(MethodError(UnionArray, (parent,)))
return new{T, N, P}(parent)
end
end

const UnionArrayImpls = Union{UnionVector, UnionArray}

default_reshape(A::UnionVector, dims::T) where T =
invoke(reshape, Tuple{AbstractArray, T}, A, dims)
# A very minimal dummy array implementation just for implementing `default_reshape`:
struct DummyArray{N} <: AbstractArray{Any,N}
dims::NTuple{N,Int}
end
Base.size(A::DummyArray) = A.dims

function default_reshape(A::UnionVector, dims::T) where {T}
dummy = reshape(DummyArray(size(A)), dims)
return @set dummy.parent = A
end

ua_reshape(A::UnionVector, dims) = UnionArray(default_reshape(A, dims))
ua_reshape(A::UnionArray, dims) = UnionArray(reshape(A.parent, dims))
Expand Down
1 change: 1 addition & 0 deletions src/impl/impl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Impl
using Base: Dims
using Transducers
using Transducers: @return_if_reduced, next, complete
using Setfield: @set # using Setfield instead of Accessors for older Julia

using ..Abstract

Expand Down
2 changes: 1 addition & 1 deletion test/environments/main/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[UnionArrays]]
deps = ["Transducers"]
deps = ["Setfield", "Transducers"]
path = "../../.."
uuid = "d6dd79e4-993b-11e9-1366-0de1c9fe1122"
version = "0.1.0"
Expand Down