Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Yichao Yu
On Wed, Nov 18, 2015 at 11:37 AM, Michele Zaffalon wrote: > Hi all, > > I would be glad if somebody could explain to me why the following function > which generates a pair of random integer between 1 and 6 and if they are > equal generates another pair > > function

[julia-users] norm() is faster than maxabs()

2015-11-18 Thread Sisyphuss
Interesting phenomenon: norm() is faster than maxabs() x = randn(10) @time maxabs(x) @time norm(x) 0.000108 seconds (5 allocations: 176 bytes) 0.40 seconds (5 allocations: 176 bytes) I have thought the contrary, for norm() requires N square and 1 square root; maxabs() requires 2N

[julia-users] Arbitrary Vector literal nesting

2015-11-18 Thread vishesh
Hi everyone, Julia seems cool! Vector literals have me completely stumped though. A little help? What is going on here? ["1","1"] => ASCIIString["1","1"] ["1",["1"]] => ASCIIString["1","1"] + "WARNING: [a,b] concatenation is deprecated; use [a;b] instead" ["1",Any["1"]] =>

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread Josh Langsfeld
Should also mention that even when ["1", ["1","2","3"]] returns a two element Vector{Any}, the inner array will still get inferred to be Vector{ASCIIString} unless you add the Any prefix. On Wednesday, November 18, 2015 at 12:30:28 PM UTC-5, Josh Langsfeld wrote: > > Your conclusion is correct.

[julia-users] String argument for @sprintf

2015-11-18 Thread Júlio Hoffimann
Hi, Could you please explain why this works: @sprintf("foo%02i", 3) but this doesn't: s = string("foo","%02i") @sprintf(s, 3) How is a formatted string different than an usual string? -Júlio

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread vishesh
Awesome, I see that 0.5 is scheduled for early December. Looking forward to having this fixed. On Wednesday, November 18, 2015 at 9:37:37 AM UTC-8, Josh Langsfeld wrote: > > Should also mention that even when ["1", ["1","2","3"]] returns a two > element Vector{Any}, the inner array will still

[julia-users] Re: indexing with non Integer Reals is deprecated

2015-11-18 Thread DNF
You can also do D[i+1-d>>1:j-3+q*5] which is actually slightly faster. It looks a bit obscure at first, but now I think of it as the 'halve stuff n times' operator, which is often the correct idiom. On Wednesday, November 18, 2015 at 10:08:08 AM UTC+1, Eric Forgy wrote: > > Hi Jon, > > Have

Re: [julia-users] Pkg.update error

2015-11-18 Thread J Luis
> > No. Ref https://github.com/JuliaLang/julia/issues/13200. Just try again. > Sorry, but julia> Pkg.update() INFO: Updating METADATA... INFO: Updating cache of Clang... INFO: Updating CodeTools... INFO: Updating GMT... INFO: Updating MutateIt... INFO: Updating Atom... INFO: Updating

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread Josh Langsfeld
Your conclusion is correct. The final switch should happen pretty soon on 0.5 master. Until then, the work-around is to prefix all your brackets with 'Any', including the inner arrays. On Wednesday, November 18, 2015 at 12:20:15 PM UTC-5, vis...@stanford.edu wrote: > > Hi everyone, > > Julia

[julia-users] Re: Pkg.update error

2015-11-18 Thread Benjamin Deonovic
No, I think Julia installs its ownAnaconda Python separate from your systems python. Looks like BinDeps needs to be recompiled. Try deleting its cache, or deleteing the BinDeps folder and reinstalling it. On Wednesday, November 18, 2015 at 9:22:19 AM UTC-6, J Luis wrote: > > Is this because I

[julia-users] Re: Converting ASCIIString to and from Array{UInt8,1}

2015-11-18 Thread James Gilbert
Thanks. I had tired convert(), but didn't use the correct type specifier.

[julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
Hi all, I would be glad if somebody could explain to me why the following function which generates a pair of random integer between 1 and 6 and if they are equal generates another pair function fun() d, N = 6, 50 for n = 1:N a, b = rand(1:d), rand(1:d) if a == b

[julia-users] Pkg.update error

2015-11-18 Thread J Luis
Is this because I don't have (nor want to have) Anaconda Python? Win8 here. INFO: Building PyCall INFO: Recompiling stale cache file C:\j\.julia\lib\v0.4\Conda.ji for module Conda. WARNING: Module BinDeps uuid did not match cache file WARNING: deserialization checks failed while

Re: [julia-users] Pkg.update error

2015-11-18 Thread Yichao Yu
On Wed, Nov 18, 2015 at 10:22 AM, J Luis wrote: > Is this because I don't have (nor want to have) Anaconda Python? > Win8 here. No. Ref https://github.com/JuliaLang/julia/issues/13200. Just try again. > > INFO: Building PyCall > INFO: Recompiling stale cache file

Re: [julia-users] Interesting: Plotly has become open source

2015-11-18 Thread Randy Zwitch
Eric, are you the person who I should talk to about getting Vega.jl to render inside Atom/Juno? I already render natively inside Jupyter Notebook, and to browser from the REPL, so it seems like it shouldn't be much effort to get Atom support. On Tuesday, November 17, 2015 at 5:16:07 PM UTC-5,

[julia-users] Re: String argument for @sprintf

2015-11-18 Thread Kristoffer Carlsson
https://groups.google.com/forum/#!topic/julia-users/iG6qwZ_GWzA http://stackoverflow.com/questions/19783030/in-julia-why-is-printf-a-macro-instead-of-a-function https://groups.google.com/forum/#!topic/julia-users/7Sn5yys0UJE etc On Wednesday, November 18, 2015 at 6:38:09 PM UTC+1, Júlio

Re: [julia-users] Re: String argument for @sprintf

2015-11-18 Thread Júlio Hoffimann
Thank you Kristoffer, I had forgot about that thread on Stack Overflow. Will use Formatting.jl Cheers, -Júlio 2015-11-18 10:40 GMT-08:00 Kristoffer Carlsson : > https://groups.google.com/forum/#!topic/julia-users/iG6qwZ_GWzA > > >

Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
On Wed, Nov 18, 2015 at 5:43 PM, Yichao Yu wrote: > On Wed, Nov 18, 2015 at 11:37 AM, Michele Zaffalon > wrote: > > Hi all, > > > > I would be glad if somebody could explain to me why the following > function > > which generates a pair of random

[julia-users] Re: Arbitrary Vector literal nesting

2015-11-18 Thread Sisyphuss
Not to disappoint you, but 0.5 is scheduled for early February 2016, and actually won't happen before April. On Wednesday, November 18, 2015 at 6:46:14 PM UTC+1, vis...@stanford.edu wrote: > > Awesome, I see that 0.5 is scheduled for early December. Looking forward > to having this fixed. >

Re: [julia-users] Accessing globals from C libraries

2015-11-18 Thread Tim Holy
If they're exported by the library, then you can use the HDF5.jl strategy as described in that thread. If they're not exported by the library, then Clang.jl is your awesome friend. --Tim On Wednesday, November 18, 2015 11:22:22 AM Cedric St-Jean wrote: > Is it possible to read the constants

Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Yichao Yu
On Wed, Nov 18, 2015 at 2:28 PM, Stefan Karpinski wrote: > Sometimes you've looked at your own code too long to see these things. > Someone else sees it right away. Disclaimer, I didn't see it right away either before running your code. > > On Wed, Nov 18, 2015 at 2:04 PM,

Re: [julia-users] Re: norm() is faster than maxabs()

2015-11-18 Thread Stefan Karpinski
Those numbers don't include any compilation (the allocations are too low). I'm seeing a similar thing. They're just implemented in really different ways. maxabs uses mapreduce, which seems to be a chronic source of less-than-optimal performance. On Wed, Nov 18, 2015 at 2:12 PM, Benjamin Deonovic

Re: [julia-users] Re: norm() is faster than maxabs()

2015-11-18 Thread Stefan Karpinski
That makes sense – thanks for the thorough analysis, Tim. On Wed, Nov 18, 2015 at 2:49 PM, Tim Holy wrote: > Note also that: > > function mynorm(x) > s = zero(x[1]^2) > @inbounds @simd for I in eachindex(x) >

[julia-users] Re: norm() is faster than maxabs()

2015-11-18 Thread Benjamin Deonovic
Does norm use maxabs? If so this could be due to maxabs getting compiled. try running both of the timed statements a second time. On Wednesday, November 18, 2015 at 10:41:48 AM UTC-6, Sisyphuss wrote: > > Interesting phenomenon: norm() is faster than maxabs() > > x = randn(10) > @time

[julia-users] Accessing globals from C libraries

2015-11-18 Thread Cedric St-Jean
Is it possible to read the constants from a C header/source file? I found this discussion from 2012, but there was no clean solution. Is the standard practice just to copy-paste

Re: [julia-users] Accessing globals from C libraries

2015-11-18 Thread Isaiah Norton
http://docs.julialang.org/en/release-0.4/manual/calling-c-and-fortran-code/#accessing-global-variables (only for exported globals -- preprocessor constants need to be extracted and defined in Julia) On Wed, Nov 18, 2015 at 2:22 PM, Cedric St-Jean wrote: > Is it

Re: [julia-users] Re: norm() is faster than maxabs()

2015-11-18 Thread Tim Holy
On Wednesday, November 18, 2015 02:30:01 PM Stefan Karpinski wrote: > Those numbers don't include any compilation (the allocations are too low). > I'm seeing a similar thing. They're just implemented in really different > ways. maxabs uses mapreduce, which seems to be a chronic source of >

Re: [julia-users] Re: norm() is faster than maxabs()

2015-11-18 Thread Tim Holy
Note also that: function mynorm(x) s = zero(x[1]^2) @inbounds @simd for I in eachindex(x) s += x[I]^2 end sqrt(s) end does get SIMDed. So the difference is almost surely

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread NotSoRecentConvert
Hmm, the little example works but my code still doesn't. I've trimmed my code down to something smaller that still misbehaves. "# Eddy Meas Module The Eddy Meas module is a collection of functions to work with SLT files generated by EddySoft and, more specifically, EddyMeas. `sltload`: Load

[julia-users] Re: pmap data transfer between processes

2015-11-18 Thread bernhard
An addition/answer from my side: I think pmap does indeed "send" the data to the process each time (my code below seems to indicate this). I suppose pmap cannot know/assume that it is constant. The sendto functions help my use case! addprocs(3); @everywhere function

Re: [julia-users] Formatting function definition to accept ASCIIString AND UTF8String

2015-11-18 Thread NotSoRecentConvert
It works now. @bernhard, my problem wasn't with joinpath but with the changes to the string types. My code used String so it didn't care if it was ASCIIString or UTF8String and swapping String with AbstractString didn't work initially. I was also using the joinpath code as an example to figure

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread Michael Hatherly
Not sure what the trouble is then. If possible could you post the entire module that's misbehaving as a gist, https://gist.github.com/? - Mike On Wednesday, 18 November 2015 12:25:48 UTC+2, NotSoRecentConvert wrote: > > When I fix it in the Test module it works but when I do the *exact same >

[julia-users] How to play "synchronized" in Julia

2015-11-18 Thread Yuhui ZHI
I have a list and two threads. One thread can push messages to the list and the other can pop messages from the list. So obviously I need to use something like "synchronized" in Java because I may push a very huge message into the list. If the push is not finished while the other thread

Re: [julia-users] Re: 2-by-2 dense linear system performance

2015-11-18 Thread Tim Holy
If allocating the arrays is a big bottleneck, you might consider making use of/adding this to FixedSizeArrays. --Tim On Tuesday, November 17, 2015 05:12:13 PM Pavel wrote: > Quite useful, thank you. Essentially choosing the form of exact expression > based on matrix element comparison. Appears

[julia-users] Re: pmap data transfer between processes

2015-11-18 Thread bernhard
additonally the sendto_module functions are helpful in my case. I would say adding some of this to the documentation my help others with similar questions. function sendto_module(m::Module,p::Int; args...) for (nm, val) in args; @spawnat(p, eval(m, Expr(:(=), nm, val))) end end function

Re: [julia-users] Re: 2-by-2 dense linear system performance

2015-11-18 Thread Kristoffer Carlsson
With FSA I get around a factor 50 speedup (when I don't use the iterative corrector): function \{T}(A::FixedMatrix{2, 2, T}, b::FixedVector{2, T}) x = unroll_LU(A[1,1], A[1,2], b[1], A[2,1], A[2,2], b[2]) return x end @inline function unroll_LU{T <: Number}(a::T ,b::T ,c::T , d::T ,e::T

[julia-users] Re: indexing with non Integer Reals is deprecated

2015-11-18 Thread Jon Norberg
On a very practical note: I need to to do inline calculations of indexes such as D[i+1-d/2:j-3+q*5] where i,d,j and q are Int64 and d is a multiple of 2 i.e. d/2 should always be integer What is the most efficient way to use an expression as above but to avoid the Warning: indexing with non

Re: [julia-users] Writing CSV

2015-11-18 Thread Milan Bouchet-Valat
Le mardi 17 novembre 2015 à 13:29 -0800, digxx a écrit : > with > writedlm("C:\\Users\\Diger\\Documents\\Julia\\x_values.csv",zip(x_s[1 > ,1:end],x[1:end],epsilon[1,1:end,1],omega[300,1:end,1]),',') > I wanted to write a csv file comma separated... > Now in the manual it says that everything is

[julia-users] Formatting function definition to accept ASCIIString AND UTF8String

2015-11-18 Thread NotSoRecentConvert
I have a simple function which takes a directory string and returns a list of files and directories which fit some other parameters. My problem is that I can't find a function definition which accepts both ASCIIString and UTF8String types. Previous to Julia 0.4 I just used String and everything

Re: [julia-users] Formatting function definition to accept ASCIIString AND UTF8String

2015-11-18 Thread Milan Bouchet-Valat
Le mercredi 18 novembre 2015 à 00:40 -0800, NotSoRecentConvert a écrit : > I have a simple function which takes a directory string and returns a > list of files and directories which fit some other parameters. My > problem is that I can't find a function definition which accepts both >

[julia-users] Re: Define an objective function type

2015-11-18 Thread Eric Forgy
Try "Function"? julia> f(x) = x^2 f (generic function with 1 method) julia> typeof(f) Function On Wednesday, November 18, 2015 at 4:05:43 PM UTC+8, Sisyphuss wrote: > > Hello, everyone, > > I'd like to construct a type which contains some functions that I would > like to give value later (as

[julia-users] Define an objective function type

2015-11-18 Thread Sisyphuss
Hello, everyone, I'd like to construct a type which contains some functions that I would like to give value later (as attributes of instance). I define this type as: ``` type Objective f::Any g::Any end ``` where `f` is the objective function and `g` is the derivative. My question is:

[julia-users] Re: 2-by-2 dense linear system performance

2015-11-18 Thread Kristoffer Carlsson
Glad it worked well.

[julia-users] Re: Formatting function definition to accept ASCIIString AND UTF8String

2015-11-18 Thread NotSoRecentConvert
I looked at the joinpath code but couldn't tell why it had no problem using AbstractString to accept UFT8String or ASCIIString. joinpath(a::AbstractString) = a joinpath(a::AbstractString, b::AbstractString, c::AbstractString...) = joinpath(joinpath(a,b), c...) function

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread Michael Hatherly
Single-quoted strings don't strip leading whitespace, which means that in the second docstring is being treated as an indented code block. For any docstring longer than a single line triple-quoted strings should be used instead. - Mike On Wednesday, 18 November 2015 11:38:25 UTC+2,

[julia-users] Re: problem running jl files

2015-11-18 Thread Forrest Curo
Following an example on another site, I see that staying with the REPL and typing: include("newbox.jl") would work (aside from needing to change a package name or two -- and possibly finding some way to put in '--depwarnings=no' -- I can't be sure whether that's still needed(?)) What's gone

[julia-users] Re: Define an objective function type

2015-11-18 Thread Sisyphuss
Thanks. So the first question is solved. On Wednesday, November 18, 2015 at 9:42:26 AM UTC+1, Eric Forgy wrote: > > Try "Function"? > > julia> f(x) = x^2 > f (generic function with 1 method) > > julia> typeof(f) > Function > > > On Wednesday, November 18, 2015 at 4:05:43 PM UTC+8, Sisyphuss

[julia-users] Re: Define an objective function type

2015-11-18 Thread Sisyphuss
On Wednesday, November 18, 2015 at 2:53:02 PM UTC+1, Christoph Ortner wrote: > > Not quite answering your question, but here is how I like to do this: > > abstract ObjectiveFunction > type MyOF <: ObjectiveFunction >params > end > > function evaluate(f::ObjectiveFunction, x) > . .. >

[julia-users] Re: Define an objective function type

2015-11-18 Thread Christoph Ortner
Not quite answering your question, but here is how I like to do this: abstract ObjectiveFunction type MyOF <: ObjectiveFunction params end function evaluate(f::ObjectiveFunction, x) . .. end function evaluate_grad(f::ObjectiveFunction, x) . . . end Then, to get nice syntax, I add

Re: [julia-users] How to play "synchronized" in Julia

2015-11-18 Thread Erik Schnetter
You can use a Channel instead of an Array to communicate. You can set the channel's buffer size to 1, which ensures that only at most 1 message is in the queue. -erik On Wed, Nov 18, 2015 at 5:01 AM, Yuhui ZHI wrote: > > > I have a list and two threads. > > One thread

[julia-users] Re: Progress meter for parallel workers

2015-11-18 Thread Jason Eckstein
Interesting, thanks for the help. On Tuesday, November 17, 2015 at 8:09:44 PM UTC-7, Benjamin Deonovic wrote: > > I made a progress meter for parallel runners once in julia about a year > ago. I've since stopped using the code but it might inspire you to make > something similar: > >

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread NotSoRecentConvert
After further testing I think it has to do with caching. I copied more and more functions from the original module to the test one, testing each time. By the end I just copied and pasted everything, changing only the module name to Test in the test module. It worked with no problems. Then I

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread NotSoRecentConvert
It's a bit strange though. If I document functions which had no previously been documented in the original module and then try to load the documentation in REPL it *does* indeed show the new documentation but with incomplete formatting. When it's then copied and pasted into the Test module it

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread Michael Hatherly
Docs gets captured at macro expansion time so there's no simple way to reset the module's docstring cache other than just reloading the module completely. What are the steps you're going through when reloading the modules, which commands are you using? Are you restarting Julia between each

Re: [julia-users] Module documentation not formatting properly

2015-11-18 Thread NotSoRecentConvert
I restart Julia. As far as I know it's the most thorough way of making sure it's reloaded properly. Then it's just the usual way of loading a module, *using Test*.

[julia-users] Re: Define an objective function type

2015-11-18 Thread Christoph Ortner
On Wednesday, 18 November 2015 09:16:30 UTC-5, Sisyphuss wrote: > > > > On Wednesday, November 18, 2015 at 2:53:02 PM UTC+1, Christoph Ortner > wrote: >> >> Not quite answering your question, but here is how I like to do this: >> >> abstract ObjectiveFunction >> type MyOF <: ObjectiveFunction

Re: [julia-users] example code in chapter calling-c-and-fortran-code does not work

2015-11-18 Thread Yichao Yu
On Wed, Nov 18, 2015 at 4:31 PM, Martin Kuzma wrote: > Hello, I am learning Julia and reading the documentation. > There is this example: > > function gethostname() > hostname = Array(UInt8, 128) > ccall( (:gethostname, "libc"), Int32, > (Ptr{UInt8}, UInt), >

[julia-users] What if a Union of abstract types were Abstract?

2015-11-18 Thread Jeffrey Sarnoff
#= What if a Union of abstract types were Abstract? =# import Base: super, subtypes, typeof # pretend typeof can be overloaded type AbstractUnion end super(u::Union) = typejoin(u.types...) subtypes(u::Union)= [ [(t.abstract ? subtypes(t) : [t]) for t in

[julia-users] example code in chapter calling-c-and-fortran-code does not work

2015-11-18 Thread Martin Kuzma
Hello, I am learning Julia and reading the documentation. There is this example: function gethostname() hostname = Array(UInt8, 128) ccall( (:gethostname, "libc"), Int32, (Ptr{UInt8}, UInt), hostname, length(hostname)) return bytestring(convert(Ptr{UInt8}, hostname))end I

[julia-users] Access Bloomberg data with Julia

2015-11-18 Thread Charles Novaes de Santana
Hi, Does anyone know a way to access Bloomberg data with Julia? I know there is a library in R ( http://ftp.auckland.ac.nz/software/CRAN/src/contrib/Descriptions/RBloomberg.html) but I think it is no longer updated. There is also an API for Python, available here:

[julia-users] Build of julia with clang on windows. Clang.jl cannot build

2015-11-18 Thread Petr Hlavenka
Hi, Under windows7, msys2, I've managed to build successfully Julia 0.4.1 with BUILD_LLVM_CLANG=1 option enabled. However, while building Clang.jl package, compiler complains on the non-existent -lclang library. julia> Pkg.build("Clang") INFO: Building Clang g++ wrapclang.cpp.o -rdynamic

[julia-users] Are print, warn, etc. "preemptible"?

2015-11-18 Thread vmarsi75-ggroups via julia-users
Hi, I have a fairly typical 2-task write/read scenario, with one task writing into a fixed-length buffer, and the other task reading from it. I have the following piece of code in the write task: function bufWrite(buf, value) if buf.full warn("Buffer is full") print("full =

Re: [julia-users] Interesting: Plotly has become open source

2015-11-18 Thread Eric Forgy
Hi Randy, I've done quite a bit of work with d3 directly and am interested in learning how Julia interacts with Atom (via Juno) to leverage that work. I would imagine the same or similar implementation would work with both Vega.jl and Plotly.jl in Atom. I'm not an expert but happy to help

Re: [julia-users] rand under Windows returns almost always 1

2015-11-18 Thread Michele Zaffalon
On Wed, Nov 18, 2015 at 8:33 PM, Yichao Yu wrote: > On Wed, Nov 18, 2015 at 2:28 PM, Stefan Karpinski > wrote: > > Sometimes you've looked at your own code too long to see these things. > > Someone else sees it right away. > > Disclaimer, I didn't see it

Re: [julia-users] Do I have simd?

2015-11-18 Thread Yichao Yu
On Wed, Nov 18, 2015 at 5:44 PM, 'Greg Plowman' via julia-users wrote: > 1. Does simd work for Integer types? > > code_llvm shows vector.body section for Int16,Int32,Float32,Float64 but not > for Int64. (on my Windows 64 machine, Julia v0.4.1) > > Speedup is seen for