diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml index 9c79359..959ad88 100644 --- a/.JuliaFormatter.toml +++ b/.JuliaFormatter.toml @@ -1,2 +1,3 @@ style = "sciml" -format_markdown = true \ No newline at end of file +format_markdown = true +format_docstrings = true \ No newline at end of file diff --git a/README.md b/README.md index 82b3d51..ae1762b 100644 --- a/README.md +++ b/README.md @@ -25,24 +25,24 @@ using EllipsisNotation julia> A = Array{Int}(undef, 2, 4, 2) julia> A[.., 1] = [2 1 4 5 - 2 2 3 6] + 2 2 3 6] julia> A[.., 2] = [3 2 6 5 - 3 2 6 6] + 3 2 6 6] julia> A[:, :, 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] true julia> A[1, ..] = reshape([3 4 - 5 6 - 4 5 - 6 7], 1, 4, 2) # drops singleton dimension + 5 6 + 4 5 + 6 7], 1, 4, 2) # drops singleton dimension julia> B = [3 4 - 5 6 - 4 5 - 6 7] + 5 6 + 4 5 + 6 7] julia> B == reshape(A[1, ..], 4, 2) true diff --git a/docs/src/index.md b/docs/src/index.md index 9cd8c4d..e80f63f 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -23,24 +23,24 @@ using EllipsisNotation julia> A = Array{Int}(undef, 2, 4, 2) julia> A[.., 1] = [2 1 4 5 - 2 2 3 6] + 2 2 3 6] julia> A[.., 2] = [3 2 6 5 - 3 2 6 6] + 3 2 6 6] julia> A[:, :, 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] true julia> A[1, ..] = reshape([3 4 - 5 6 - 4 5 - 6 7], 1, 4, 2) # drops singleton dimension + 5 6 + 4 5 + 6 7], 1, 4, 2) # drops singleton dimension julia> B = [3 4 - 5 6 - 4 5 - 6 7] + 5 6 + 4 5 + 6 7] julia> B == reshape(A[1, ..], 4, 2) true diff --git a/src/EllipsisNotation.jl b/src/EllipsisNotation.jl index d22fd81..92a0cf1 100644 --- a/src/EllipsisNotation.jl +++ b/src/EllipsisNotation.jl @@ -24,25 +24,25 @@ possible confusion. julia> A = Array{Int}(undef, 2, 4, 2); julia> A[.., 1] = [2 1 4 5 - 2 2 3 6]; + 2 2 3 6]; julia> A[.., 2] = [3 2 6 5 - 3 2 6 6]; + 3 2 6 6]; julia> A[:, :, 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] true julia> A[1, ..] = reshape([3 4 - 5 6 - 4 5 - 6 7], 1, 4, 2) # drops singleton dimension + 5 6 + 4 5 + 6 7], 1, 4, 2) # drops singleton dimension ... julia> B = [3 4 - 5 6 - 4 5 - 6 7]; + 5 6 + 4 5 + 6 7]; julia> B == reshape(A[1, ..], 4, 2) true @@ -51,8 +51,8 @@ true const .. = Ellipsis() @inline function to_indices(A, - inds::NTuple{M, Any}, - I::Tuple{Ellipsis, Vararg{Any, N}}) where {M, N} + inds::NTuple{M, Any}, + I::Tuple{Ellipsis, Vararg{Any, N}}) where {M, N} # Align the remaining indices to the tail of the `inds` colons = ntuple(n -> Colon(), M - _ndims_index(I) + 1) to_indices(A, inds, (colons..., tail(I)...)) diff --git a/test/basic.jl b/test/basic.jl index e31aacc..8733167 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -5,35 +5,35 @@ using StaticArrayInterface A = Array{Int}(undef, 2, 4, 2) A[.., 1] = [2 1 4 5 - 2 2 3 6] + 2 2 3 6] A[.., 2] = [3 2 6 5 - 3 2 6 6] + 3 2 6 6] @test A[:, :, 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] @test A[:, :, 2] == [3 2 6 5 - 3 2 6 6] + 3 2 6 6] @test A[:, .., 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] @test A[:, .., 1] == [2 1 4 5 - 2 2 3 6] + 2 2 3 6] A[1, ..] = reshape([3 4 - 5 6 - 4 5 - 6 7], + 5 6 + 4 5 + 6 7], 1, 4, 2) B = [3 4 - 5 6 - 4 5 - 6 7] + 5 6 + 4 5 + 6 7] @test B == reshape(A[1, ..], 4, 2) == reshape(view(A, 1, ..), 4, 2) @@ -81,9 +81,9 @@ C[1, 1] += 1 StaticArrayInterface.setindex!(A, reshape([3 4; 5 6; 4 5; 6 7], 1, 4, 2), 1, ..) B = [3 4 - 5 6 - 4 5 - 6 7] + 5 6 + 4 5 + 6 7] @test B == reshape(StaticArrayInterface.getindex(A, 1, ..), 4, 2) ==