-
Notifications
You must be signed in to change notification settings - Fork 16
Julia v1.0 transition
Revise is used to not have to restart Julia every time code changes are made. To install Revise, hit ]
in the Julia REPL to enter Pkg REPL-mode, then type:
(v1.0) pkg> add Revise
Then add the following to ~/.julia/config/startup.jl
(which you may have to create if it doesn't exist already) to enable Revise on startup, and restart Julia:
try
@eval using Revise
# Turn on Revise's automatic-evaluation behavior
Revise.async_steal_repl_backend()
catch err
@warn "Could not load Revise."
end
For more details, read about Revise here.
Start/navigate Julia to the NonlinearEigenproblems
directory. Then hit ]
in the Julia REPL to enter Pkg REPL-mode, then type:
(v1.0) pkg> activate .
Hit backspace to return to the REPL, then type:
julia> using NonlinearEigenproblems
The error
ERROR: LoadError: ArgumentError: Package Arpack [7d9fca2a-8960-54d3-9f78-7d1dccf2cb97] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
...
Run this command
julia> using Pkg
julia> Pkg.update("Arpack")
(I know it's deprecated, so maybe there is an better way.)
Start/navigate Julia to the NonlinearEigenproblems
directory. Then hit ]
in the Julia REPL to enter Pkg REPL-mode, then type:
(v1.0) pkg> activate .
(NonlinearEigenproblems) pkg> add NAME-OF-PACKAGE
This will update the file Project.toml
, and may also update Manifest.toml
.
Go to the NonlinearEigenproblems
directory. Then run:
julia --check-bounds=yes --color=yes -e 'using Pkg; Pkg.activate("."); Pkg.test()'
-
There are likely errors remaining in currently untested code paths where
opnorm
is called with a vector. Assuming that the call is always performed with vectors (and not matrices), these can simply be changed to changed tonorm
. -
eye
andspeye
are removed. Try to use theI
form whenever possible. Avoid usingI
as a variable name. -
Be cautious about transposed matrices when used with sparse matrices. For example:
A = sprandn(100000,100000,0.000001);
x = randn(100000,1);
@time x'*A*x
In Julia 0.6.4, this code runs in 0.0016 seconds. In Julia 0.7, it runs in 13.4 seconds. The reason is that x'
is no longer a Matrix{Float64}
, but an Adjoint{Float64,Matrix{Float64}}
. This can be fixed by materializing the adjoint matrix:
@time copy(x')*A*x
0.000983 seconds (10 allocations: 1.526 MiB)
-
Try to avoid global variables, even in tests. Wrap variable declarations in tests in a
@testset
or a function. If you need a global variable for some reason, try to give it a unique name, e.g.test_broyden_nep
. -
Stack trace line numbers may be incorrect. Not sure what this is caused by, some cases might be due to inlining, others perhaps by having multiple statements on the same line? Sometimes hard to track.
If you want to hack around in REPL
, and not having to load all "basic packages" manually, you could try to add this code to ~/.julia/config/startup.jl
. It takes some time to start Julia since it loads all the packages. However, depending on how you use it it might be nice to have. Or at least to have a short-command for doing it. It gives more of a MATLAB-ish feeling to is since you do not have to manually load the basics every time.
for pkg = [:SparseArrays, :LinearAlgebra, :Random, :IterativeSolvers, :Printf, :Statistics, :InteractiveUtils] #:Plots
try
@eval using ($pkg)
catch err
@warn "Could not load $pkg."
end
end