Skip to content
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

classification bug #136

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all 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
6 changes: 3 additions & 3 deletions src/transform_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Returns an array with the values of `f` evaluated for the respective solutions.
Additional substitution rules can be specified in `rules` in the format `("a" => val)` or `(a => val)`
"""
function transform_solutions(res::Result, func; branches = 1:branch_count(res))

# preallocate an array for the numerical values, rewrite parts of it
# when looping through the solutions
pars = res.swept_parameters |> values |> collect
n_vars = length(get_variables(res))
n_pars = length(res.swept_parameters)
n_pars = length(pars)

vtype = isa(Base.invokelatest(func, rand(ComplexF64, n_vars+n_pars)), Bool) ? BitVector : Vector{ComplexF64}
transformed = _similar(vtype, res; branches=branches)
Expand All @@ -26,7 +26,7 @@ function transform_solutions(res::Result, func; branches = 1:branch_count(res))
_vals = Vector{ComplexF64}(undef, n_vars + n_pars)
for idx in batch
for i in 1:length(idx) # param values are common to all branches
_vals[end-n_pars+i] = res.swept_parameters[idx[i]][i]
_vals[end-n_pars+i] = pars[i][idx[i]]
end
for (k, branch) in enumerate(branches)
_vals[1:n_vars] .= res.solutions[idx][branch]
Expand Down
Loading