Skip to content

Commit

Permalink
IO bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkreindler committed Jan 1, 2024
1 parent 20ce741 commit 1a74296
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/functions_estimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function fit_onestep(
# skip if output file already exists
if !opts.overwrite && (opts.path != "")

opt_results_from_file = read_fit(opts)
opt_results_from_file = read_fit(opts.path, subpath=opts.subpath)

if !isnothing(opt_results_from_file)
println(" Results file already exists. Reading from file.")
Expand Down Expand Up @@ -385,7 +385,7 @@ function fit_onerun(
# skip if output file already exists
if !opts.overwrite && (opts.path != "")

opt_results_from_file = read_fit(opts, subpath="__iter__/fit_" * string(idx))
opt_results_from_file = read_fit(opts.path, subpath="__iter__/fit_" * string(idx))

if !isnothing(opt_results_from_file)
(opts.trace > 0) && println(" Reading from file.")
Expand Down
24 changes: 14 additions & 10 deletions src/functions_inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ function vcov_simple(
myfit.errored && error("Cannot compute vcov_simple because estimation errored.")

# try to read from file
myvcov = read_vcov(opts.path)
if !opts.overwrite && !isnothing(myvcov) && myvcov.method == :simple
# TODO: use opts.overwrite option to error if vcov already exists but is not :simple
myfit.vcov = myvcov
return
if !opts.overwrite
myvcov = read_vcov(opts.path)
if !isnothing(myvcov) && myvcov.method == :simple
# TODO: use opts.overwrite option to error if vcov already exists but is not :simple
myfit.vcov = myvcov
return
end
end

# jacobian
Expand Down Expand Up @@ -281,11 +283,13 @@ function vcov_bboot(
opts::GMMOptions=default_gmm_opts())

# try to read from file
myvcov = read_vcov(opts.path)
if !opts.overwrite && !isnothing(myvcov) && myvcov.method == :bayesian_bootstrap
# TODO: use opts.overwrite option to error if vcov already exists but is not bayesian_bootstrap
myfit.vcov = myvcov
return
# TODO: use opts.overwrite option to error if vcov already exists but is not bayesian_bootstrap
if !opts.overwrite
myvcov = read_vcov(opts.path)
if !isnothing(myvcov) && myvcov.method == :bayesian_bootstrap
myfit.vcov = myvcov
return
end
end

# copy options so we can modify them (trace and path)
Expand Down

0 comments on commit 1a74296

Please sign in to comment.