Learning to use PyPlot with Julia programming language (Version 0.4.5), I've encountered an error while trying to produce a simple plot:
julia> using PyPlot
julia> x = linspace(0,100,1000)
linspace(0.0,100.0,1000)
julia> y = x.^2;
julia> plot(x,y)
signal (11): Segmentation fault
unknown function (ip: 0x32736)
Segmentation fault (core dumped)
Someone knows what's going on here?
I can't reproduce your error when running on 0.4.6. My thoughts would be:
Update to latest version.
Update all your packages
Quit and restart julia
If none of those work, it's conceivable perhaps that the plot function doesn't like the mismatch of argument types. Thus, you could apply collect(x) so that both x and y are of type Array.
Related
I'm using Julia 1.1 and I tried to use for loop do the following simple things:
i_index=1;
for index in (1:100)
i_index=i_index+1;
end
However, I got an error saying:
ERROR: UndefVarError: i_index not defined
I have tried several times and variations, but they all failed to work. Is this a bug? or why Julia can't do this simple iterative addition?
In the REPL:
i_index=1;
for index in (1:100)
global i_index;
i_index=i_index+1;
end
This is because of variable scope, see in Julia documentation. Note that the examples there pertain to the REPL.
I tried following the official Julia docs on plotting, where the following code is proposed for plotting:
Pkg.add("PyPlot")
using PyPlot
x = range(0,stop=2*pi,length=1000); y = sin.(3*x + 4*cos.(2*x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
Julia v1.0.2 exits with the error
ERROR: LoadError: UndefVarError: Pkg not defined
My question is how to actually run the above code?
The problem is that the Pkg module is not loaded, because this seems to be deprecated. To fix this the following line has to be added before the first line
using Pkg
The code then works for me not from the command line interface, but within an interactive julia session and produces the following image:
I'm trying to use Rcpp on Windows in RStudio. I have R version 3.2.3 and I have installed the Rcpp package. The problem is that I am unable to call any functions defined through the CPP code. I tried the following (picked up from an example online).
body <- '
NumericVector xx(x);
return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'
add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp")
This gives the following warning, but completes execution successfully.
cygwin warning:
MS-DOS style path detected: C:/R/R-32~1.3/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-32~1.3/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
When I try to use the above function,
x <- 1
y <- 2
res <- add(c(x, y))
I get the following error :
R Session Aborted
R encountered a fatal error.
The session was terminated.
Any suggestions? This same 'Fatal Error' happens for any code that I run with Rcpp.
Try rebuilding locally, starting with Rcpp. This is valid code and will work (and the hundreds of unit tests stress may more than this). Sometimes the compiler or something else changes under you and this sort of thing happens. It is then useful to have an alternative build system -- eg via Travis at GitHub you get Linux for free.
Also, learning about Rcpp Attributes. Your example can be written as
R> library(Rcpp)
R> cppFunction("double adder(std::vector<double> x) { return std::accumulate(x.begin(), x.end(), 0.0); }")
R> adder(c(1,2))
[1] 3
R>
which is simpler. Works of course the same way with Rcpp::NumericVector.
I've installed Julia Version 0.3.10-pre+4 and am trying to run the examples contained in julia/examples, in particular plife.jl, which seems to be a parallel simulation of Conway's game of life. I have the error
julia> include("plife.jl")
plife (generic function with 1 method)
julia> plife(100,100)
ERROR: Window not defined
in plife at /x/faia/julia/examples/plife.jl:44
where the error is caused by the code
function plife(m, n)
w = Window("parallel life", n, m)
c = Canvas(w)
I have searched for a package that defines the Window function, but have failed to find it. Does anyone know how to run this example code?
That example seems to be reliant on an external package, it looks like it might be Tk.jl but there have been some renames since then.
It has actually been removed on the development branch of Julia, but still lingers in the 0.3 series. I've filed a PR to remove it.
How can I get a stack trace back from a snow node after an error occurs? I'm getting errors when I use parSapply that do not occur when I use sapply. Snow is nice enough to give me the error message but it would be much more useful for me to have the kind of stack trace you can get from traceback(). So far I have tried:
options(showWarnCalls = T, showErrorCalls = T)
setDefaultClusterOptions(outfile = "/dev/tty")
and
options(error=traceback)
setDefaultClusterOptions(outfile = "/dev/tty")
without luck. I'm currently just testing with a local cluster ie:
makeSOCKcluster(c("localhost","localhost"))
but I will eventually be using an MPI cluster. Thanks.
Relevant versions:
snow package (version 0.3-3)
R 2.10.1
Mac OS X 10.5.8
Edit: moved version info to bottom of question and added OS X
For me, simple
options(error=traceback)
works, snow just captures the error message with traceback from slave and shows it on the master's output.