Skip to content

Commit

Permalink
reapply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoStrouwen committed Feb 22, 2024
1 parent 0fb731b commit f5b3776
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
style = "sciml"
format_markdown = true
format_markdown = true
format_docstrings = true
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/EllipsisNotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)...))
Expand Down
30 changes: 15 additions & 15 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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) ==
Expand Down

0 comments on commit f5b3776

Please sign in to comment.