Skip to content

Commit 5327006

Browse files
committed
fix vector pos not parsing correctly
1 parent 4723863 commit 5327006

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/core.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ function _position(nt::NamedTuple{(:r, :theta)})
4242
th_rad = deg2rad(nt.theta)
4343
return CartesianFromPolar()(Polar(nt.r, th_rad))
4444
end
45-
_position(nt::NamedTuple{(:pos,)}) = SVector(nt.pos)
45+
_position(nt::NamedTuple{(:pos,)}) = _position(nt.pos)
46+
_position(pos::AbstractVector) = SVector{length(pos)}(pos)
47+
_position(pos::SVector) = pos
48+
_position(pos::Tuple) = SVector(pos)
4649
_position(nt::NamedTuple{(:x, :y)}) = SA[nt.x, nt.y]
4750
_position(nt::NamedTuple{()}) = SA[0, 0]
4851

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function test_model_interface(K)
2929

3030
# test new position
3131
m = K(x=12, y=13, fwhm=10)
32-
@test m == K(pos=(12, 13), fwhm=10) == K(pos=SA[12, 13], fwhm=10)
32+
@test m == K(pos=(12, 13), fwhm=10) == K(pos=SA[12, 13], fwhm=10) == K(pos=[12, 13], fwhm=10)
3333
@test size(m) == (31, 31)
3434
@test axes(m) == (-2:28, -3:27)
3535
@test m.pos SA[12, 13]

0 commit comments

Comments
 (0)