Skip to content

Fix undefined reference error when type widening #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 21, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ function transitions(
N::Integer;
kwargs...
)
return Vector{typeof(transition)}(undef, N)
ts = Vector{typeof(transition)}(undef, 0)
sizehint!(ts, N)
return ts
end

function transitions(
Expand All @@ -112,7 +114,7 @@ function transitions(
::AbstractSampler;
kwargs...
)
return Vector{typeof(transition)}(undef, 1)
return Vector{typeof(transition)}(undef, 0)
end

"""
Expand All @@ -133,10 +135,12 @@ function save!!(
iteration::Integer,
::AbstractModel,
::AbstractSampler,
::Integer;
N::Integer;
kwargs...
)
return BangBang.setindex!!(transitions, transition, iteration)
new_ts = BangBang.push!!(transitions, transition)
typeof(new_ts) !== typeof(transitions) && Base.sizehint!(new_ts, N)
return new_ts
end

function save!!(
Expand All @@ -154,4 +158,3 @@ Base.@deprecate transitions_init(transition, model::AbstractModel, sampler::Abst
Base.@deprecate transitions_init(transition, model::AbstractModel, sampler::AbstractSampler; kwargs...) transitions(transition, model, sampler; kwargs...) false
Base.@deprecate transitions_save!(transitions, iteration::Integer, transition, model::AbstractModel, sampler::AbstractSampler; kwargs...) save!!(transitions, transition, iteration, model, sampler; kwargs...) false
Base.@deprecate transitions_save!(transitions, iteration::Integer, transition, model::AbstractModel, sampler::AbstractSampler, N::Integer; kwargs...) save!!(transitions, transition, iteration, model, sampler, N; kwargs...) false