Skip to content

Commit 659e16e

Browse files
sjkellyhyrodium
andauthored
fix bounds error reporting (#250)
* fix bounds error reporting and add tests * Update test/unitquat.jl Co-authored-by: Yuto Horikawa <[email protected]> Co-authored-by: Yuto Horikawa <[email protected]>
1 parent 88fb790 commit 659e16e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/core_types.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ function isrotation(r::StaticMatrix{N,N,T}, tol::Real = 1000 * _isrotation_eps(e
216216
end
217217

218218
function isrotation(r::AbstractMatrix{T}, tol::Real = 1000 * _isrotation_eps(eltype(T))) where T<:Real
219-
if !=(size(r)...)
219+
s = size(r)
220+
if s[1] != s[2]
220221
return false
221222
end
222223
d = norm(r*r'-one(r))

src/unitquaternion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function Base.getindex(q::QuatRotation, i::Int)
173173

174174
ww - xx - yy + zz
175175
else
176-
throw(BoundsError(r,i))
176+
throw(BoundsError(q,i))
177177
end
178178
end
179179

test/unitquat.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import Rotations: vmat, rmult, lmult, hmat, tmat
1717
@test QuatRotation(1, 0, 0, 0) isa QuatRotation{Float64}
1818
@test QuatRotation(1.0f0, 0, 0, 0) isa QuatRotation{Float32}
1919

20+
# indexing
21+
qi = QuatRotation(1, 0, 0, 0)
22+
@test qi[1] == 1.0
23+
@test qi[6] == 0.0
24+
@test qi[5] == 1.0
25+
@test_throws BoundsError qi[10]
26+
2027
q = normalize(@SVector rand(4))
2128
q32 = SVector{4,Float32}(q)
2229
@test QuatRotation(q) isa QuatRotation{Float64}

0 commit comments

Comments
 (0)