Skip to content

Commit e0090e5

Browse files
Use explicit imports
1 parent 04bc3e6 commit e0090e5

33 files changed

+620
-618
lines changed

docs/src/api/daskr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ algorithm, you will need to install and use the package:
77
```julia
88
using Pkg
99
Pkg.add("DASKR")
10-
using DASKR
10+
import DASKR
1111
```
1212

1313
These methods can be used independently of the rest of DifferentialEquations.jl.

docs/src/api/sundials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ the package before using these solvers:
77
```julia
88
using Pkg
99
Pkg.add("Sundials")
10-
using Sundials
10+
import Sundials
1111
```
1212

1313
These methods can be used independently of the rest of DifferentialEquations.jl.

docs/src/basics/faq.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
250250
If I want to set this directly to 4 threads, I would use:
251251

252252
```julia
253-
using LinearAlgebra
253+
import LinearAlgebra
254254
LinearAlgebra.BLAS.set_num_threads(4)
255255
```
256256

@@ -260,7 +260,7 @@ can use [MKL.jl](https://github.com/JuliaLinearAlgebra/MKL.jl), which will accel
260260
the linear algebra routines. This is done via:
261261

262262
```julia
263-
using MKL
263+
import MKL
264264
```
265265

266266
#### My ODE is solving really slow
@@ -472,7 +472,7 @@ To show this in action, let's say we want to find the Jacobian of solution
472472
of the Lotka-Volterra equation at `t=10` with respect to the parameters.
473473

474474
```@example faq1
475-
using DifferentialEquations
475+
import DifferentialEquations
476476
function func(du, u, p, t)
477477
du[1] = p[1] * u[1] - p[2] * u[1] * u[2]
478478
du[2] = -3 * u[2] + u[1] * u[2]
@@ -491,14 +491,14 @@ for the timespan just to show what you'd do if there were parameters-dependent e
491491
Then we can take the Jacobian via ForwardDiff.jl:
492492

493493
```@example faq1
494-
using ForwardDiff
494+
import ForwardDiff
495495
ForwardDiff.jacobian(f, [1.5, 1.0])
496496
```
497497

498498
and compare it to FiniteDiff.jl:
499499

500500
```@example faq1
501-
using FiniteDiff
501+
import FiniteDiff
502502
FiniteDiff.finite_difference_jacobian(f, [1.5, 1.0])
503503
```
504504

@@ -508,7 +508,7 @@ This is because you're using a cache which is incompatible with autodifferentiat
508508
via ForwardDiff.jl. For example, if we use the ODE function:
509509

510510
```julia
511-
using LinearAlgebra, OrdinaryDiffEq
511+
import LinearAlgebra, OrdinaryDiffEq
512512
function foo(du, u, (A, tmp), t)
513513
mul!(tmp, A, u)
514514
@. du = u + tmp
@@ -539,7 +539,7 @@ We could use `get_tmp` and `dualcache` functions from
539539
to solve this issue, e.g.,
540540

541541
```julia
542-
using LinearAlgebra, OrdinaryDiffEq, PreallocationTools
542+
import LinearAlgebra, OrdinaryDiffEq, PreallocationTools
543543
function foo(du, u, (A, tmp), t)
544544
tmp = get_tmp(tmp, first(u) * t)
545545
mul!(tmp, A, u)

docs/src/basics/integrator.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ For example, if one wants to iterate but only stop at specific values, one can
250250
choose:
251251

252252
```julia
253-
integrator = init(prob, Tsit5(); dt = 1 // 2^(4), tstops = [0.5], advance_to_tstop = true)
253+
integrator = DE.init(prob, DE.Tsit5(); dt = 1 // 2^(4), tstops = [0.5], advance_to_tstop = true)
254254
for (u, t) in tuples(integrator)
255255
@test t [0.5, 1.0]
256256
end
@@ -261,7 +261,7 @@ and thus there are two values of `tstops` which are hit). Additionally, one can
261261
`solve!` only to `0.5` via:
262262

263263
```julia
264-
integrator = init(prob, Tsit5(); dt = 1 // 2^(4), tstops = [0.5])
264+
integrator = DE.init(prob, DE.Tsit5(); dt = 1 // 2^(4), tstops = [0.5])
265265
integrator.opts.stop_at_next_tstop = true
266266
solve!(integrator)
267267
```
@@ -283,20 +283,20 @@ For an example of manually chaining together the iterator interface and plotting
283283
one should try the following:
284284

285285
```julia
286-
using DifferentialEquations, DiffEqProblemLibrary, Plots
286+
import DifferentialEquations as DE, DiffEqProblemLibrary, Plots
287287

288288
# Linear ODE which starts at 0.5 and solves from t=0.0 to t=1.0
289-
prob = ODEProblem((u, p, t) -> 1.01u, 0.5, (0.0, 1.0))
289+
prob = DE.ODEProblem((u, p, t) -> 1.01u, 0.5, (0.0, 1.0))
290290

291-
using Plots
292-
integrator = init(prob, Tsit5(); dt = 1 // 2^(4), tstops = [0.5])
291+
import Plots
292+
integrator = DE.init(prob, DE.Tsit5(); dt = 1 // 2^(4), tstops = [0.5])
293293
pyplot(show = true)
294-
plot(integrator)
294+
Plots.plot(integrator)
295295
for i in integrator
296-
display(plot!(integrator, idxs = (0, 1), legend = false))
296+
display(Plots.plot!(integrator, idxs = (0, 1), legend = false))
297297
end
298298
step!(integrator);
299-
plot!(integrator, idxs = (0, 1), legend = false);
299+
Plots.plot!(integrator, idxs = (0, 1), legend = false);
300300
savefig("iteratorplot.png")
301301
```
302302

docs/src/basics/plot.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ and the plotter will generate appropriate plots.
88

99
```julia
1010
#]add Plots # You need to install Plots.jl before your first time using it!
11-
using Plots
12-
plot(sol) # Plots the solution
11+
import Plots
12+
Plots.plot(sol) # Plots the solution
1313
```
1414

1515
Many of the types defined in the DiffEq universe, such as
@@ -21,7 +21,7 @@ on the plot by doing:
2121

2222
```julia
2323
gr()
24-
plot(sol, title = "I Love DiffEqs!")
24+
Plots.plot(sol, title = "I Love DiffEqs!")
2525
```
2626

2727
Then to save the plot, use `savefig`, for example:
@@ -37,13 +37,13 @@ to use the dense function for generating the plot, and `plotdensity` is the numb
3737
of evenly-spaced points (in time) to plot. For example:
3838

3939
```julia
40-
plot(sol, denseplot = false)
40+
Plots.plot(sol, denseplot = false)
4141
```
4242

4343
means “only plot the points which the solver stepped to”, while:
4444

4545
```julia
46-
plot(sol, plotdensity = 1000)
46+
Plots.plot(sol, plotdensity = 1000)
4747
```
4848

4949
means to plot 1000 points using the dense function (since `denseplot=true` by
@@ -133,7 +133,7 @@ more details on the extra controls that exist.
133133
A plotting timespan can be chosen by the `tspan` argument in `plot`. For example:
134134

135135
```julia
136-
plot(sol, tspan = (0.0, 40.0))
136+
Plots.plot(sol, tspan = (0.0, 40.0))
137137
```
138138

139139
only plots between `t=0.0` and `t=40.0`. If `denseplot=true` these bounds will be respected
@@ -143,7 +143,7 @@ i.e. no points outside the interval will be plotted.
143143
### Example
144144

145145
```@example plots
146-
using DifferentialEquations, Plots
146+
import DifferentialEquations as DE, Plots
147147
function lorenz(du, u, p, t)
148148
du[1] = p[1] * (u[2] - u[1])
149149
du[2] = u[1] * (p[2] - u[3]) - u[2]
@@ -153,28 +153,28 @@ end
153153
u0 = [1.0, 5.0, 10.0]
154154
tspan = (0.0, 100.0)
155155
p = (10.0, 28.0, 8 / 3)
156-
prob = ODEProblem(lorenz, u0, tspan, p)
157-
sol = solve(prob)
158-
xyzt = plot(sol, plotdensity = 10000, lw = 1.5)
159-
xy = plot(sol, plotdensity = 10000, idxs = (1, 2))
160-
xz = plot(sol, plotdensity = 10000, idxs = (1, 3))
161-
yz = plot(sol, plotdensity = 10000, idxs = (2, 3))
162-
xyz = plot(sol, plotdensity = 10000, idxs = (1, 2, 3))
163-
plot(plot(xyzt, xyz), plot(xy, xz, yz, layout = (1, 3), w = 1), layout = (2, 1))
156+
prob = DE.ODEProblem(lorenz, u0, tspan, p)
157+
sol = DE.solve(prob)
158+
xyzt = Plots.plot(sol, plotdensity = 10000, lw = 1.5)
159+
xy = Plots.plot(sol, plotdensity = 10000, idxs = (1, 2))
160+
xz = Plots.plot(sol, plotdensity = 10000, idxs = (1, 3))
161+
yz = Plots.plot(sol, plotdensity = 10000, idxs = (2, 3))
162+
xyz = Plots.plot(sol, plotdensity = 10000, idxs = (1, 2, 3))
163+
Plots.plot(Plots.plot(xyzt, xyz), Plots.plot(xy, xz, yz, layout = (1, 3), w = 1), layout = (2, 1))
164164
```
165165

166166
An example using the functions:
167167

168168
```@example plots
169169
f(x, y, z) = (sqrt(x^2 + y^2 + z^2), x)
170-
plot(sol, idxs = (f, 1, 2, 3))
170+
Plots.plot(sol, idxs = (f, 1, 2, 3))
171171
```
172172

173173
or the norm over time:
174174

175175
```@example plots
176176
f(t, x, y, z) = (t, sqrt(x^2 + y^2 + z^2))
177-
plot(sol, idxs = (f, 0, 1, 2, 3))
177+
Plots.plot(sol, idxs = (f, 0, 1, 2, 3))
178178
```
179179

180180
## Animations
@@ -205,14 +205,14 @@ use this to plot solutions. For example, in PyPlot, Gadfly, GR, etc., you can
205205
do the following to plot the timeseries:
206206

207207
```julia
208-
plot(sol.t, sol')
208+
Plots.plot(sol.t, sol')
209209
```
210210

211211
since these plot along the columns, and `sol'` has the timeseries along the column.
212212
Phase plots can be done similarly, for example:
213213

214214
```julia
215-
plot(sol[i, :], sol[j, :], sol[k, :])
215+
Plots.plot(sol[i, :], sol[j, :], sol[k, :])
216216
```
217217

218218
is a 3D phase plot between variables `i`, `j`, and `k`.
@@ -223,7 +223,7 @@ the interpolation must be done manually. For example:
223223
```julia
224224
n = 101 #number of timepoints
225225
ts = range(0, stop = 1, length = n)
226-
plot(sol(ts, idxs = i), sol(ts, idxs = j), sol(ts, idxs = k))
226+
Plots.plot(sol(ts, idxs = i), sol(ts, idxs = j), sol(ts, idxs = k))
227227
```
228228

229229
is the phase space using values `0.01` apart in time.

docs/src/basics/problem.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ which outputs a tuple.
6868
### Examples
6969

7070
```@example problem
71-
using DifferentialEquations
72-
prob = ODEProblem((u, p, t) -> u, (p, t0) -> p[1], (p) -> (0.0, p[2]), (2.0, 1.0))
71+
import DifferentialEquations
72+
prob = DifferentialEquations.ODEProblem((u, p, t) -> u, (p, t0) -> p[1], (p) -> (0.0, p[2]), (2.0, 1.0))
7373
```
7474

7575
```@example problem
76-
using Distributions
77-
prob = ODEProblem((u, p, t) -> u, (p, t) -> Normal(p, 1), (0.0, 1.0), 1.0)
76+
import Distributions
77+
prob = DifferentialEquations.ODEProblem((u, p, t) -> u, (p, t) -> Distributions.Normal(p, 1), (0.0, 1.0), 1.0)
7878
```
7979

8080
## Lower Level `__init` and `__solve`
@@ -101,8 +101,8 @@ example, to simulate it for longer timespan. It can be done by the
101101
`remake` function:
102102

103103
```@example problem
104-
prob1 = ODEProblem((u, p, t) -> u / 2, 1.0, (0.0, 1.0))
105-
prob2 = remake(prob1; tspan = (0.0, 2.0))
104+
prob1 = DifferentialEquations.ODEProblem((u, p, t) -> u / 2, 1.0, (0.0, 1.0))
105+
prob2 = DifferentialEquations.remake(prob1; tspan = (0.0, 2.0))
106106
```
107107

108108
A general syntax of `remake` is

docs/src/examples/beeler_reuter.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,27 +348,27 @@ u0[90:102, 90:102] .= v1; # a small square in the middle of the domain
348348
The initial condition is a small square in the middle of the domain.
349349

350350
```julia
351-
using Plots
352-
heatmap(u0)
351+
import Plots
352+
Plots.heatmap(u0)
353353
```
354354

355355
Next, the problem is defined:
356356

357357
```julia
358-
using DifferentialEquations, Sundials
358+
import DifferentialEquations as DE, Sundials
359359

360360
deriv_cpu = BeelerReuterCpu(u0, 1.0);
361-
prob = ODEProblem(deriv_cpu, u0, (0.0, 50.0));
361+
prob = DE.ODEProblem(deriv_cpu, u0, (0.0, 50.0));
362362
```
363363

364364
For stiff reaction-diffusion equations, CVODE_BDF from Sundial library is an excellent solver.
365365

366366
```julia
367-
@time sol = solve(prob, CVODE_BDF(linear_solver = :GMRES), saveat = 100.0);
367+
@time sol = DE.solve(prob, Sundials.CVODE_BDF(linear_solver = :GMRES), saveat = 100.0);
368368
```
369369

370370
```julia
371-
heatmap(sol.u[end])
371+
Plots.heatmap(sol.u[end])
372372
```
373373

374374
## CPU/GPU Beeler-Reuter Solver
@@ -402,7 +402,7 @@ The key to fast CUDA programs is to minimize CPU/GPU memory transfers and global
402402
We modify ``BeelerReuterCpu`` into ``BeelerReuterGpu`` by defining the state variables as *CuArray*s instead of standard Julia *Array*s. The name of each variable defined on the GPU is prefixed by *d_* for clarity. Note that $\Delta{v}$ is a temporary storage for the Laplacian and stays on the CPU side.
403403

404404
```julia
405-
using CUDA
405+
import CUDA
406406

407407
mutable struct BeelerReuterGpu <: Function
408408
t::Float64 # the last timestep time to calculate Δt
@@ -651,15 +651,15 @@ end
651651
Ready to test!
652652

653653
```julia
654-
using DifferentialEquations, Sundials
654+
import DifferentialEquations as DE, Sundials
655655

656656
deriv_gpu = BeelerReuterGpu(u0, 1.0);
657-
prob = ODEProblem(deriv_gpu, u0, (0.0, 50.0));
658-
@time sol = solve(prob, CVODE_BDF(linear_solver = :GMRES), saveat = 100.0);
657+
prob = DE.ODEProblem(deriv_gpu, u0, (0.0, 50.0));
658+
@time sol = DE.solve(prob, Sundials.CVODE_BDF(linear_solver = :GMRES), saveat = 100.0);
659659
```
660660

661661
```julia
662-
heatmap(sol.u[end])
662+
Plots.heatmap(sol.u[end])
663663
```
664664

665665
## Summary

0 commit comments

Comments
 (0)