diff --git a/Project.toml b/Project.toml index 28100ad..8e9dfbf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Quaternions" uuid = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0" -version = "0.7.0-DEV" +version = "0.7.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/Quaternion.jl b/src/Quaternion.jl index 490a3b3..7ce5c45 100644 --- a/src/Quaternion.jl +++ b/src/Quaternion.jl @@ -23,14 +23,6 @@ Quaternion{T}(x::Real) where {T<:Real} = Quaternion(convert(T, x)) Quaternion{T}(q::Quaternion) where {T<:Real} = Quaternion{T}(q.s, q.v1, q.v2, q.v3) Quaternion(s::Real, v1::Real, v2::Real, v3::Real) = Quaternion(promote(s, v1, v2, v3)...) Quaternion(x::Real) = Quaternion(x, zero(x), zero(x), zero(x)) -function Quaternion(s::Real, a::AbstractVector) - Base.depwarn("`Quaternion(s::Real, a::AbstractVector)` is deprecated and will be removed in the next breaking release (v0.7.0). Please use `Quaternion(s, a[1], a[2], a[3])` instead.", :Quaternion) - Quaternion(s, a[1], a[2], a[3]) -end -function Quaternion(a::AbstractVector) - Base.depwarn("`Quaternion(a::AbstractVector)` is deprecated and will be removed in the next breaking release (v0.7.0). Please use `Quaternion(0, a[1], a[2], a[3])` instead.", :Quaternion) - Quaternion(0, a[1], a[2], a[3]) -end Base.promote_rule(::Type{Quaternion{T}}, ::Type{S}) where {T <: Real, S <: Real} = Quaternion{promote_type(T, S)} Base.promote_rule(::Type{Quaternion{T}}, ::Type{Quaternion{S}}) where {T <: Real, S <: Real} = Quaternion{promote_type(T, S)} @@ -48,15 +40,23 @@ Quaternion{Int64}(7, 0, 0, 0) julia> quat(1.0, 2, 3, 4) QuaternionF64(1.0, 2.0, 3.0, 4.0) -julia> quat([1, 2, 3]) # This output will be changed in the next breaking release for consistency. (#94) -Quaternion{Int64}(0, 1, 2, 3) +julia> quat([1, 2, 3]) +3-element Vector{Quaternion{Int64}}: + Quaternion{Int64}(1, 0, 0, 0) + Quaternion{Int64}(2, 0, 0, 0) + Quaternion{Int64}(3, 0, 0, 0) ``` """ quat quat(p, v1, v2, v3) = Quaternion(p, v1, v2, v3) quat(x) = Quaternion(x) -quat(s, a) = Quaternion(s, a) +function quat(A::AbstractArray{T}) where T + if !isconcretetype(T) + error("`quat` not defined on abstractly-typed arrays; please convert to a more specific type") + end + convert(AbstractArray{typeof(quat(zero(T)))}, A) +end """ real(T::Type{<:Quaternion}) diff --git a/test/Quaternion.jl b/test/Quaternion.jl index 5895a43..2beba43 100644 --- a/test/Quaternion.jl +++ b/test/Quaternion.jl @@ -49,12 +49,6 @@ end @test @inferred(Quaternion(q)) === q end end - @testset "from vector" begin - s = randn() - v = randn(3) - @test @inferred(Quaternion(s, v)) === Quaternion(s, v...) - @test @inferred(Quaternion(v)) === Quaternion(0, v) - end end @testset "==" begin @@ -90,9 +84,8 @@ end @test quat(1) === Quaternion(1) @test quat(1, 2, 3, 4) === Quaternion(1, 2, 3, 4) @test quat(Quaternion(1, 2, 3, 4)) === Quaternion(1, 2, 3, 4) - @test quat(1, [2, 3, 4]) === Quaternion(1, 2, 3, 4) - @test quat([2, 3, 4]) === Quaternion(0, 2, 3, 4) - @test_deprecated quat([2, 3, 4]) + @test quat([2, 3, 4]) == Quaternion{Int}[2, 3, 4] + @test_throws ErrorException quat(Real[1,2,3]) end @testset "random generation" begin