I'm trying to precompile my package to reduce startup time, and I've the answer here and the manual to get some information. I added some precompile hints (as in the SO answer) and now I see a ton of warnings when using my module. I was able to recreate these warnings with a new package called PrecompileTester which has the contents:
__precompile__()
module PrecompileTester
module M
using SpecialFunctions
const A = digamma(1) # precompile hint
const B = digamma(1.0) # precompile hint
end
end # module
The warnings all seem to say that I'm overwriting a function at X with the same function from the same place. Here are the last two lines of the warning output:
...
WARNING: Method definition digamma(Union{Float16, Main.Base.Complex{Float16}, Float32, Main.Base.Complex{Float32}}) in module SpecialFunctions at /Users/user/.julia/v0.6/SpecialFunctions/src/gamma.jl:497 overwritten in module SpecialFunctions at /Users/user/.julia/v0.6/SpecialFunctions/src/gamma.jl:497.
WARNING: Method definition digamma(Number) in module SpecialFunctions at /Users/user/.julia/v0.6/SpecialFunctions/src/gamma.jl:501 overwritten in module SpecialFunctions at /Users/user/.julia/v0.6/SpecialFunctions/src/gamma.jl:501.
What is going on here, and how do I precompile without all these warnings?
Related
I’m trying to duplicate the first example of trajectory evolution in the docs for the InteractiveDynamcis package (https://juliadynamics.github.io/InteractiveDynamics.jl/dev/trajectory/).
I’ve already created an environment into which I’ve added InteractiveDynamics, DynamicalSystems, GLMakie, and OrdinaryDiffEq.
In that environment, I executed:
using InteractiveDynamics
using DynamicalSystems, GLMakie
using OrdinaryDiffEq
But when I try to execute next…
ds = Systems.henonheiles()
… I get error:
ERROR: UndefVarError: Systems not defined
Stacktrace:
[1] top-level scope
What is Systems?
I tried to add a package named Systems but no such package was found.
Surely: ds = DynamicalSystems.henonheiles()
unless you do Systems = DynamicalSystems first
Can you share what package versions you are using? On Julia 1.6.1 with the following package versions, the code above works:
[61744808] DynamicalSystems v1.7.7
[ec714cd0] InteractiveDynamics v0.15.1
[e9467ef8] GLMakie v0.3.4
[1dea7af3] OrdinaryDiffEq v5.57.0
I have created a package (let's call it package_name) in Julia; the file structure is already generated along with the Project.toml and Manifest.toml files and I have already added some dependencies when I created the package.
I forgot to add a dependency and I would like to get the REPL to show:
(package_name) pkg >
so that I may type
add dependency_name
How do I get the REPL to show this? I think I need to go to the package folder and (re) activate the package but I am unable to navigate to it with cd.
Showing the exact commands I should type in the REPL would be helpful.
In order to get the package REPL mode, you should type a closing bracket ] when your cursor is at the beginning of the line. Likewise, when in package REPL mode, you need to type BackSpc right after the prompt in order to get back to standard REPL mode:
julia> # type ] here to enter the Pkg REPL
# We're now in the Pkg REPL, but the default environment is active
# Let's activate the environment we want
# (replace the path below with "." to activate the environment defined in the current working directory)
(#v1.5) pkg> activate /path/to/package
# Now we see that the correct environment is active
# This is where new dependencies will be added
(package_name) pkg> add DepName
(package_name) pkg> # type BackSpace here to get back to the standard REPL
julia>
Additionally, you could achieve the same thing without entering the Pkg REPL mode, by using the pkg"..." string macro defined in the Pkg library:
julia> using Pkg
julia> pkg"activate /path/to/package"
julia> pkg"add DepName"
You can also add deps manually to your project.toml file like
name = "MyPackage"
uuid = "e91191c6-8984-4a4d-b031-ef6fb65a77ca"
authors = ["Shep Bryan IV and contributors"]
version = "0.1.0"
[deps]
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
This requires that you be able to find the corresponding uuid codes for each package you use. Currently there is no simple function to do this, but if you really want to do it manually you can find a complete list of uuids for registered packages here.
Alternatively you can use this crude script to get the uuids from within Julia:
using Downloads
function get_uuid_from_registry(modulename)
# Download the registry to temporary file
tempfile = Downloads.download("https://github.com/JuliaRegistries/General/blob/master/Registry.toml")
# Open the tempfile
f = open(tempfile, "r")
# Loop through the lines in the file
for line in readlines(f)
if occursin(">$(modulename)<", line)
# Cut out uuid from HTML file
uuid = split(split(line, "<span class=\"pl-smi\">")[2], "</span>")[1]
return uuid
end
end
println("No module found")
return
end
uuid = get_uuid_from_registry("HDF5")
I try to build a custom geom to extend ggplot2.
While the function works, I am not able to build the package as I have the following error message:
==> devtools::document(roclets=c('rd', 'collate', 'namespace'))
Updating ggvis documentation
Loading ggvis
Error in ggproto("GeomDash", Geom, required_aes = c("x", "y"), non_missing_aes = c("linetype", (from geom_dash.R#57) :
impossible de trouver la fonction "ggproto"
Calls: suppressPackageStartupMessages ... withr_with_dir -> force -> source_many -> source_one -> eval -> eval
Ex�cution arr�t�e
Exited with status 1.
I installed the dev version of ggplot2 as recommanded by Hadley. With no success. For some reason it does not show an error when I try with a dummy function such as:
f <- function(x){
return(ggproto(x))}
But it doesn't work even with the initial code of geom_segment or by integrating the ggproto function in the package's folder.
You can find my function here
I've already created a package to extend ggplot2 with no problem. It still builds just fine.
Any suggestion? Cheers.
The problem was solved by editing the NAMESPACE as suggested by #Gregor.
Removing the existing NAMESPACE file and running
devtools::document()
allowed the creation of a clean NAMESPACE file containing the required exports and imports.
I am using JuliaPro v0.6.0.1 and the JunoIDE
I tried to apply the DifferentialEquations.jl. In order to run a first example I added the package DifferentialEquations followed by the using statement. In a next step I copied the first example:
f(t,u) = 1.01*u
u0=1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob,Tsit5(),reltol=1e-8,abstol=1e-8)
using Plots
plot(sol,linewidth=5,title="Solution to the linear ODE with a thick line",
xaxis="Time (t)",yaxis="u(t) (in μm)",label="My Thick Line!") # legend=false
plot!(sol.t, t->0.5*exp(1.01t),lw=3,ls=:dash,label="True Solution!")
Instead of getting the expected graphic I've got the message:
UndefVarError: ODEProblem not defined
Furthermore I've got the warnings right after the: using DifferentialEquations statement
WARNING: The call to compilecache failed to create a usable precompiled cache file for module StochasticDiffEq. Got:
WARNING: Module Iterators uuid did not match cache file.
> LoadError: Declaring __precompile__(true) is only allowed in module files being imported.
which I do not understand. Nevertheless the last warning deals with StochasticDiffEq whereas I'm applying an Ordinary Differential Equation problem.
Any help is appropiated
JuliaPro is incompatible with some packages including DifferentialEquations. I would avoid using JuliaPro and instead use a standard installation until JuliaPro is updated.
I want to create a package containing a RcppArmadillo function:
library(Rcpp)
library(RcppArmadillo)
sourceCpp("calculSignSim.cpp")
RcppArmadillo.package.skeleton(name = "calculSignSimCPP",list = "calculSignSim")
The function created by sourceCpp works fine.
However, this latter line gives me the following error:
Calling package.skeleton to create basic package.
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './calculSignSimCPP/Read-and-delete-me'.
Adding RcppArmadillo settings
>> added Imports: Rcpp
>> added LinkingTo: Rcpp, RcppArmadillo
>> added useDynLib and importFrom directives to NAMESPACE
>> added Makevars file with Rcpp settings
>> added Makevars.win file with RcppArmadillo settings
>> added example src file using armadillo classes
>> added example Rd file for using armadillo classes
Error in Rcpp::compileAttributes(root) :
Evaluation error: D:/R packages/calculSignSimCPP/R/calculSignSim.R:3:21: unexpected '<'
2: function (lemmesV, ulemmesV, optionLien)
3: .Primitive(".Call")(<
^.
In addition: Warning message:
In dump(item, file = file.path(code_dir, sprintf("%s.R", list0[item])), :
deparse may be incomplete
I really don't understand why it doesn't work.
When I do not explicitely indicate which function I want to include, i.e. when I do
RcppArmadillo.package.skeleton(name = "calculSignSimCPP")
Everything works fine, but the created package does not contain my function...
Any idea ?