Skip to content
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 .github/workflows/Testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- '1.2'
- '1.3'
- '1.4'
- '1'
- 'nightly'
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f"
license = "MIT"
desc = "C shim for task copying in Turing"
repo = "https://github.com/TuringLang/Libtask.jl.git"
version = "0.4.2"
version = "0.4.3"

[deps]
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
Expand Down
7 changes: 3 additions & 4 deletions src/tarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ struct TArray{T,N} <: AbstractArray{T,N}
TArray{T,N}() where {T,N} = new(gensym(), current_task())
end

TArray{T,1}(d::Integer) where T = TArray(T, d)
TArray{T}(d::Integer...) where T = TArray(T, d)
TArray{T}(UndefInitializer, d::Integer...) where T = TArray(T, d)
TArray{T,N}(d::Integer...) where {T,N} = length(d)==N ? TArray(T,d) : error("Malformed dims")
TArray{T,N}(UndefInitializer, d::Integer...) where {T,N} = length(d)==N ? TArray(T,d) : error("Malformed dims")
TArray{T}(::UndefInitializer, d::Integer...) where T = TArray(T, d)
TArray{T,N}(d::Vararg{<:Integer,N}) where {T,N} = TArray(T, d)
TArray{T,N}(::UndefInitializer, d::Vararg{<:Integer,N}) where {T,N} = TArray{T,N}(d)
TArray{T,N}(dim::NTuple{N,Int}) where {T,N} = TArray(T, dim)

function TArray(T::Type, dim)
Expand Down
35 changes: 35 additions & 0 deletions test/tarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,47 @@

@testset "other methods" begin
ta2 = TArray{Int}(4, 4)
@test ta2 isa TArray{Int,2}
@test size(ta2) == (4, 4)

ta2 = TArray{Int}(undef, 4, 4)
@test ta2 isa TArray{Int,2}
@test size(ta2) == (4, 4)

ta2 = TArray{Int,2}(4, 4)
@test ta2 isa TArray{Int,2}
@test size(ta2) == (4, 4)

ta2 = TArray{Int,2}(undef, 4, 4)
@test ta2 isa TArray{Int,2}
@test size(ta2) == (4, 4)

@test_throws MethodError TArray{Int,2}(4)
@test_throws MethodError TArray{Int,2}(undef, 4)

ta3 = TArray{Int, 4}(4, 3, 2, 1)
ta4 = get(ta3)
@test ta3[3] == ta4[3]

ta5 = TArray{Int}(4)
@test ta5 isa TArray{Int,1}
@test size(ta5) == (4,)

ta5 = TArray{Int}(undef, 4)
@test ta5 isa TArray{Int,1}
@test size(ta5) == (4,)

ta5 = TArray{Int,1}(4)
@test ta5 isa TArray{Int,1}
@test size(ta5) == (4,)

ta5 = TArray{Int,1}(undef, 4)
@test ta5 isa TArray{Int,1}
@test size(ta5) == (4,)

@test_throws MethodError TArray{Int,1}(4, 4)
@test_throws MethodError TArray{Int,1}(undef, 4, 4)

for i in 1:4
ta5[i] = i
end
Expand Down