Skip to content

Commit

Permalink
Don't use invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Mar 5, 2021
1 parent 5512352 commit aabd2c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
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]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"

[compat]
Expand Down
12 changes: 10 additions & 2 deletions src/impl/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ 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
@@ -1,6 +1,7 @@
module Impl

using Base: Dims
using Accessors: @set
using Transducers
using Transducers: @return_if_reduced, next, complete

Expand Down
8 changes: 7 additions & 1 deletion test/environments/main/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# This file is machine-generated - editing it directly is not advised

[[Accessors]]
deps = ["Compat", "CompositionsBase", "ConstructionBase", "Future", "MacroTools", "Requires", "Test"]
git-tree-sha1 = "6061581e28cf6fbbb6af983022c2589cbc801007"
uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
version = "0.1.1"

[[ArgCheck]]
git-tree-sha1 = "dedbbb2ddb876f899585c4ec4433265e3017215a"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down Expand Up @@ -195,7 +201,7 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

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

0 comments on commit aabd2c5

Please sign in to comment.