Skip to content

Commit

Permalink
Add Zeros(T, n...) and Ones(T, n...) constructors (#94(
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Mar 28, 2023
1 parent b681ddd commit a8666da
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ for (Typ, funcs, func) in ((:Zeros, :zeros, :zero), (:Ones, :ones, :one))
@inline $Typ{T,N}(A::AbstractArray{V,N}) where{T,V,N} = $Typ{T,N}(size(A))
@inline $Typ{T}(A::AbstractArray) where{T} = $Typ{T}(size(A))
@inline $Typ(A::AbstractArray) = $Typ{eltype(A)}(A)
@inline $Typ(::Type{T}, m...) where T = $Typ{T}(m...)

@inline axes(Z::$Typ) = Z.axes
@inline size(Z::$Typ) = length.(Z.axes)
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ include("infinitearrays.jl")

for T in (Int, Float64)
Z = $Typ{T}(5)
@test $Typ(T, 5) Z
@test eltype(Z) == T
@test Array(Z) == $funcs(T,5)
@test Array{T}(Z) == $funcs(T,5)
Expand All @@ -34,6 +35,7 @@ include("infinitearrays.jl")
@test $Typ(2ones(T,5)) == Z

Z = $Typ{T}(5, 5)
@test $Typ(T, 5, 5) Z
@test eltype(Z) == T
@test Array(Z) == $funcs(T,5,5)
@test Array{T}(Z) == $funcs(T,5,5)
Expand Down

0 comments on commit a8666da

Please sign in to comment.