Skip to content

Commit

Permalink
Add Aqua.jl in test (#238)
Browse files Browse the repository at this point in the history
* add method for QuatRotation to remove ambiguities

* add Aqua.jl

* add ForwardDiff in test/Project.toml

* add BenchmarkTools in test/Project.toml

* add tests for QuatRotation(SVector(1, 2, 3, 4, 5))
  • Loading branch information
hyrodium authored Sep 10, 2022
1 parent e34142d commit 44f7ade
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
10 changes: 0 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,3 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Quaternions = "0.5.3"
StaticArrays = "1.2.12"
julia = "1.6"

[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["BenchmarkTools", "ForwardDiff", "Test", "InteractiveUtils", "Unitful"]
4 changes: 4 additions & 0 deletions src/unitquaternion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ end
@inline function (::Type{Q})(q::StaticVector{4}, normalize::Bool = true) where Q <: QuatRotation
Q(q[1], q[2], q[3], q[4], normalize)
end
function (::Type{Q})(q::StaticArray{S, T, 1} where {S<:Tuple, T}, normalize::Bool = true) where Q <: QuatRotation
# This method is just for avoiding ambiguities.
error("The input vector $q must have 4 elements.")
end

# Copy constructors
QuatRotation(q::QuatRotation) = q
Expand Down
14 changes: 14 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
Aqua = "0.5"
7 changes: 2 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ using Rotations
using StaticArrays
using InteractiveUtils: subtypes
using Quaternions
using Aqua
import Unitful

import Random

# Check that there are no ambiguities beyond those present in StaticArrays
ramb = detect_ambiguities(Rotations, Base, Core)
samb = detect_ambiguities(StaticArrays, Base, Core)
@test isempty(setdiff(ramb, samb))
Aqua.test_all(Rotations)

include("util_tests.jl")
include("2d.jl")
Expand Down
2 changes: 2 additions & 0 deletions test/unitquat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import Rotations: vmat, rmult, lmult, hmat, tmat
@test 2 * q == 2 * Matrix(q)
@test q * 2 == 2 * Matrix(q)

@test_throws ErrorException QuatRotation(SVector(1, 2, 3, 4, 5))

# Axis-angle
ϕ = 0.1 * @SVector [1, 0, 0]
q = expm(ϕ)
Expand Down

0 comments on commit 44f7ade

Please sign in to comment.