Skip to content

Commit 4cfb55d

Browse files
authored
Add deprecated messages for DualQuaternion (#93)
* 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
1 parent bf302ae commit 4cfb55d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/DualQuaternion.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ struct DualQuaternion{T<:Real} <: Number
44
q0::Quaternion{T}
55
qe::Quaternion{T}
66
norm::Bool
7+
function DualQuaternion{T}(q0, qe, norm) where T <: Real
8+
Base.depwarn("`DualQuaternion` is deprecated and will be removed in the next breaking release. Use `Quaternion{ForwardDiff.Dual}` instead.", :DualQuaternion)
9+
return new{T}(q0, qe, norm)
10+
end
11+
end
12+
13+
function DualQuaternion(q0::Quaternion{T}, qe::Quaternion{T}, norm::Bool) where T <: Real
14+
return DualQuaternion{T}(q0, qe, norm)
715
end
816

917
DualQuaternion{T}(dq::DualQuaternion) where {T<:Real} = DualQuaternion{T}(dq.q0, dq.qe, dq.norm)

test/DualQuaternion.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ end
111111
DualQuaternion(Quaternion(1.0, 2, 3, 4), Quaternion(1, 2, 3, 4))
112112
end
113113

114+
@testset "deprecated warning" begin
115+
@test_deprecated DualQuaternion(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8))
116+
@test_deprecated DualQuaternion{Int}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false)
117+
@test_deprecated DualQuaternion{Float64}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false)
118+
end
119+
114120
@testset "convert" begin
115121
@test convert(DualQuaternion{Float64}, 1) === DualQuaternion(1.0)
116122
@test convert(DualQuaternion{Float64}, DualNumbers.Dual(1, 2)) ===

0 commit comments

Comments
 (0)