Skip to content

Commit ce69d4d

Browse files
kshyattandyferris
authored andcommitted
Fix bug in Scalar convert and add test (#219)
1 parent e7010b1 commit ce69d4d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Scalar.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Scalar{T} = SArray{Tuple{},T,0,1}
1010
@inline Scalar(a::AbstractArray) = Scalar{typeof(a)}((a,))
1111
@inline Scalar(a::AbstractScalar) = Scalar{eltype(a)}((a[],)) # Do we want this to convert or wrap?
1212
@inline function convert(::Type{SA}, a::AbstractArray) where {SA <: Scalar}
13-
return SA((a,))
13+
return SA((a[],))
1414
end
1515

1616
getindex(v::Scalar) = v.data[1]

test/Scalar.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
@test_throws ErrorException Scalar(2)[2]
66
@test Scalar(2)[] == 2
77
@test Tuple(Scalar(2)) == (2,)
8+
@test Tuple(convert(Scalar{Float64}, [2.0])) == (2.0,)
89
end

0 commit comments

Comments
 (0)