Mathieu Besançon
Twitter: @MathieuBesancon
mbesancon.github.io
Julia modules define a scope for variables, functions, ...
import JuMP
@show JuMP.solve
JuMP.solve = JuMP.solve
solve (generic function with 1 method)
import DifferentialEquations
@show DifferentialEquations.solve
DifferentialEquations.solve = DiffEqBase.solve
solve (generic function with 34 methods)
Now getting messy...
using JuMP # all things from JuMP imported in scope
using DifferentialEquations # same for DifferentialEquations
# solve?
@show solve
WARNING: both DifferentialEquations and JuMP export "solve"; uses of it in module Main must be qualified
UndefVarError: solve not defined Stacktrace: [1] include_string(::String, ::String) at ./loading.jl:522
When identifier source is ambiguous, call explicit
import MyModule
y = MyModule.func(x)
Code regrouped for a specific purpose.
src/
¶Contains the source code you develop, wrapped in at least a module
test/
¶Used to import your package and test its expected behavior as a user would.
How well did you test your package? This can't be cheated by coveralls
.
Example with LGFlows
REQUIRE
¶docs
¶Detailed documentation of the package built however you like.
The Documenter.jl package is a common choice.
\begin{bmatrix} 1 & 0 & 0 &...\\ 1 & 1 & 0 &...\\ 1 & 1 & 1 &...\\ & & ... & \\ 1 & 1 & ... & 1\\ \end{bmatrix}
Errors in scientific computing:
vec = [3, 5, 7]
i = 2
j = 1
elem = vec[length(vec)*i + j] # oh no!
> BoundsError: attempt to access 3-element Array{Int64,1} at index [7]
Occurs in signal / image filter, time-series analysis, ...
A solution would be a "clipped access" to the vector:
vec = [3, 5, 7]
vec[1] # returns 3
vec[0] # would return 3
vec[3] # returns 7
vec[4] # would return 7
Thank you for listening!
Questions?