Skip to content

Commit

Permalink
make transformations on AbstractVector return SVector (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp authored Sep 27, 2022
1 parent 154e052 commit 362e962
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SpectralKit"
uuid = "5c252ae7-b5b6-46ab-a016-b0e3d78320b7"
authors = ["Tamas K. Papp <[email protected]>"]
version = "0.10.0"
version = "0.11.0"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
4 changes: 2 additions & 2 deletions src/transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

####
Expand Down
8 changes: 4 additions & 4 deletions test/test_transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 362e962

@tpapp
Copy link
Owner Author

@tpapp tpapp commented on 362e962 Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/69056

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.0 -m "<description of version>" 362e962d1e1dbcd44975426461a4784e77e596e9
git push origin v0.11.0

Please sign in to comment.