Skip to content

Commit a4d227c

Browse files
authored
Deprecate quatrand and nquatrand (#125)
* remove Rational in randn * deprecate quatrand and nquatrand * remove exports, quatrand and nquatrand * add `@test_deprecated` for quatrand and nquatrand
1 parent 6cba417 commit a4d227c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Quaternion.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,19 @@ end
325325

326326
Base.:^(q::Quaternion, w::Quaternion) = exp(w * log(q))
327327

328-
quatrand(rng = Random.GLOBAL_RNG) = quat(randn(rng), randn(rng), randn(rng), randn(rng))
329-
nquatrand(rng = Random.GLOBAL_RNG) = sign(quatrand(rng))
328+
Base.@deprecate quatrand(rng::AbstractRNG=Random.GLOBAL_RNG) randn(rng, QuaternionF64) * 2
329+
Base.@deprecate nquatrand(rng = Random.GLOBAL_RNG) sign(randn(rng, QuaternionF64))
330330

331331
function Base.rand(rng::AbstractRNG, ::Random.SamplerType{Quaternion{T}}) where {T<:Real}
332332
Quaternion{T}(rand(rng, T), rand(rng, T), rand(rng, T), rand(rng, T))
333333
end
334334

335335
function Base.randn(rng::AbstractRNG, ::Type{Quaternion{T}}) where {T<:AbstractFloat}
336336
Quaternion{T}(
337-
randn(rng, T) * 1//2,
338-
randn(rng, T) * 1//2,
339-
randn(rng, T) * 1//2,
340-
randn(rng, T) * 1//2,
337+
randn(rng, T) / 2,
338+
randn(rng, T) / 2,
339+
randn(rng, T) / 2,
340+
randn(rng, T) / 2,
341341
)
342342
end
343343

src/Quaternions.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export Quaternion
1010
export QuaternionF16, QuaternionF32, QuaternionF64
1111
export quat
1212
export imag_part
13-
export quatrand
14-
export nquatrand
1513
export slerp
1614

1715
end # module

test/Quaternion.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ end
9797

9898
@testset "random generation" begin
9999
@testset "quatrand" begin
100+
@test_deprecated quatrand()
100101
rng = Random.MersenneTwister(42)
101102
q1 = quatrand(rng)
102103
@test q1 isa Quaternion
@@ -106,6 +107,7 @@ end
106107
end
107108

108109
@testset "nquatrand" begin
110+
@test_deprecated nquatrand()
109111
rng = Random.MersenneTwister(42)
110112
q1 = nquatrand(rng)
111113
@test q1 isa Quaternion

0 commit comments

Comments
 (0)