Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Base.one(::Angle2d) method and etc. #195

Merged
merged 2 commits into from
Nov 16, 2021

Conversation

hyrodium
Copy link
Collaborator

This PR fixes #194.

Before this PR

julia> one(Angle2d(0.1))
ERROR: MethodError: Cannot `convert` an object of type NTuple{4, Float64} to an object of type Float64
Closest candidates are:
  convert(::Type{T}, ::Base.TwicePrecision) where T<:Number at twiceprecision.jl:250
  convert(::Type{T}, ::AbstractChar) where T<:Number at char.jl:180
  convert(::Type{T}, ::CartesianIndex{1}) where T<:Number at multidimensional.jl:136
  ...
Stacktrace:
 [1] Angle2d{Float64}(theta::NTuple{4, Float64})
   @ Rotations ~/.julia/dev/Rotations/src/core_types.jl:163
 [2] _construct_sametype
   @ ~/.julia/dev/StaticArrays/src/linalg.jl:97 [inlined]
 [3] _one(s::Size{(2, 2)}, m_or_SM::Angle2d{Float64})
   @ StaticArrays ~/.julia/dev/StaticArrays/src/linalg.jl:106
 [4] one(m::Angle2d{Float64})
   @ StaticArrays ~/.julia/dev/StaticArrays/src/linalg.jl:99
 [5] top-level scope
   @ REPL[10]:1

julia> one(RotXY(1,2))
ERROR: Cannot construct a two-axis rotation from a matrix
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] RotXY
   @ ~/.julia/dev/Rotations/src/euler_types.jl:240 [inlined]
 [3] _construct_sametype
   @ ~/.julia/dev/StaticArrays/src/linalg.jl:97 [inlined]
 [4] _one(s::Size{(3, 3)}, m_or_SM::RotXY{Float64})
   @ StaticArrays ~/.julia/dev/StaticArrays/src/linalg.jl:106
 [5] one(m::RotXY{Float64})
   @ StaticArrays ~/.julia/dev/StaticArrays/src/linalg.jl:99
 [6] top-level scope
   @ REPL[29]:1

After this PR

julia> one(Angle2d(0.1))
2×2 Angle2d{Float64} with indices SOneTo(2)×SOneTo(2)(0.0):
 1.0  -0.0
 0.0   1.0

julia> one(RotXY(1,2))
3×3 RotXY{Float64} with indices SOneTo(3)×SOneTo(3)(0.0, 0.0):
  1.0  0.0   0.0
  0.0  1.0  -0.0
 -0.0  0.0   1.0

@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #195 (43077e8) into master (15d1c32) will decrease coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
- Coverage   86.12%   85.92%   -0.21%     
==========================================
  Files          14       14              
  Lines        1341     1343       +2     
==========================================
- Hits         1155     1154       -1     
- Misses        186      189       +3     
Impacted Files Coverage Δ
src/core_types.jl 90.44% <100.00%> (+0.14%) ⬆️
src/euler_types.jl 91.68% <0.00%> (-0.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15d1c32...43077e8. Read the comment docs.

@hyrodium hyrodium merged commit f13326d into JuliaGeometry:master Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

one(Angle2d(0.1)) returns error
1 participant