Skip to content

Commit

Permalink
Add deprecated messages for DualQuaternion (#93)
Browse files Browse the repository at this point in the history
* add deprecated messages for DualQuaternion

* add `@test_deprecated` for DualQuaternion

* update depwarn messages for DualQuaternion

* update tests for DualQuaternion

* remove unnecessary type limitation in the DualQuaternion constructor

* add <: Real parameter in the DualQuaternion constructor
  • Loading branch information
hyrodium authored Sep 20, 2022
1 parent bf302ae commit 4cfb55d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DualQuaternion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ struct DualQuaternion{T<:Real} <: Number
q0::Quaternion{T}
qe::Quaternion{T}
norm::Bool
function DualQuaternion{T}(q0, qe, norm) where T <: Real
Base.depwarn("`DualQuaternion` is deprecated and will be removed in the next breaking release. Use `Quaternion{ForwardDiff.Dual}` instead.", :DualQuaternion)
return new{T}(q0, qe, norm)
end
end

function DualQuaternion(q0::Quaternion{T}, qe::Quaternion{T}, norm::Bool) where T <: Real
return DualQuaternion{T}(q0, qe, norm)
end

DualQuaternion{T}(dq::DualQuaternion) where {T<:Real} = DualQuaternion{T}(dq.q0, dq.qe, dq.norm)
Expand Down
6 changes: 6 additions & 0 deletions test/DualQuaternion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ end
DualQuaternion(Quaternion(1.0, 2, 3, 4), Quaternion(1, 2, 3, 4))
end

@testset "deprecated warning" begin
@test_deprecated DualQuaternion(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8))
@test_deprecated DualQuaternion{Int}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false)
@test_deprecated DualQuaternion{Float64}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false)
end

@testset "convert" begin
@test convert(DualQuaternion{Float64}, 1) === DualQuaternion(1.0)
@test convert(DualQuaternion{Float64}, DualNumbers.Dual(1, 2)) ===
Expand Down

0 comments on commit 4cfb55d

Please sign in to comment.