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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticArrays"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.9.18"
version = "1.9.19"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
4 changes: 2 additions & 2 deletions src/SArray.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

@noinline function generator_too_short_error(inds::CartesianIndices, i::CartesianIndex)
error("Generator produced too few elements: Expected exactly $(shape_string(inds)) elements, but generator stopped at $(shape_string(i))")
n = LinearIndices(inds)[i] - 1
error("Generator produced too few elements: Expected exactly $(shape_string(inds)) elements, but got $(n)")
end
@noinline function generator_too_long_error(inds::CartesianIndices)
error("Generator produced too many elements: Expected exactly $(shape_string(inds)) elements, but generator yields more")
end

shape_string(inds::CartesianIndices) = join(length.(inds.indices), '×')
shape_string(inds::CartesianIndex) = join(Tuple(inds), '×')

@inline throw_if_nothing(x, inds, i) =
(x === nothing && generator_too_short_error(inds, i); x)
Expand Down
33 changes: 33 additions & 0 deletions test/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,39 @@
@test_throws Exception SArray{Tuple{2,3}}(10i+j for i in 1:1, j in 1:3)
@test_throws Exception SArray{Tuple{2,3}}(10i+j for i in 1:3, j in 1:3)

# too-short error reports the count produced, not the failing coordinate (#1207)
# (@test_throws "msg" needs Julia 1.8+; package supports 1.6)
let err = try
SVector{5}(i for i in 1:5 if i != 2)
catch e
e
end
@test err isa Exception
msg = sprint(showerror, err)
@test occursin("Expected exactly 5 elements", msg)
@test occursin("got 4", msg)
@test !occursin("stopped at", msg)
end
let err = try
SMatrix{2,3}(i for i in 1:6 if i != 4)
catch e
e
end
@test err isa Exception
msg = sprint(showerror, err)
@test occursin("Expected exactly 2×3 elements", msg)
@test occursin("got 5", msg)
end
let err = try
SVector{3}(i for i in 1:0)
catch e
e
end
@test err isa Exception
@test occursin("got 0", sprint(showerror, err))
end
@test SVector{5}(i for i in 1:5) == SVector{5}(1, 2, 3, 4, 5)

@test StaticArrays.sacollect(SVector{6}, Iterators.product(1:2, 1:3)) ==
SVector{6}(collect(Iterators.product(1:2, 1:3)))
@test StaticArrays.sacollect(SVector{2}, Iterators.zip(1:2, 2:3)) ==
Expand Down
7 changes: 6 additions & 1 deletion test/expm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ using StaticArrays, Test, LinearAlgebra
for nB in (0.005, 0.1, 0.5, 3.0, 20.0)
B = A*nB/nA
SB = SMatrix{sz,sz,typ}(B)
@test exp(B) ≈ exp(SB)
if Sys.ARCH in (:x86_64, :i686) && VERSION >= v"1.12" && VERSION < v"1.13" && typ === ComplexF64
# Julia 1.12 has a bug that makes this test fail on some systems,
# see https://github.com/JuliaLang/julia/issues/62368
else
@test exp(B) ≈ exp(SB)
end
end
end
end
Loading