julia

Julia 1.0.0 on Windows 10 using PyPlot compiler error because it can't load library expected at: .julia\\packages\\Conda\\m7vem\\deps\\usr\\python37\

可紊 提交于 2020-01-06 06:53:27
问题 I'm trying to get matplotlib working with Julia 1.0.0. Installed it but get error when I try to test it by doing this... ENV["PYTHON"]="c:\\ProgramData\\Anaconda3\\python.exe" using Pkg Pkg.add("PyPlot") using PyPlot ...which gets this error: ErrorException("error compiling display_error: error compiling findprev: error compiling lookup: error compiling Type: could not load library \"C:\\Users\\ME\\.julia\\packages\\Conda\\m7vem\\deps\\usr\\python37\"\nThe specified module could not be found.

Execute a string?

橙三吉。 提交于 2020-01-05 15:16:51
问题 I wanted to execute a string, but found that there's no exec function in Julia: a = 1 println(exec("a")) # ERROR: exec not defined Is there a way to execute a string in Julia? The original problem is that I'm trying to log a list of variables: thingsToLog = ["a", "b", "c"] to file: open(logFile, "w") do io for thing in thingsToLog write(io, @sprintf("%s = %s\n", thing, eval(thing))) end end 回答1: As said above, you can call parse to create an AST from the string, and then call eval on that. In

Troubleshooting: Kernel always dies using IJulia in IPython notebook

馋奶兔 提交于 2020-01-05 14:13:23
问题 I recently began using julia, and I would like to use in with IPython Notebook/Jupyter. So, I installed julia using MacPorts, i.e. sudo port install julia . Following the installation instructions here: https://github.com/JuliaLang/IJulia.jl After the prompt, I used "Pkg.add("IJulia") to install IJulia. However, I cannot use Julia with IPython notebook. After opening the notebook with ipython notebook --profile=julia the kernel for the julia notebook dies instantly and cannot be restarted.

How to automatically parenthesize an arbitrary Julia expression

*爱你&永不变心* 提交于 2020-01-05 08:36:38
问题 Given a syntactically valid, but otherwise arbitrary, Julia expression, such as 3 - 4 > 1 & 2 + 2 == 4 | 10 - 5 > 2 or 2 + 9 - 8 * 8 ^ 7 / 2 == 8 + 8 / 1 ^ 2 ...is there a convenient way to fully parenthesize the expression in a way consistent with Julia's standard parsing of it? One approach that won't go far enough: julia> parse("3 - 4 > 1 & 2+2 == 4 | 10 - 5 > 2") :(3 - 4 > 1 & 2 + 2 == (4 | 10) - 5 > 2) julia> parse("2 + 9 - 8 * 8 ^ 7 / 2 == 8 + 8 / 1 ^ 2") :((2 + 9) - (8 * 8^7) / 2 == 8

Pass additional arguments to a built-in function

北城以北 提交于 2020-01-05 08:32:00
问题 I'm pretty new on Julia and have a question that may appear simple. Say I have a function, which I will name test(x::Vector, arg1, arg2) where x is a vector of variables and the function has two arguments arg1 & arg2 . I would like to optimize (minimize) the function test with respect to the vector x . I can't figure out how to use the optimize function from the Optim package that accepts two arguments values. In R, one may do as following: optim(initial guest, test, arg1=value1,arg2=value2)

Pass additional arguments to a built-in function

这一生的挚爱 提交于 2020-01-05 08:31:31
问题 I'm pretty new on Julia and have a question that may appear simple. Say I have a function, which I will name test(x::Vector, arg1, arg2) where x is a vector of variables and the function has two arguments arg1 & arg2 . I would like to optimize (minimize) the function test with respect to the vector x . I can't figure out how to use the optimize function from the Optim package that accepts two arguments values. In R, one may do as following: optim(initial guest, test, arg1=value1,arg2=value2)

Julia v0.6 macro inside function

老子叫甜甜 提交于 2020-01-04 14:13:32
问题 Can someone resolve this macro error I'm having, it only started happening in version 0.6: mutable struct Foo x::Int end macro test(myfoo) quoteblock = quote myfoo.x += 1 end return quoteblock end function func(myfoo) @test myfoo println(myfoo.x) end foo = Foo(3) func(foo) In theory this should just replace the line @test myfoo in the function func with myfoo.x += 1 at compile time, which should work, but instead I get the error: UndefVarError: myfoo not defined 回答1: The corresponding change

How does Julia using behave on missing package?

吃可爱长大的小学妹 提交于 2020-01-04 13:44:48
问题 So what exactly does Julia do with the statement using Foo if you don't have package Foo installed? As I understood Julia starts searching JULIA_LOAD_PATH , but how? At the root level of JULIA_LOAD_PATH there must be a directory named Foo.jl where the Foo part may be case insensitive and the .jl suffix is optional? And within this Foo.jl directory there must be a source file name Foo.jl with a module Foo ? 回答1: using implicitly calls require which indirectly calls find_in_path: function find

Julia: why doesn't shared memory multi-threading give me a speedup?

空扰寡人 提交于 2020-01-04 09:14:30
问题 I want to use shared memory multi-threading in Julia. As done by the Threads.@threads macro, I can use ccall(:jl_threading_run ...) to do this. And whilst my code now runs in parallel, I don't get the speedup I expected. The following code is intended as a minimal example of the approach I'm taking and the performance problem I'm having: [EDIT: See later for even more minimal example] nthreads = Threads.nthreads() test_size = 1000000 println("STARTED with ", nthreads, " thread(s) and test

Why does julia not recognize the type of an array that is passed as a function argument, listing it as Any instead?

血红的双手。 提交于 2020-01-04 06:38:29
问题 I am defining a function in julia that accepts a vector (specifically Vector{Complex128} ). When I look at the output of @code_warntype I see that the variable type is listed as Any . This can potentially have speed implications, as I understand. Here is a simple version of the code, for example: function abc(h::Vector{Complex128}) a=1+2 end The output from @code_warntype is julia> @code_warntype abc(zeros(Complex128,2)) Variables: #self#::#abc h::Any a::Int64 Body: begin SSAValue(0) = (Base