From d7763e0012be367b3aa4dd540fe8af737557ce6b Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Sun, 25 Mar 2018 12:38:29 -0400 Subject: [PATCH] Address comments and fix diagm depwarn. --- src/core_types.jl | 4 +++- test/2d.jl | 13 ------------- test/rotation_tests.jl | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/core_types.jl b/src/core_types.jl index 1b2e60e4..599541d3 100644 --- a/src/core_types.jl +++ b/src/core_types.jl @@ -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 diff --git a/test/2d.jl b/test/2d.jl index 25bb9d3e..0249b4e6 100644 --- a/test/2d.jl +++ b/test/2d.jl @@ -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 diff --git a/test/rotation_tests.jl b/test/rotation_tests.jl index 18d5b905..de5518a5 100644 --- a/test/rotation_tests.jl +++ b/test/rotation_tests.jl @@ -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 @@ -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