control-toolbox / CTBase.jl

Fundamentals of the control-toolbox ecosystem
http://control-toolbox.org/CTBase.jl/
MIT License
12 stars 3 forks source link

Add extension error if Plots is not loaded #237

Open ocots opened 3 months ago

ocots commented 3 months ago

Add extension error if Plots.jl is not loaded. For the moment we have

julia> using CTBase
julia> sol = ...
julia> plt = plot(sol)
ERROR: UndefVarError: `plot` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[46]:1
ocots commented 2 months ago

The last thing I had which is not working is the following:

julia> using CTBase

julia> plot(sol)
ERROR: ExtensionError. Please make: julia> using Plots
Stacktrace:
 [1] plot(::OptimalControlSolution; kwargs::@Kwargs{})
   @ CTBase ~/Research/logiciels/dev/control-toolbox/CTBase/src/CTBase.jl:219
 [2] top-level scope
   @ REPL[4]:1

julia> using Plots
[ Info: Precompiling CTBasePlots [0ad68a25-3dcc-5afc-86be-7bb96764f193]
WARNING: using Plots.plot in module Main conflicts with an existing identifier.

julia> plot(sol)
ERROR: ExtensionError. Please make: julia> using Plots
Stacktrace:
 [1] plot(::OptimalControlSolution; kwargs::@Kwargs{})
   @ CTBase ~/Research/logiciels/dev/control-toolbox/CTBase/src/CTBase.jl:219
 [2] top-level scope
   @ REPL[6]:1
jbcaillau commented 2 months ago

@ocots OK, but no one is supposed to use CTBase then solve / plot...

ocots commented 2 months ago

@ocots OK, but no one is supposed to use CTBase then solve / plot...

Yes but it is the same from OptimalControl.

For the moment, after using OptimalControl there is an error that we raise if we call solve without using NLPModelsIpopt, an error that we raise if we call Flow without using OrdinaryDiffEq but if we call plot there is an error from Julia, not from us. It is not consistent.

jbcaillau commented 2 months ago

Ah, sure.