Skip to content

Commit 60a8ebd

Browse files
authored
remove some ambiguities (#236)
* remove some ambiguities * update test
1 parent 524f61d commit 60a8ebd

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/euler_types.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ for axis in [:X, :Y, :Z]
1414
@eval begin
1515
struct $RotType{T} <: Rotation{3,T}
1616
theta::T
17-
$RotType{T}(theta) where {T} = new{T}(theta)
17+
$RotType{T}(theta::Number) where {T} = new{T}(theta)
1818
$RotType{T}(r::$RotType) where {T} = new{T}(r.theta)
1919
end
2020

21-
@inline function $RotType(theta)
21+
@inline function $RotType(theta::Number)
2222
$RotType{rot_eltype(typeof(theta))}(theta)
2323
end
2424
@inline $RotType(r::$RotType{T}) where {T} = $RotType{T}(r)

src/rotation_generator.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Base.one(::Type{<:RotationGenerator{N,T}}) where {N,T} = one(SMatrix{N,N,T})
2222
Base.ones(::Type{R}) where {R<:RotationGenerator} = ones(R, ()) # avoid StaticArray constructor
2323
Base.ones(::Type{R}, dims::Base.DimOrInd...) where {R<:RotationGenerator} = ones(typeof(one(R)),dims...)
2424
Base.ones(::Type{R}, dims::NTuple{N, Integer}) where {R<:RotationGenerator, N} = ones(typeof(one(R)),dims)
25+
Base.ones(::Type{R}, dims::Tuple{}) where {R<:RotationGenerator} = ones(typeof(one(R)),dims)
2526

2627
# Generate zero rotation matrix
2728
Base.zero(r::RotationGenerator) = zero(typeof(r))
@@ -124,7 +125,7 @@ A 2×2 rotation generator matrix (i.e. skew-symmetric matrix).
124125
"""
125126
struct Angle2dGenerator{T} <: RotationGenerator{2,T}
126127
v::T
127-
Angle2dGenerator{T}(r) where T = new{T}(r)
128+
Angle2dGenerator{T}(r::Number) where T = new{T}(r)
128129
end
129130

130131
@inline function Angle2dGenerator(r::T) where T <: Number

src/unitquaternion.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ end
7474
check_length(q, 4)
7575
Q(q[1], q[2], q[3], q[4], normalize)
7676
end
77-
@inline (::Type{Q})(q::StaticVector{4}, normalize::Bool = true) where Q <: QuatRotation =
77+
@inline function (::Type{Q})(q::StaticVector{4}, normalize::Bool = true) where Q <: QuatRotation
7878
Q(q[1], q[2], q[3], q[4], normalize)
79+
end
7980

8081
# Copy constructors
8182
QuatRotation(q::QuatRotation) = q

test/rotation_generator.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
r = one(T)
5252
@test r isa SMatrix
5353
@test r == one(r)
54+
@test ones(T,()) isa Array{typeof(one(T)), 0}
5455
@test ones(T,2,3) == [one(T) for i in 1:2, j in 1:3]
5556
@test ones(T{BigFloat},2,3) == [one(T{BigFloat}) for i in 1:2, j in 1:3]
5657
@test ones(T,(2,3)) == [one(T) for i in 1:2, j in 1:3]

0 commit comments

Comments
 (0)