-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
summary simplification, test cases, and eager checks (#28)
* add testset and eager argument checks on construction Also allow incomplete `alongs::TypedBool...` input, with tailing missing values default to `False()` * move doctest to document CI add JuliennedArrays to docs/Project.toml, ven though we must do `pkg> dev .` to use local development version of it. * simplify summary show * support linear indexing * revert incomplete constructors * comment out size checks * comment out all the safety checks * comment out 1 more line Co-authored-by: bramtayl <[email protected]>
- Loading branch information
1 parent
c2ea56e
commit fb9bf0a
Showing
6 changed files
with
128 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
name = "JuliennedArrays" | ||
uuid = "5cadff95-7770-533d-a838-a1bf817ee6e0" | ||
authors = ["Brandon Taylor <[email protected]>"] | ||
version = "0.2.2" | ||
repo = "https://github.com/bramtayl/JuliennedArrays.jl.git" | ||
version = "0.2.2" | ||
|
||
[compat] | ||
julia = "1" | ||
|
||
[extras] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Documenter"] | ||
|
||
[compat] | ||
julia = "1" | ||
test = ["Test"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
JuliennedArrays = "5cadff95-7770-533d-a838-a1bf817ee6e0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
using JuliennedArrays | ||
using Documenter: deploydocs, makedocs | ||
|
||
makedocs(sitename = "JuliennedArrays.jl", modules = [JuliennedArrays], doctest = false) | ||
makedocs(sitename = "JuliennedArrays.jl", modules = [JuliennedArrays], doctest = true, strict=true) | ||
deploydocs(repo = "github.com/bramtayl/JuliennedArrays.jl.git") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,57 @@ | ||
import JuliennedArrays | ||
using Documenter: doctest | ||
using JuliennedArrays | ||
using Test | ||
|
||
doctest(JuliennedArrays) | ||
@testset "JuliennedArrays.jl" begin | ||
@testset "Align" begin | ||
Xs = [rand(2, 3) for _ in 1:4] | ||
X = @inferred Align(Xs, True(), False(), True()) | ||
@test size(X) == (2, 4, 3) | ||
@test permutedims(cat(Xs...; dims=3), (1, 3, 2)) == X | ||
@test X[1] == Xs[1][1] # test linear indexing | ||
@test X[1, 2, 3] == Xs[2][1, 3] # test cartesian indexing | ||
|
||
Xs = reshape(Xs, 1, 4) | ||
X = @inferred Align(Xs, True(), False(), True(), False()) | ||
@test size(X) == (2, 1, 3, 4) | ||
@test permutedims(X, (1, 3, 2, 4))[:] == cat(Xs...; dims=3)[:] | ||
|
||
# type is not inferrable for integer alongs | ||
Xs = [rand(2, 3) for _ in 1:4] | ||
RT = Base.return_types(Align, (typeof(Xs), Int, Int))[1] | ||
@test !isconcretetype(RT) | ||
@test Align(Xs, True(), False(), True()) == Align(Xs, 1, 3) | ||
|
||
# @test_throws DimensionMismatch Align([rand(2, 3) for _ in 1:4], 1) # issue #25 | ||
# @test_throws MethodError Align(ones(2, 3, 4), 1, 2, 3) | ||
end | ||
|
||
@testset "Slice" begin | ||
X = rand(2, 3, 4, 5) | ||
Xs = @inferred Slices(X, True(), False(), False(), False()) | ||
|
||
Xs = Slices(X, 1) | ||
@test size(Xs) == (3, 4, 5) | ||
@test Xs[1, 1, 1] == X[:, 1, 1, 1] | ||
|
||
Xs = Slices(X, 2) | ||
@test size(Xs) == (2, 4, 5) | ||
@test Xs[1, 1, 1] == X[1, :, 1, 1] | ||
|
||
Xs = Slices(X, 1, 3) | ||
@test size(Xs) == (3, 5) | ||
@test Xs[1, 2] == X[:, 1, :, 2] | ||
@test Align(Xs, 1, 3) == X # Slices is the inverse of Align | ||
@test Xs[1] == X[:, 1, :, 1] # test linear indexing | ||
@test Xs[1, 3] == X[:, 1, :, 3] # test cartesian indexing | ||
|
||
# type is not inferrable for integer alongs | ||
RT = Base.return_types(Slices, (typeof(X), Int, Int))[1] | ||
@test !isconcretetype(RT) | ||
@test Slices(X, True(), False(), True(), False()) == Slices(X, 1, 3) | ||
|
||
# X = rand(2, 3, 4, 5) | ||
# @test_throws ArgumentError Slices(X, True()) | ||
# @test_throws ArgumentError Slices(X, True(), False(), False(), False(), False()) | ||
# @test_throws ArgumentError Slices(X, 5) | ||
end | ||
end |