From 362e962d1e1dbcd44975426461a4784e77e596e9 Mon Sep 17 00:00:00 2001 From: "Tamas K. Papp" Date: Tue, 27 Sep 2022 16:00:30 +0200 Subject: [PATCH] make transformations on AbstractVector return SVector (#39) --- Project.toml | 2 +- src/transformations.jl | 4 ++-- test/test_transformations.jl | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index f865c45..e3f6493 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SpectralKit" uuid = "5c252ae7-b5b6-46ab-a016-b0e3d78320b7" authors = ["Tamas K. Papp "] -version = "0.10.0" +version = "0.11.0" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" diff --git a/src/transformations.jl b/src/transformations.jl index d821e7e..d1e8bb0 100644 --- a/src/transformations.jl +++ b/src/transformations.jl @@ -110,7 +110,7 @@ function to_pm1(ct::CoordinateTransformations, x::Tuple) end function to_pm1(ct::CoordinateTransformations, x::AbstractVector) - to_pm1(ct, Tuple(x)) + SVector(to_pm1(ct, Tuple(x))) end function from_pm1(ct::CoordinateTransformations, x::Tuple) @@ -119,7 +119,7 @@ function from_pm1(ct::CoordinateTransformations, x::Tuple) end function from_pm1(ct::CoordinateTransformations, x::AbstractVector) - from_pm1(ct, Tuple(x)) + SVector(from_pm1(ct, Tuple(x))) end #### diff --git a/test/test_transformations.jl b/test/test_transformations.jl index f091e97..ea1d3fb 100644 --- a/test/test_transformations.jl +++ b/test/test_transformations.jl @@ -60,15 +60,15 @@ end ct = coordinate_transformations(t1, t2) x = SVector(rand_pm1(), rand_pm1()) y = @inferred from_pm1(ct, x) - @test y isa NTuple{2,Float64} - @test y == (from_pm1(t1, x[1]), from_pm1(t2, x[2])) + @test y isa SVector{2,Float64} + @test y == SVector(from_pm1(t1, x[1]), from_pm1(t2, x[2])) # handle generic inputs y2 = @inferred from_pm1(ct, Vector(x)) - @test y2 isa NTuple{2,Float64} && y2 == y + @test y2 isa SVector{2,Float64} && y2 == y x2 = @inferred to_pm1(ct, [y...]) - @test x2 isa NTuple{2,Float64} && all(x2 .≈ x) + @test x2 isa SVector{2,Float64} && all(x2 .≈ x) end @testset "partial application" begin