I came back from vacations and started to work on my code again. Some code that was working previously doesn’t seem to work anymore, while I don’t think I made any modifications to the code (updated my machine, but nothing major).
The issues goes along the lines of having a bit of code as:
foo(;a::Type1, b::Int, c:: ... ) = ...
foo(;a::Type2) = ...
When calling foo with a Type2, julia seems to want to use the first function, even though they are incompatible. Previously, this bit of code was working as intended. I am encountering this issue with multiple functions working with multiple dispatch.
A practical example in my code would be
function get_eigenvector_x_q_space(;x::Vector, q::Vector, eigenvectors, eigenstates_analytical_e, eigenstates_analytical_ph, eigenvector_index::Int, n_basis_states_e::Int, n_basis_states_ph::Int, atol = TOLERANCE_WAVE_FUNCTION_NORMALIZATION_2DOF)
# some more code
end
function get_eigenvector_x_q_space(;eigenvector_index::Int, k_y_index::Int, params::SimulationParameters, sim_results::SimulationResults2D, atol = TOLERANCE_WAVE_FUNCTION_NORMALIZATION_2DOF)
# construction the wave function for the full state using the basis
@unpack n_basis_states_e, n_basis_states_ph = params
x = sim_results.x_grid_array[1]
q = sim_results.q_grid_array[1]
eigenvectors = sim_results.eigenvectors_array[k_y_index]
eigenstates_analytical_e = sim_results.eigenstates_analytical_e_array[k_y_index]
eigenstates_analytical_ph = sim_results.eigenstates_analytical_ph_array[k_y_index]
get_eigenvector_x_q_space(x = x, q = q, eigenvectors = eigenvectors, eigenstates_analytical_e = eigenstates_analytical_e, eigenstates_analytical_ph = eigenstates_analytical_ph, eigenvector_index = eigenvector_index, atol = atol, n_basis_states_e = n_basis_states_e, n_basis_states_ph = n_basis_states_ph)
end
Calling
get_eigenvector_x_q_space(eigenvector_index=1, k_y_index=1, params = params_int, sim_results = sim_results_int)
results in
ERROR: UndefKeywordError: keyword argument `k_y_index` not assigned
Stacktrace:
[1]
@ Main ~/Documents/postdoc_freiburg/valery/quantum_hall_effect_cavity/julia/quantum_hall_with_cavity/2d_states_representation.jl:64
[2] top-level scope
@ ~/Documents/postdoc_freiburg/valery/quantum_hall_effect_cavity/julia/quantum_hall_with_cavity/main.jl:155
Some type information was truncated. Use `show(err)` to see complete types.
julia> show(err)
1-element ExceptionStack:
LoadError: UndefKeywordError: keyword argument `k_y_index` not assigned
Stacktrace:
[1] get_eigenvector_x_q_space(; eigenvector_index::Int64, k_y_index::Int64, params::SimulationParameters, sim_results::SimulationResults2D, atol::Float64)
@ Main ~/Documents/postdoc_freiburg/valery/quantum_hall_effect_cavity/julia/quantum_hall_with_cavity/2d_states_representation.jl:64
[2] top-level scope
@ ~/Documents/postdoc_freiburg/valery/quantum_hall_effect_cavity/julia/quantum_hall_with_cavity/main.jl:155
[3] eval
@ ./boot.jl:385 [inlined]
[4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:2076
[5] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
@ Base ./essentials.jl:892
[6] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base ./essentials.jl:889
[7] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:271
[8] (::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:181
[9] withpath(f::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/repl.jl:276
[10] (::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:179
[11] hideprompt(f::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/repl.jl:38
[12] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:150
[13] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging ./logging.jl:515
[14] with_logger
@ ./logging.jl:627 [inlined]
[15] (::VSCodeServer.var"#66#71"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:263
[16] #invokelatest#2
@ ./essentials.jl:892 [inlined]
[17] invokelatest(::Any)
@ Base ./essentials.jl:889
[18] (::VSCodeServer.var"#64#65")()
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.120.2/scripts/packages/VSCodeServer/src/eval.jl:34
in expression starting at /home/benoitseron/Documents/postdoc_freiburg/valery/quantum_hall_effect_cavity/julia/quantum_hall_with_cavity/main.jl:155
julia>
I am not sure how to attack this problem. It feels like I am missing something elementary, but I am quite confident that this code was working fine previously. Renaming the first function to some other name, to avoid the use of multiple dispatch, solves the issue, but is not a very elegant solution as this problem seems to be popping up everywhere in my code.