kestrelquantum / QuantumCollocation.jl

Quantum Optimal Control with Direct Collocation
MIT License
29 stars 7 forks source link

[Bug]: Objective constructors have bad initial keyword args #68

Open andgoldschmidt opened 8 months ago

andgoldschmidt commented 8 months ago

What happened?

function QuadraticSmoothnessRegularizer(;
    name::Symbol=nothing,
    times::AbstractVector{Int}=1:traj.T,
    R::AbstractVector{<:Real}=ones(traj.dims[name]),
    eval_hessian=true
)

and

function QuadraticRegularizer(;
    name::Symbol=nothing,
    times::AbstractVector{Int}=1:traj.T,
    dim::Int=nothing,
    R::AbstractVector{<:Real}=ones(traj.dims[name]),
    values::Union{Nothing,AbstractArray{<:Real}}=nothing,
    eval_hessian=true,
    timestep_symbol=:Δt
)

are an example of the bug. These interfaces are not usually called, but still the interface of these objectives should be adjusted.

Version

stable release

What does this bug affect?

Other information

No response

andgoldschmidt commented 3 months ago

For now, the fix should be to set default args to nothing, with their types declared as Unions with nothing so that the asserts print.