Skip to content

Commit 0f57093

Browse files
hyrodiumsethaxen
andauthored
update quat(::Array) to return Array{<:Quaternion} (#95)
* add docsting to quat * update quat(::Array) to return Array{<:Quaternion} * remove deprecated methods such as `Quaternion(s::Real, a::AbstractVector)` * update tests * bump version to v0.7.0 * fix jldoctest * fix docstring * fix docstring * Remove unnecessary `quat` method Co-authored-by: Seth Axen <seth@sethaxen.com> * add test for quat(Real[1,2,3]) Co-authored-by: Seth Axen <seth@sethaxen.com>
1 parent 3ab59a0 commit 0f57093

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Quaternions"
22
uuid = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
3-
version = "0.7.0-DEV"
3+
version = "0.7.0"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/Quaternion.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ Quaternion{T}(x::Real) where {T<:Real} = Quaternion(convert(T, x))
2323
Quaternion{T}(q::Quaternion) where {T<:Real} = Quaternion{T}(q.s, q.v1, q.v2, q.v3)
2424
Quaternion(s::Real, v1::Real, v2::Real, v3::Real) = Quaternion(promote(s, v1, v2, v3)...)
2525
Quaternion(x::Real) = Quaternion(x, zero(x), zero(x), zero(x))
26-
function Quaternion(s::Real, a::AbstractVector)
27-
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)
28-
Quaternion(s, a[1], a[2], a[3])
29-
end
30-
function Quaternion(a::AbstractVector)
31-
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)
32-
Quaternion(0, a[1], a[2], a[3])
33-
end
3426

3527
Base.promote_rule(::Type{Quaternion{T}}, ::Type{S}) where {T <: Real, S <: Real} = Quaternion{promote_type(T, S)}
3628
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)
4840
julia> quat(1.0, 2, 3, 4)
4941
QuaternionF64(1.0, 2.0, 3.0, 4.0)
5042
51-
julia> quat([1, 2, 3]) # This output will be changed in the next breaking release for consistency. (#94)
52-
Quaternion{Int64}(0, 1, 2, 3)
43+
julia> quat([1, 2, 3])
44+
3-element Vector{Quaternion{Int64}}:
45+
Quaternion{Int64}(1, 0, 0, 0)
46+
Quaternion{Int64}(2, 0, 0, 0)
47+
Quaternion{Int64}(3, 0, 0, 0)
5348
```
5449
"""
5550
quat
5651

5752
quat(p, v1, v2, v3) = Quaternion(p, v1, v2, v3)
5853
quat(x) = Quaternion(x)
59-
quat(s, a) = Quaternion(s, a)
54+
function quat(A::AbstractArray{T}) where T
55+
if !isconcretetype(T)
56+
error("`quat` not defined on abstractly-typed arrays; please convert to a more specific type")
57+
end
58+
convert(AbstractArray{typeof(quat(zero(T)))}, A)
59+
end
6060

6161
"""
6262
real(T::Type{<:Quaternion})

test/Quaternion.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ end
4949
@test @inferred(Quaternion(q)) === q
5050
end
5151
end
52-
@testset "from vector" begin
53-
s = randn()
54-
v = randn(3)
55-
@test @inferred(Quaternion(s, v)) === Quaternion(s, v...)
56-
@test @inferred(Quaternion(v)) === Quaternion(0, v)
57-
end
5852
end
5953

6054
@testset "==" begin
@@ -90,9 +84,8 @@ end
9084
@test quat(1) === Quaternion(1)
9185
@test quat(1, 2, 3, 4) === Quaternion(1, 2, 3, 4)
9286
@test quat(Quaternion(1, 2, 3, 4)) === Quaternion(1, 2, 3, 4)
93-
@test quat(1, [2, 3, 4]) === Quaternion(1, 2, 3, 4)
94-
@test quat([2, 3, 4]) === Quaternion(0, 2, 3, 4)
95-
@test_deprecated quat([2, 3, 4])
87+
@test quat([2, 3, 4]) == Quaternion{Int}[2, 3, 4]
88+
@test_throws ErrorException quat(Real[1,2,3])
9689
end
9790

9891
@testset "random generation" begin

0 commit comments

Comments
 (0)