Skip to content

Commit 0eeac7a

Browse files
committed
add only function to fix 1.3 compat
1 parent f1ab042 commit 0eeac7a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/util.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,18 @@ Loess.loess(x::AbstractVector, y::AbstractVector; kwargs...) =
455455
loess(collect.(zip(promote.(x,y)...))...; kwargs...)
456456

457457

458-
expnorm(x) = exp.(x .- maximum(x))
458+
expnorm(x) = exp.(x .- maximum(x))
459+
460+
if VERSION<v"1.4"
461+
Base.@propagate_inbounds function only(x)
462+
i = iterate(x)
463+
@boundscheck if i === nothing
464+
throw(ArgumentError("Collection is empty, must contain exactly 1 element"))
465+
end
466+
(ret, state) = i
467+
@boundscheck if iterate(x, state) !== nothing
468+
throw(ArgumentError("Collection has multiple elements, must contain exactly 1 element"))
469+
end
470+
return ret
471+
end
472+
end

0 commit comments

Comments
 (0)