How use Systems.henonheiles from InteractiveDynamics - julia

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

Related

How to accurately use the epi.kappa() function in R?

I am attempting to perform a kappa statistic test on 2 indices I created. I've found that there are multiple packages in R that have functions for this and am trying to compare two functions: the epi.kappa() function in the epiR package and the cohen.kappa() function from the psych package.
I was able to successfully use the cohen.kappa() function with my data however, I continue to get errors when using the epi.kappa() function. My code is as follows
library(epiR)
kap.dat = matrix(c(275,78,305,154),nrow=2,byrow=TRUE)
colnames(kap.dat) = c("I1-0","I1-1")
rownames(kap.dat) = c("I2-0","I2-1")
epi.kappa(kap.dat,method="cohen",alternative= "two.sided",conf.level=0.95)
The error I get is:
Error in epi.kappa(kap.dat,method="cohen",alternative="two.sided", :
object `pO.p` not found
Check that you've got the latest version of epiR installed and update if necessary. Latest version on CRAN is 2.0.50. Type help(epi.about) once package loaded --- version of package will be shown at the bottom of the page.

clustMixType version 0.2-11 cannot find silhouette_kproto

I'm trying to run the example of the silhouette_kproto function from the documentation:
https://www.rdocumentation.org/packages/clustMixType/versions/0.2-2/topics/silhouette_kproto
I've installed v 0.2-11 as shown in my SessionInfo()
other attached packages:
[1] clustMixType_0.2-11 readxl_1.1.0
But it seems that this version does not include the silhouette_kproto function, this function seems to be in version 0.2-2 as shown here:
https://www.rdocumentation.org/packages/clustMixType/versions/0.2-2/topics/silhouette_kproto
How could I install the 0.2-2 version of clustMixType? I've just run this
install.packages('clustMixType')
Is it supposed to insall the last version?
I've searched for it using
> getAnywhere(silhouette_kproto)
And it was found:
A single object matching ‘silhouette_kproto’ was found
It was found in the following places
namespace:clustMixType
Why then I get the error message when I try tu use it?
could not find function "silhouette_kproto"
The example you are referring to is from the documentation from an older version.
Please try to reproduce the example from the new version, we have restructured the functions and you should now use validation_kproto(method = "silhouette", ...) (have a look here).
Many greetings Rabea
clustmixtype

Unit tests for R functions that are not exported

I am quite new to unit testing, and I would like to implement some simple unit tests for the functions of an R package. The problem is that most functions of this R package are currently not exported, so that most of unit tests will concern R functions that are not mentioned in the NAMESPACE file.
This concerns the following R package : https://gitlab.com/f.santos/anthropmmd/tree/devel
I am using testthat, and when I try to test an R function that is not exported (for example, the most simple function in the package, max3), I get the following error message:
> setwd('............./AnthropMMD/')
> library(devtools)
> devtools::load_all()
Loading AnthropMMD
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Registered S3 methods overwritten by 'car':
method from
influence.merMod lme4
cooks.distance.influence.merMod lme4
dfbeta.influence.merMod lme4
dfbetas.influence.merMod lme4
Attaching package: ‘testthat’
The following objects are masked from ‘package:devtools’:
setup, test_file
> test()
Loading AnthropMMD
Testing AnthropMMD
✔ | OK F W S | Context
✖ | 0 1 | max3
────────────────────────────────────────────────────────────────────────────────
test-max3.R:5: error: max3 gives correct answer
could not find function max3
I found on this thread that using devtools::load_all() before running the tests should fix the problem, but it did not work for me, and I guess I should have missed something.
What is the correct and complete set up one should follow to be able to test non-exported functions in an R package?
Thanks!
(NB: as I am not an Rstudio user, please do not make me any "Rstudio-specific" answer ;))

failed to execute first example of Differential Algebraic Equations

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.

Determine version of a specific package

How can I get the version number for a specific package?
The obvious way is to get the dictionary with all installed packages, and then filter for the one of interest:
pkgs = Pkg.installed();
pkgs["Datetime"]
Getting the list of all installed packages is very slow though, especially if there are many packages.
EDIT: For Julia version 1.1+
Use the Pkg REPL notation:
] status # Show every installed package version
] status pkgName # Show the specific version of the package
] status pkgName1 pkgName2 # Show the named packages. You can continue the list.
The ] enters the Pkg REPL, so you basically write status ...
So in your case, write after entering the Pkg REPL:
status DataFrame
Or use the object-oriented approach (NB: Here you don't enter the Pkg REPL, i.e. DON'T use ]:
Pkg.status("DataFrame")
EDIT: For Julia version 1.0
Pkg.installed seems to have "regressed" with the new package system. There are no arguments for Pkg.installed. So, the OP's original method seems to be about the best you can do at the moment.
pkgs = Pkg.installed();
pkgs["Datetime"]
EDIT: For Julia version upto 0.6.4
You can pass a string to Pkg.installed. For example:
pkgs = Pkg.installed("JuMP")
I often check available calling arguments with methods. For example:
julia> methods(Pkg.installed)
# 2 methods for generic function "installed":
installed() at pkg/pkg.jl:122
installed(pkg::AbstractString) at pkg/pkg.jl:129
or
julia> Pkg.installed |> methods
# 2 methods for generic function "installed":
installed() at pkg/pkg.jl:122
installed(pkg::AbstractString) at pkg/pkg.jl:129
I would try Pkg.status("PackageName")
This will print out a little blurb giving the package name.
Here is an example
julia> Pkg.status("QuantEcon")
- QuantEcon 0.0.1 master
In Julia 1.1 you can use
(v1.1) pkg> status "name_of_the_package"
to find the version of any package in a given environment.
In order to look of a version of an indirectly included package (e.g. top-level project includes Module A which depends on Module B, where you need to know info about Module B), you have to pull the info either from the Manifest.toml directly, or you have to bring in the Context object in from Pkg.
Below is done with Julia 1.3.1 ... there may be changes to Pkg's internals since then.
using Pkg
ctx = Pkg.Operations.Context()
# Get the version of CSV.jl
version = ctx.env.manifest[UUID("336ed68f-0bac-5ca0-87d4-7b16caf5d00b")].version
if version <= v"0.5.24"
# handle some uniqueness about the specific version of CSV.jl here
end
UPDATE: Or without a UUID and just the package name (thanks #HHFox):
using Pkg
pkg_name = "Observables"
m = Pkg.Operations.Context().env.manifest
v = m[findfirst(v->v.name == pkg_name, m)].version
or to do the same with the Manifest.toml
using Pkg
# given the path to the Manifest.toml file...
manifest_dict = Pkg.TOML.parsefile(manifest_path)
# look for a named package like `CSV`
package_dict = manifest_dict[package_name][1]
#show package_dict
Well this didn't print well in the comment section...
Here is a version that matches the name rather than the UUID
using Pkg
m = Pkg.Operations.Context().env.manifest
v = m[findfirst(v -> v.name == "CSV", m)].version
For packages which are dependencies of the specified packages in the project file one can use status -m <packageName> or shorter st -m <packageName> in package mode (After ]`).
For a full list, just use st -m.
This is an extension to https://stackoverflow.com/a/25641957.

Resources