Skip to content

Commit

Permalink
Address comments and fix diagm depwarn.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoolen committed Mar 25, 2018
1 parent 6720803 commit d7763e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/core_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,7 @@ end

# Removes module name from output, to match other types
function Base.summary(r::Rotation{N,T}) where {T,N}
"$N×$N $(typeof(r).name.name){$(eltype(r))}"
inds = indices(r)
typestring = last(split(string(typeof(r)), '.'; limit = 2))
string(Base.dims2string(length.(inds)), " ", typestring)
end
13 changes: 0 additions & 13 deletions test/2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,6 @@ using Rotations, StaticArrays, Compat.Test
@test R * R T[0 -1; 1 0]
end
end

@testset "show" begin
io = IOBuffer()
r = rand(RotMatrix{2})
show(io, MIME("text/plain"), r)
str = String(take!(io))
@test startswith(str, "2×2 RotMatrix{Float64}:")

rxyz = RotXYZ(1.0, 2.0, 3.0)
show(io, MIME("text/plain"), rxyz)
str = String(take!(io))
@test startswith(str, "3×3 RotXYZ{Float64}(1.0, 2.0, 3.0):")
end
end

nothing
15 changes: 14 additions & 1 deletion test/rotation_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ all_types = (RotMatrix{3}, Quat, SPQuat, AngleAxis, RodriguesVec,
#########################################################################
function nearest_orthonormal(not_orthonormal)
u,s,v = svd(not_orthonormal)
return u * diagm([1, 1, sign(det(u * transpose(v)))]) * transpose(v)
return u * Diagonal([1, 1, sign(det(u * transpose(v)))]) * transpose(v)
end

@testset "DCM to Quat" begin
Expand Down Expand Up @@ -302,4 +302,17 @@ all_types = (RotMatrix{3}, Quat, SPQuat, AngleAxis, RodriguesVec,
rot = eye(RotMatrix{3, Float64})
@inferred Tuple(rot)
end

@testset "Testing show" begin
io = IOBuffer()
r = rand(RotMatrix{2})
show(io, MIME("text/plain"), r)
str = String(take!(io))
@test startswith(str, "2×2 RotMatrix{2,Float64,4}:")

rxyz = RotXYZ(1.0, 2.0, 3.0)
show(io, MIME("text/plain"), rxyz)
str = String(take!(io))
@test startswith(str, "3×3 RotXYZ{Float64}(1.0, 2.0, 3.0):")
end
end

0 comments on commit d7763e0

Please sign in to comment.