[julia-users] ANN: Julia 0.5.0-rc4 now available

2016-09-09 Thread Tony Kelman
I have just tagged and uploaded release candidate 4 for Julia version 
0.5.0. Binaries are available from

https://s3.amazonaws.com/julialang/bin/linux/x64/0.5/julia-0.5.0-rc4-linux-x86_64.tar.gz
 
https://s3.amazonaws.com/julialang/bin/linux/x86/0.5/julia-0.5.0-rc4-linux-i686.tar.gz
https://s3.amazonaws.com/julialang/bin/linux/arm/0.5/julia-0.5.0-rc4-linux-arm.tar.gz
 
https://s3.amazonaws.com/julialang/bin/osx/x64/0.5/julia-0.5.0-rc4-osx10.7+.dmg 
https://s3.amazonaws.com/julialang/bin/winnt/x64/0.5/julia-0.5.0-rc4-win64.exe 
https://s3.amazonaws.com/julialang/bin/winnt/x86/0.5/julia-0.5.0-rc4-win32.exe 
https://s3.amazonaws.com/julialang/bin/checksums/julia-0.5.0-rc4.sha256 
https://s3.amazonaws.com/julialang/bin/checksums/julia-0.5.0-rc4.md5 
For gpg signatures (with this key http://julialang.org/juliareleases.asc) 
of the Linux tar.gz binaries, append .asc to the filename.

Sorry there was a bit of a delay, one of the precompilation-related 
backports just after RC3 had a bug that took some time to get fixed. Please 
test this and report any issues. Unless anything major comes up over the 
weekend or early next week, I plan doing at most a handful more very small 
backports then tagging 0.5.0 final. Bugfixes will continue to be backported 
to the release-0.5 branch for an 0.5.1 patch release roughly a month after 
that.

-Tony



[julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread K leo
I tried the following, it compiles OK and runs OK, but it appears the julia 
function is not called (because there is no output from the println 
statement).  What is wrong?

#include 
> #include 
> using namespace std;
> struct TestType {
> double a;
> double b;
> };
> int main(int argc, char *argv[])
> {
> TestType A, *ret;
> A.a=2.;
> A.b=3.;
> jl_init(NULL);
> jl_load("TestArg.jl");
> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
> jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
> jl_call1(func, (jl_value_t *)&A);
> jl_atexit_hook(0);
> return 0;
> }
> # TestArg.jl
> module TestArg
> type TestType
> a::Float64
> b::Float64
> end
> function TestFunc(data::TestType)
> println("in TestArg.TestFunc ")
> end
> end




Re: [julia-users] Re: How I did get a spurious method for *{T}(Irrational{T},Irrational{T})?

2016-09-09 Thread Tim Holy
https://github.com/JuliaLang/julia/issues/18419

--Tim

On Wednesday, September 7, 2016 12:59:05 AM CDT Lutfullah Tomak wrote:
> A reduced case that also makes multiplication of the same Irrational an
> error.
> 
>_
>_   _ _(_)_ |  A fresh approach to technical computing
>   (_) | (_) (_)|  Documentation: http://docs.julialang.org
>_ _   _| |_  __ _   |  Type "?help" for help.
> 
>   | | | | | | |/ _` |  |
>   | | |
>   | | |_| | | | (_| |  |  Version 0.5.0-rc3+0 (2016-08-22 23:43 UTC)
> 
>  _/ |\__'_|_|_|\__'_|  |
> 
> |__/   |  x86_64-linux-gnu
> 
> julia> module Erratic
> 
> 
>const DummyUnion =  Union{Irrational,AbstractFloat}
>abstract DummyReal <: Real
>immutable DummyType <: DummyReal
>var::DummyUnion
>end
> 
> 
>mulSym(x::DummyUnion, y::DummyUnion) = x*y
>mulSym(x::DummyUnion, y::DummyType)  = DummyType(mulSym(x, y.var
> ))
> 
> 
>import Base.*
>*(x::DummyUnion, y::DummyReal) = mulSym(x, y)
> 
> 
>end
> Erratic
> 
> 
> julia> pi*pi
> ERROR: * not defined for Irrational{:π}
>  in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
>  in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
>  in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
>  in eval(::Module, ::Any) at ./boot.jl:234
> 
> 
> julia> pi*Erratic.DummyType(pi)
> ERROR: * not defined for Irrational{:π}
>  in error(::String, ::String, ::Vararg{Any,N}) at ./error.jl:22
>  in no_op_err(::String, ::Type{T}) at ./promotion.jl:254
>  in *(::Irrational{:π}, ::Irrational{:π}) at ./promotion.jl:256
>  in mulSym(::Irrational{:π}, ::Irrational{:π}) at ./REPL[1]:9
>  in mulSym(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:10
>  in *(::Irrational{:π}, ::Erratic.DummyType) at ./REPL[1]:13
>  in eval(::Module, ::Any) at ./boot.jl:234
> 
> 
> julia> pi*Erratic.DummyType(2.)
> Erratic.DummyType(6.283185307179586)
> 
> DummyReal does not cover Irrationals but it somehow triggers default
> *{T<:Number}(x::T, y::T) = no_op_err("*", T)
> What kind of number does not have multiplication defined with itself?




[julia-users] Inference and Core.Box - why is this happening?

2016-09-09 Thread Patrick Kofod Mogensen
So, I am kind of confused here. In my code, a maxV = maximum(V) is labeled 
as Core.Box in @code_warntype, but if I remove a line after the line where 
maxV is calculated, it is correctly labelled as eltype(V). Can anyone 
explain what happens/what I am doing wrong here? This is not the whole 
function, I've tried to remove all irrelevant code.
V = [0.,]
P = Vector{Float64}[[0.0,], [0.0,]]
U = Vector{Float64}[[1.,], [1.,]]
F = Matrix{Float64}[eye(1), eye(1)]
b = 0.9

function c!{T}(P, U, b::T, F, V)
if length(P) > 2
maxV = maximum(V)
d = sum(exp(U[ia]+b*F[ia]*V-maxV) for ia = 1:length(P))::T
end
P
end

# This shows maxV as Core.Box
@code_warntypec!(P, U, β, F, V)


function c!{T}(P, U, b::T, F, V)
if length(P) > 2
maxV = maximum(V)
end
P
end

# This does not show maxV as Core.Box, but as eltype(V) as I expected
@code_warntypec!(P, U, β, F, V)

Thanks


[julia-users] @profile does not allow variable assignment on v0.5

2016-09-09 Thread Florian Oswald
hi all, 

on v0.5-rc3, I see this

*julia> **f(x)=x^3*

*f (generic function with 1 method)*


*julia> **@profile y = f(5)*

*125*


*julia> **y*

*ERROR: UndefVarError: y not defined*



which used to work in previous versions. Is that intended behaviour?




[julia-users] Why is BLAS.dot slower than BLAS.axpy!?

2016-09-09 Thread Sheehan Olver

I have the following code that is part of a Householder routine, where 
j::Int64, 
N::Int64, R.cols::Vector{Int64}, wp::Ptr{Float64}, M::Int64, 
v::Ptr{Float64}:

  …
for j=k:N
v=r+(R.cols[j]+k-2)*sz
dt=BLAS.dot(M,wp,1,v,1)
BLAS.axpy!(M,-2*dt,wp,1,v,1)
end
…



For some reason, the BLAS.dot call takes 3x as long as the BLAS.axpy! call. 
 Is this expected, or is there something wrong?




[julia-users] Parallel computation of Array of user-defined types

2016-09-09 Thread amiksvi
Hello,

What would be the best option to parallelize this code:

type T a end
f(i) = T(i)
v = map(f, collect(1:1:100))

This example could sound stupid but the point is that I have a function 
```f``` that returns a rather complicated user-defined type ```T```, and I 
need to store a lot of these types in an ```Array```.
I've read a bit about the parallel paradigm of Julia and I honestly 
wouldn't know how to do such a thing.

Any hint?

Many thanks!


[julia-users] Re: Inference and Core.Box - why is this happening?

2016-09-09 Thread Lutfullah Tomak
Using a captured variable in a closure makes it somehow a Core.box.
Generator defines an anonymous with maxV so it is hitting something like 
this https://github.com/JuliaLang/julia/issues/15276
Smaller repro
function c!{T}(::T,P)
  if length(P)>2
maxV = one(T)
d = x->maxV
  end
  P
end



On Friday, September 9, 2016 at 1:02:29 PM UTC+3, Patrick Kofod Mogensen 
wrote:
>
> So, I am kind of confused here. In my code, a maxV = maximum(V) is labeled 
> as Core.Box in @code_warntype, but if I remove a line after the line where 
> maxV is calculated, it is correctly labelled as eltype(V). Can anyone 
> explain what happens/what I am doing wrong here? This is not the whole 
> function, I've tried to remove all irrelevant code.
> V = [0.,]
> P = Vector{Float64}[[0.0,], [0.0,]]
> U = Vector{Float64}[[1.,], [1.,]]
> F = Matrix{Float64}[eye(1), eye(1)]
> b = 0.9
>
> function c!{T}(P, U, b::T, F, V)
> if length(P) > 2
> maxV = maximum(V)
> d = sum(exp(U[ia]+b*F[ia]*V-maxV) for ia = 1:length(P))::T
> end
> P
> end
>
> # This shows maxV as Core.Box
> @code_warntypec!(P, U, β, F, V)
>
>
> function c!{T}(P, U, b::T, F, V)
> if length(P) > 2
> maxV = maximum(V)
> end
> P
> end
>
> # This does not show maxV as Core.Box, but as eltype(V) as I expected
> @code_warntypec!(P, U, β, F, V)
>
> Thanks
>


Re: [julia-users] @profile does not allow variable assignment on v0.5

2016-09-09 Thread Yichao Yu
On Fri, Sep 9, 2016 at 6:04 AM, Florian Oswald 
wrote:

> hi all,
>
> on v0.5-rc3, I see this
>
> *julia> **f(x)=x^3*
>
> *f (generic function with 1 method)*
>
>
> *julia> **@profile y = f(5)*
>
> *125*
>
>
> *julia> **y*
>
> *ERROR: UndefVarError: y not defined*
>
>
>
> which used to work in previous versions. Is that intended behaviour?
>


I believe this is the same on 0.3 and 0.4. Of course being in a
`try`-`catch` the behavior is different if the global was defined
previously.


[julia-users] Re: @profile does not allow variable assignment on v0.5

2016-09-09 Thread Lutfullah Tomak
I think it is on the way @profile defined makes it not processed in outer 
scope

julia> macroexpand(:(@profile y = f(5)))
quote  # profile.jl, line 11:
try  # profile.jl, line 12:
#10#status = (Base.Profile.start_timer)() # profile.jl, line 13:
if #10#status < 0 # profile.jl, line 14:
(Base.Profile.error)((Base.Profile.error_codes)[#10#status])
end # profile.jl, line 16:
y = f(5)
finally  # profile.jl, line 18:
(Base.Profile.stop_timer)()
end
end

try finally end block makes y a local variable if not defined beforehand.

julia> try
   y=125
   finally
   nothing
   end
125


julia> y
ERROR: UndefVarError: y not defined


julia> y =5
5


julia> try
   y=125
   finally
   nothing
   end
125


If you think it is a regression file a bug report for profile.


On Friday, September 9, 2016 at 1:04:21 PM UTC+3, Florian Oswald wrote:
>
> hi all, 
>
> on v0.5-rc3, I see this
>
> *julia> **f(x)=x^3*
>
> *f (generic function with 1 method)*
>
>
> *julia> **@profile y = f(5)*
>
> *125*
>
>
> *julia> **y*
>
> *ERROR: UndefVarError: y not defined*
>
>
>
> which used to work in previous versions. Is that intended behaviour?
>
>
>

[julia-users] Re: Running octave scrips from julia

2016-09-09 Thread Steven G. Johnson


On Friday, February 6, 2015 at 2:03:23 PM UTC-5, astromono wrote:
>
>   in pyinitialize at /home/rober/.julia/v0.4/PyCall/src/pyinit.jl:245
>

 I think you must have pinned PyCall at some ancient version, because the 
current pyinit.jl file only has 115 lines.


[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Steven G. Johnson


On Friday, September 9, 2016 at 2:56:02 AM UTC-4, Christoph Ortner wrote
>
> (2) convert it to a PyArray (no copy) : 
> Xpy = PyArray(X)
>
>
> (3) then assign this to a field of an object:   
> pyobj["X"] = Xpy   orpyobj["X"] = Xpy.o or 
>
> The aim is, when I modify X, then the data in pyobj[:X] should be modified 
> as well. The way described above does not work. 
>

 pyobj["X"] = Xpy is the equivalent of pyobj.X = X in Python.   Is that 
what you want to do?  Is. pyobj.X a writable attribute in Python?  What 
error message are you getting?   It "does not work" is not a useful 
description of your problem.


[julia-users] Re: Preferred MIME type for Julia

2016-09-09 Thread Steven G. Johnson


On Thursday, September 8, 2016 at 8:42:51 PM UTC-4, Fengyang Wang wrote:
>
> What is the standard MIME type for Julia code?
>
> My reading of the MIME standard leads to me think 
> application/x-julia
>
> is the accurate choice. However, I could only find few results on Google, 
> and Julia doesn't currently recognize this as a text MIME.
>

The "x-foo" MIME types are deprecated . 
  Use application/julia.  (I really wish that programming language code 
used text/, e.g. text/julia, but that doesn't seem to be the standard 
practice.)


[julia-users] Re: @profile does not allow variable assignment on v0.5

2016-09-09 Thread Florian Oswald
I'm pretty sure this behaved differently some time ago, because that was a 
piece of working code. It's not worth a bug report though.

On Friday, 9 September 2016 13:19:12 UTC+2, Lutfullah Tomak wrote:
>
> I think it is on the way @profile defined makes it not processed in outer 
> scope
>
> julia> macroexpand(:(@profile y = f(5)))
> quote  # profile.jl, line 11:
> try  # profile.jl, line 12:
> #10#status = (Base.Profile.start_timer)() # profile.jl, line 13:
> if #10#status < 0 # profile.jl, line 14:
> (Base.Profile.error)((Base.Profile.error_codes)[#10#status])
> end # profile.jl, line 16:
> y = f(5)
> finally  # profile.jl, line 18:
> (Base.Profile.stop_timer)()
> end
> end
>
> try finally end block makes y a local variable if not defined beforehand.
>
> julia> try
>y=125
>finally
>nothing
>end
> 125
>
>
> julia> y
> ERROR: UndefVarError: y not defined
>
>
> julia> y =5
> 5
>
>
> julia> try
>y=125
>finally
>nothing
>end
> 125
>
>
> If you think it is a regression file a bug report for profile.
>
>
> On Friday, September 9, 2016 at 1:04:21 PM UTC+3, Florian Oswald wrote:
>>
>> hi all, 
>>
>> on v0.5-rc3, I see this
>>
>> *julia> **f(x)=x^3*
>>
>> *f (generic function with 1 method)*
>>
>>
>> *julia> **@profile y = f(5)*
>>
>> *125*
>>
>>
>> *julia> **y*
>>
>> *ERROR: UndefVarError: y not defined*
>>
>>
>>
>> which used to work in previous versions. Is that intended behaviour?
>>
>>
>>

Re: [julia-users] Julia with fewer dependencies?

2016-09-09 Thread Joaquim Dias Garcia
Thanks! That is a great start!

Joaquim

> On 6 de set de 2016, at 03:24, Michele Zaffalon  
> wrote:
> 
> Is this maybe what you are looking for 
> https://groups.google.com/d/msg/julia-users/WStpLtrKiFA/JhiAbc-vAwAJ?
> 
>> On Mon, Sep 5, 2016 at 11:10 PM, Joaquim Masset Lacombe Dias Garcia 
>>  wrote:
>> 
>> The basic question is "Can I compile a smaller version of julia?"
>> 
>> For instance, I want to ship some program as an executable, something 
>> similar to what BuildExecutable.jl does, btw its very nice!
>> The only problem is that with BuildExecutable.jl or even with the pure 
>> usrimg.jl trick create a huge folder with all the julia main libs.
>> 
>> I looked for an existing post but all I could find is this archived old 
>> post: 
>> https://www.reddit.com/r/Julia/comments/2da03c/julia_with_fewer_dependencies/
>> 
>> Can I compile julia without some of those libs?
>> 
>> One nice use would be if I have a program with no use of libopenblas that I 
>> could ship without having to send a 40Mb lib...
>> 
>> Thanks in advance!
> 


[julia-users] Re: Inference and Core.Box - why is this happening?

2016-09-09 Thread Patrick Kofod Mogensen
I was referred to that issue earlier but didn't quite get why, but now I 
see it! Thanks.

On Friday, September 9, 2016 at 1:02:27 PM UTC+2, Lutfullah Tomak wrote:
>
> Using a captured variable in a closure makes it somehow a Core.box.
> Generator defines an anonymous with maxV so it is hitting something like 
> this https://github.com/JuliaLang/julia/issues/15276
> Smaller repro
> function c!{T}(::T,P)
>   if length(P)>2
> maxV = one(T)
> d = x->maxV
>   end
>   P
> end
>
>
>
> On Friday, September 9, 2016 at 1:02:29 PM UTC+3, Patrick Kofod Mogensen 
> wrote:
>>
>> So, I am kind of confused here. In my code, a maxV = maximum(V) is 
>> labeled as Core.Box in @code_warntype, but if I remove a line after the 
>> line where maxV is calculated, it is correctly labelled as eltype(V). Can 
>> anyone explain what happens/what I am doing wrong here? This is not the 
>> whole function, I've tried to remove all irrelevant code.
>> V = [0.,]
>> P = Vector{Float64}[[0.0,], [0.0,]]
>> U = Vector{Float64}[[1.,], [1.,]]
>> F = Matrix{Float64}[eye(1), eye(1)]
>> b = 0.9
>>
>> function c!{T}(P, U, b::T, F, V)
>> if length(P) > 2
>> maxV = maximum(V)
>> d = sum(exp(U[ia]+b*F[ia]*V-maxV) for ia = 1:length(P))::T
>> end
>> P
>> end
>>
>> # This shows maxV as Core.Box
>> @code_warntypec!(P, U, β, F, V)
>>
>>
>> function c!{T}(P, U, b::T, F, V)
>> if length(P) > 2
>> maxV = maximum(V)
>> end
>> P
>> end
>>
>> # This does not show maxV as Core.Box, but as eltype(V) as I expected
>> @code_warntypec!(P, U, β, F, V)
>>
>> Thanks
>>
>

[julia-users] idiom for standard basis vector (eg [0,1,0])

2016-09-09 Thread Tamas Papp
Is there a preferred constructor for standard basis vectors? Eg
something equivalent to

function sbvec(T, n, i)
v = zeros(T, n)
v[i] = one(T)
v
end

Note that I am not implying that there should be one in Base etc. I
would just avoid defining if already available, but could not find it.

Best,

Tamas


[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Christoph Ortner
Sorry - I was rushing when I wrote this. What I meant was: after the 
assignment pyobj["X"] = Xpy, if I modify X in-place, this modification does 
not seem to propagate to pyobj.X. I will try to put together an example.




[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Christoph Ortner
It now looks to me like the "problem" is with Python, not with PyCall; I 
thought the assignment pyobj.X = X  would be by reference, but apparently 
it makes a copy ?!?

Alternatively, to achieve what I want I could do   
Xpy = PyArray( pyobj.X )

Now Xpy is really a reference to the array I want to manipulate.  How can I 
now "reinterpret" Xpy (i.e. the block of memory) as a Julia Array, or other 
Julia data structure - specifically I want a Vector of FixedSizeArray ?

Thank you.

On Friday, 9 September 2016 13:18:58 UTC+1, Christoph Ortner wrote:
>
> Sorry - I was rushing when I wrote this. What I meant was: after the 
> assignment pyobj["X"] = Xpy, if I modify X in-place, this modification does 
> not seem to propagate to pyobj.X. I will try to put together an example.
>
>
>

[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Christoph Ortner
To partially answer my own question --- I just hadn't thought of this 
alternative route before --- the following seems to do it:

X = pointer_to_array(Xpy.data, (Xpy.dims[2], Xpy.dims[1]), false)

Are there any concerns associated with this other than the risk that Python 
might free the allocated memory associated with that pointer?


On Friday, 9 September 2016 13:33:09 UTC+1, Christoph Ortner wrote:
>
> It now looks to me like the "problem" is with Python, not with PyCall; I 
> thought the assignment pyobj.X = X  would be by reference, but apparently 
> it makes a copy ?!?
>
> Alternatively, to achieve what I want I could do   
> Xpy = PyArray( pyobj.X )
>
> Now Xpy is really a reference to the array I want to manipulate.  How can 
> I now "reinterpret" Xpy (i.e. the block of memory) as a Julia Array, or 
> other Julia data structure - specifically I want a Vector of FixedSizeArray 
> ?
>
> Thank you.
>
> On Friday, 9 September 2016 13:18:58 UTC+1, Christoph Ortner wrote:
>>
>> Sorry - I was rushing when I wrote this. What I meant was: after the 
>> assignment pyobj["X"] = Xpy, if I modify X in-place, this modification does 
>> not seem to propagate to pyobj.X. I will try to put together an example.
>>
>>
>>

Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Isaiah Norton
In c, 'struct TestType' is plain old data, not a Julia type (jl_value_t).
Either change to an immutable on julia side, and change function signature
to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with the correct type tag, and
set the fields.

On Friday, September 9, 2016, K leo  wrote:

> I tried the following, it compiles OK and runs OK, but it appears the
> julia function is not called (because there is no output from the println
> statement).  What is wrong?
>
> #include 
>> #include 
>> using namespace std;
>> struct TestType {
>> double a;
>> double b;
>> };
>> int main(int argc, char *argv[])
>> {
>> TestType A, *ret;
>> A.a=2.;
>> A.b=3.;
>> jl_init(NULL);
>> jl_load("TestArg.jl");
>> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
>> jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
>> jl_call1(func, (jl_value_t *)&A);
>> jl_atexit_hook(0);
>> return 0;
>> }
>> # TestArg.jl
>> module TestArg
>> type TestType
>> a::Float64
>> b::Float64
>> end
>> function TestFunc(data::TestType)
>> println("in TestArg.TestFunc ")
>> end
>> end
>
>
>


[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Steven G. Johnson


On Friday, September 9, 2016 at 8:33:09 AM UTC-4, Christoph Ortner wrote:
>
> It now looks to me like the "problem" is with Python, not with PyCall; I 
> thought the assignment pyobj.X = X  would be by reference, but apparently 
> it makes a copy ?!?
>

Converting an array from Julia to Python in PyCall (e.g. by pyobject["X"] = 
X) is by reference (i.e. it wraps a numpy array around the same data). 
 However, converting an array from Python back to Julia defaults to making 
a copy, unless you explicitly use a PyArray, as in PyArray(pyobj["X"]).
 

> Now Xpy is really a reference to the array I want to manipulate.  How can 
> I now "reinterpret" Xpy (i.e. the block of memory) as a Julia Array, or 
> other Julia data structure - specifically I want a Vector of FixedSizeArray 
> ?
>

Why do you need an Array?   Why not just use the PyArray as-is?


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread K leo
Isaiah,

Thanks for the reply.

I tried your advice A, i.e. "change to an immutable on julia side, and 
change function signature to  'Ptr{TestType}'", and the code behaves the 
same as before, i.e. it compiles OK and runs OK but does not show the 
output of the println in the function.

I guess at the moment what puzzles me is not whether the data get passed 
correctly (because I am not trying to access the data yet), but why the one 
single statement in the Julia function is not executed.  That function 
appears to be taken correctly because if I change the function name in 
Julia then there is a core dump.  Any thoughts?

I have not yet tried your advice B as I am not too clear about it.


On Friday, September 9, 2016 at 8:52:30 PM UTC+8, Isaiah wrote:
>
> In c, 'struct TestType' is plain old data, not a Julia type (jl_value_t). 
> Either change to an immutable on julia side, and change function signature 
> to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with the correct type tag, 
> and 
> set the fields.
>
> On Friday, September 9, 2016, K leo > 
> wrote:
>
>> I tried the following, it compiles OK and runs OK, but it appears the 
>> julia function is not called (because there is no output from the println 
>> statement).  What is wrong?
>>
>> #include 
>>> #include 
>>> using namespace std;
>>> struct TestType {
>>> double a;
>>> double b;
>>> };
>>> int main(int argc, char *argv[])
>>> {
>>> TestType A, *ret;
>>> A.a=2.;
>>> A.b=3.;
>>> jl_init(NULL);
>>> jl_load("TestArg.jl");
>>> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
>>> jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
>>> jl_call1(func, (jl_value_t *)&A);
>>> jl_atexit_hook(0);
>>> return 0;
>>> }
>>> # TestArg.jl
>>> module TestArg
>>> type TestType
>>> a::Float64
>>> b::Float64
>>> end
>>> function TestFunc(data::TestType)
>>> println("in TestArg.TestFunc ")
>>> end
>>> end
>>
>>
>>

[julia-users] Re: Maps in Julia?

2016-09-09 Thread Michael Borregaard
You can open esri shapefiles with shapefiles.jl. There is a plotting function 
for shapefiles in plotrecipes.jl. You can layer shapefiles to create vector 
maps. I am happy to help out if you want to use this.

[julia-users] basic question on structuring modules

2016-09-09 Thread Neal Becker
Let's say I have a simple module which contains 1 function called "foo"

I might create foo.jl that contains

foo.jl
module foo

function foo ...
end

end

This doesn't work, it seems the module name collides with the function name.

foo.jl
module foo_mod

function foo ...
end

end

This might be OK, but provokes a warning (here foo -> coef_from_func)
julia> using coef_from_func
WARNING: requiring "coef_from_func" in module "Main" did not define a 
corresponding module.

So as a newb, what is the basic way to package up a function like this?



[julia-users] Re: ANN: Julia 0.5.0-rc4 now available

2016-09-09 Thread Uwe Fechner
Nice work! The regression of RC3 on the load time packages is fixed.

On Friday, September 9, 2016 at 9:39:38 AM UTC+2, Tony Kelman wrote:
>
> I have just tagged and uploaded release candidate 4 for Julia version 
> 0.5.0. Binaries are available from
>
>
> https://s3.amazonaws.com/julialang/bin/linux/x64/0.5/julia-0.5.0-rc4-linux-x86_64.tar.gz
>  
>
> https://s3.amazonaws.com/julialang/bin/linux/x86/0.5/julia-0.5.0-rc4-linux-i686.tar.gz
>
> https://s3.amazonaws.com/julialang/bin/linux/arm/0.5/julia-0.5.0-rc4-linux-arm.tar.gz
>  
>
> https://s3.amazonaws.com/julialang/bin/osx/x64/0.5/julia-0.5.0-rc4-osx10.7+.dmg
>  
>
> https://s3.amazonaws.com/julialang/bin/winnt/x64/0.5/julia-0.5.0-rc4-win64.exe
>  
>
> https://s3.amazonaws.com/julialang/bin/winnt/x86/0.5/julia-0.5.0-rc4-win32.exe
>  
> https://s3.amazonaws.com/julialang/bin/checksums/julia-0.5.0-rc4.sha256 
> https://s3.amazonaws.com/julialang/bin/checksums/julia-0.5.0-rc4.md5 
> For gpg signatures (with this key http://julialang.org/juliareleases.asc) 
> of the Linux tar.gz binaries, append .asc to the filename.
>
> Sorry there was a bit of a delay, one of the precompilation-related 
> backports just after RC3 had a bug that took some time to get fixed. Please 
> test this and report any issues. Unless anything major comes up over the 
> weekend or early next week, I plan doing at most a handful more very small 
> backports then tagging 0.5.0 final. Bugfixes will continue to be backported 
> to the release-0.5 branch for an 0.5.1 patch release roughly a month after 
> that.
>
> -Tony
>
>

[julia-users] PyPlot x(y)tick label fontsize

2016-09-09 Thread MLicer
Dear  all, 

i am using PyPlot for a simple sine plot and i am trying to increase the 
fontsize of x(y) *tick* labels (*not* x(y) *axis* labes). 

The following code... 

using PyPlot

# generate data:
x = 0:0.01:30
sin_noise(arr) = sin(arr) + rand(length(arr))


# Create a figure
fig = figure("pyplot_customtime",figsize=(18,12)) 
ax = axes()
plot(x,sin_noise(x),linestyle="-",marker="None",color="blue", label=L
"$y=\sin(x)+x_{random}$")
ax[:legend](loc="lower left",fontsize=30)
ax[:set_xlabel]("X Axis", fontsize=38)
ax[:set_ylabel](L"$y(x)$", fontsize=38)
axis("tight")
grid("on")


# Update the figure and save to file:
fig[:canvas][:draw]() 
PyPlot.tight_layout()
savefig("plot_signal_filter.pdf")
println("Done.")

..produces the plot below.  The fonts on x(y) axis are much too small and i 
want to have control over how big the x(y)tick labels 
([0,5,10,15,20,25,30]) are. Incredibly enough, I haven't been able to find 
a straightforward answer online. Can anyone please help?

Best regards,
M.




[julia-users] Re: basic question on structuring modules

2016-09-09 Thread K leo
The module name needs to be the same as the file, so in this case you need 
to change the function name.

On Friday, September 9, 2016 at 9:29:48 PM UTC+8, Neal Becker wrote:
>
> Let's say I have a simple module which contains 1 function called "foo" 
>
> I might create foo.jl that contains 
>
> foo.jl 
> module foo 
>
> function foo ... 
> end 
>
> end 
>
> This doesn't work, it seems the module name collides with the function 
> name. 
>
> foo.jl 
> module foo_mod 
>
> function foo ... 
> end 
>
> end 
>
> This might be OK, but provokes a warning (here foo -> coef_from_func) 
> julia> using coef_from_func 
> WARNING: requiring "coef_from_func" in module "Main" did not define a 
> corresponding module. 
>
> So as a newb, what is the basic way to package up a function like this? 
>
>

[julia-users] Re: basic question on structuring modules

2016-09-09 Thread Neal Becker
K leo wrote:

> The module name needs to be the same as the file, so in this case you need
> to change the function name.
> 
> On Friday, September 9, 2016 at 9:29:48 PM UTC+8, Neal Becker wrote:
>>
>> Let's say I have a simple module which contains 1 function called "foo"
>>
>> I might create foo.jl that contains
>>
>> foo.jl
>> module foo
>>
>> function foo ...
>> end
>>
>> end
>>
>> This doesn't work, it seems the module name collides with the function
>> name.
>>
>> foo.jl
>> module foo_mod
>>
>> function foo ...
>> end
>>
>> end
>>
>> This might be OK, but provokes a warning (here foo -> coef_from_func)
>> julia> using coef_from_func
>> WARNING: requiring "coef_from_func" in module "Main" did not define a
>> corresponding module.
>>
>> So as a newb, what is the basic way to package up a function like this?
>>
>>

If I want a file that just defines 1 function, should I be using a module?  
Is there a better alternative?



[julia-users] Re: basic question on structuring modules

2016-09-09 Thread Adrian Salceanu
By convention, module names should be PascalCase. 

Thus, you'll end up with 

# Foo.jl 
module Foo 

function foo()
end 

end

Julia being case sensitive, there will be no name clashes. 


vineri, 9 septembrie 2016, 15:29:48 UTC+2, Neal Becker a scris:
>
> Let's say I have a simple module which contains 1 function called "foo" 
>
> I might create foo.jl that contains 
>
> foo.jl 
> module foo 
>
> function foo ... 
> end 
>
> end 
>
> This doesn't work, it seems the module name collides with the function 
> name. 
>
> foo.jl 
> module foo_mod 
>
> function foo ... 
> end 
>
> end 
>
> This might be OK, but provokes a warning (here foo -> coef_from_func) 
> julia> using coef_from_func 
> WARNING: requiring "coef_from_func" in module "Main" did not define a 
> corresponding module. 
>
> So as a newb, what is the basic way to package up a function like this? 
>
>

[julia-users] Re: basic question on structuring modules

2016-09-09 Thread Adrian Salceanu
If you don't want to use a module you will have to explicitly include the 
file using 
include(path::AbstractString)

And the content of the file will be evaluated in the current context 
(providing mixin behavior). That should be OK for very short scripts / 
apps. 

For anything bigger you should use modules as they provide a namespace like 
structure and help you avoid the error prone task of having to manage file 
paths and includes manually. 

vineri, 9 septembrie 2016, 15:48:34 UTC+2, Neal Becker a scris:
>
> K leo wrote: 
>
> > The module name needs to be the same as the file, so in this case you 
> need 
> > to change the function name. 
> > 
> > On Friday, September 9, 2016 at 9:29:48 PM UTC+8, Neal Becker wrote: 
> >> 
> >> Let's say I have a simple module which contains 1 function called "foo" 
> >> 
> >> I might create foo.jl that contains 
> >> 
> >> foo.jl 
> >> module foo 
> >> 
> >> function foo ... 
> >> end 
> >> 
> >> end 
> >> 
> >> This doesn't work, it seems the module name collides with the function 
> >> name. 
> >> 
> >> foo.jl 
> >> module foo_mod 
> >> 
> >> function foo ... 
> >> end 
> >> 
> >> end 
> >> 
> >> This might be OK, but provokes a warning (here foo -> coef_from_func) 
> >> julia> using coef_from_func 
> >> WARNING: requiring "coef_from_func" in module "Main" did not define a 
> >> corresponding module. 
> >> 
> >> So as a newb, what is the basic way to package up a function like this? 
> >> 
> >> 
>
> If I want a file that just defines 1 function, should I be using a module? 
>   
> Is there a better alternative? 
>
>

Re: [julia-users] Re: basic question on structuring modules

2016-09-09 Thread Tamas Papp
Depends on what you want. If it is part of something larger but want to
keep it in a separate file, you can just include it --- this is a
standard solution for writing more complex modules.

On Fri, Sep 09 2016, Neal Becker wrote:

> K leo wrote:
>
>> The module name needs to be the same as the file, so in this case you need
>> to change the function name.
>> 
>> On Friday, September 9, 2016 at 9:29:48 PM UTC+8, Neal Becker wrote:
>>>
>>> Let's say I have a simple module which contains 1 function called "foo"
>>>
>>> I might create foo.jl that contains
>>>
>>> foo.jl
>>> module foo
>>>
>>> function foo ...
>>> end
>>>
>>> end
>>>
>>> This doesn't work, it seems the module name collides with the function
>>> name.
>>>
>>> foo.jl
>>> module foo_mod
>>>
>>> function foo ...
>>> end
>>>
>>> end
>>>
>>> This might be OK, but provokes a warning (here foo -> coef_from_func)
>>> julia> using coef_from_func
>>> WARNING: requiring "coef_from_func" in module "Main" did not define a
>>> corresponding module.
>>>
>>> So as a newb, what is the basic way to package up a function like this?
>>>
>>>
>
> If I want a file that just defines 1 function, should I be using a module?  
> Is there a better alternative?


[julia-users] Precompilation (using usrimg.jl) of pkg using binary lib

2016-09-09 Thread Joaquim Masset Lacombe Dias Garcia
Hi all!

I have a package which depends a external binary library(I will just write 
dll from now on), I want to figure out a way to call the dll in a way that 
if some user decides to precompile a system image with this library it can 
still work.

My package is Xpress.jl (I know it wraps commercial lib), my initial link 
to the binary was very simple, actually a copied from Gurobi.jl.
It uses the a build step to locate an environment variable, than it creates 
a script that defines a const global variable (for the pkg) that indicates 
the dll directory.

This method would have a few problems:
1 - will not support complete precompilation since it relies on creating an 
extra .jl file
2 - the user must have the environment variable, so that its bad for 
shipping the complete precompiled julia with the dll inside

I was able to hack the library to do that (since I wrote most of it), I 
removed the build step, I loaded the pkg without loading the dll, just 
loaded the dll afterwards, using 'dlopen'. (The shipped program sent the 
path of the dll via args to the a julia code, thats how I used dlopen)

As it was not enough the pkg also currently has a __init__() function, that 
call a environment initializer of the dll. (For the precompiled version I 
removed it and loaded the environment just after dlopen)

Clearly I hacked the package a lot, so I would like to know if there is any 
other way to do something similar.

In a nutshell, I would like a method that
1- enables the user to precompile the pkg into sysimg
2- enables the pkg to reach to the dll even in sysimg precompilation 
state,for me there is no problem in having to put the dll inside some julia 
installation folder

Thanks in advance!


[julia-users] Re: [julia-dev] Convert a dense matrix A into a sparse matrix with sparsevec(A)

2016-09-09 Thread Cameron McBride
This thread is old, but I was poking through some unread bits and found it.
Beyond that, it’s likely a better question for julia-users list (which I’m
including here).

Anyhow, the answer is that sparsevec converts a dense matrix into a sparse
matrix format where zero values are not explicitly stored. If the vector
(or matrix) really is dense, this does not save space.

julia> A = [23.1, 42.67, 8.246, 111.33]
4-element Array{Float64,1}:
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(A)
Sparse vector of length 4 with 4 Float64 nonzero entries:
  [1]  =  23.1
  [2]  =  42.67
  [3]  =  8.246
  [4]  =  111.33


julia> B = [0,0,A...]
6-element Array{Float64,1}:
   0.0
   0.0
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(B)
Sparse vector of length 6 with 4 Float64 nonzero entries:
  [3]  =  23.1
  [4]  =  42.67
  [5]  =  8.246
  [6]  =  111.33

Cameron


On Sat, Aug 20, 2016 at 7:15 AM, Parkway  wrote:

> The doc for the function sparsevec(A) says:
> sparsevec(A)
> Convert a dense vector A into a sparse matrix of size m x 1. In julia,
> sparse vectors are really just sparse matrices with one column.
>
> What does this actually mean? For example, what does the dense vector A =
> [23.1, 42.67, 8.246, 111.33] get converted to?
>
>


[julia-users] PyPlot x(y)tick label fontsize

2016-09-09 Thread Ralph Smith
 ax[:tick_params]("both",labelsize=24)

See http://matplotlib.org/api/pyplot_api.html
for related functions and arguments.

[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Christoph Ortner
Because I want to reinterpret it as a Vector of fixed size arrays. Can this be 
done with a PyArray directly? (I can't try it out right now)

[julia-users] idiom for standard basis vector (eg [0,1,0])

2016-09-09 Thread Christoph Ortner
I predict that - right now - somebody is writing an answer explaining why this 
is terrible and you need an abstract array type with lazy evaluation. ;)

[julia-users] Parallel computing and type-stability

2016-09-09 Thread Sleort
I've been playing around with the parallel functionality of Julia (0.4.6) 
in order to get a better understanding of it. Just for the sake of testing, 
I made a "silly" nworkers() implementation like
julia> function silly_nworkers()
  @parallel (+) for p in workers()
1
  end
end
which, as expected, return the number of workers - just like nworkers(). 
Now, running julia -p 2 (or any other number of processes)
julia> @code_warntype silly_nworkers()
I get the result
Variables:


Body:
  begin  # none, line 2:
  return (AST(:($(Expr(:lambda, Any[], Any[Any[Any[symbol("#8#therange"
),Array{Int64,1},19]],Any[],Any[Function],Any[]], :(begin  # expr.jl, line 
113:
NewvarNode(symbol("#8#therange")) # multi.jl, line 1587:
#8#therange = (Main.workers)()::Array{Int64,1} # multi.jl, line 
1587: # multi.jl, line 1542:
GenSym(0) = AST(:($(Expr(:lambda, 
Any[:(#9#lo::(top(getfield))(Base,:Int)::Any::Any),:(#10#hi::(top(getfield))(Base,:Int)::Any::Any)],
 
Any[Any[Any[symbol("#9#lo"),Any,18],Any[symbol("#10#hi"),Any,18],Any[:p,Any,2],Any[symbol("#11#ac"),Any,2],Any[symbol("#s7"),Any,2]],Any[Any[symbol("#8#therange"),Array{Int64,1},19]],4,Any[]],
 
:(begin 
#9#lo = 
(top(typeassert))(#9#lo,(top(getfield))(Base,:Int)::Any)::Any
#10#hi = 
(top(typeassert))(#10#hi,(top(getfield))(Base,:Int)::Any)::Any # multi.jl, 
line 1543:
p = (Main.getindex)(#8#therange,#9#lo)::Any # multi.jl, line 1544: 
# none, line 3:
#11#ac = 1 # multi.jl, line 1545:
unless ((top(getfield))(Base,:(!=))::Any)(#9#lo,#10#hi)::Any goto 0 
# multi.jl, line 1546:
GenSym(1) = (Main.getindex)(
#8#therange,(Main.colon)(((top(getfield))(Base,:+)::Any)(#9#lo,1)::Any,#10#hi)::Any)::Any
#s7 = (top(start))(GenSym(1))::Any
unless (top(!))((top(done))(GenSym(1),#s7)::Any)::Any goto 1
2: 
GenSym(2) = (top(next))(GenSym(1),#s7)::Any
p = (top(getfield))(GenSym(2),1)::Any
#s7 = (top(getfield))(GenSym(2),2)::Any # multi.jl, line 1547: # 
none, line 3:
GenSym(3) = 1
#11#ac = #11#ac + GenSym(3)::Any
3: 
unless (top(!))((top(!))((top(done))(GenSym(1),#s7)::Any)::Any)::Any 
goto 2
1: 
0:  # multi.jl, line 1550:
return #11#ac
end::Any)
return ((top(getfield))(Base,:preduce)::F)(Main.+,GenSym(0),(Base.
arraylen)(#8#therange::Array{Int64,1})::Int64)::Any
end::Any))()::Any
  end::Any
where there is a large number of undetermined types/Anys in the code. 
(Except for that, I must admit that I don't understand all the details of 
the code/output itself). The conventional Julia optimization wisdom tells 
me that I should have specific types in order to get fast code. What's 
going on here, and is there a way to "fix"/improve this situation? The 
silly_nworkers() itself seems to be rather straightforward to me, so I'm 
not sure why the compiler cannot make more type-specific code...


Re: [julia-users] Parallel computing and type-stability

2016-09-09 Thread Yichao Yu
On Fri, Sep 9, 2016 at 12:07 PM, Sleort  wrote:

> I've been playing around with the parallel functionality of Julia (0.4.6)
> in order to get a better understanding of it. Just for the sake of testing,
> I made a "silly" nworkers() implementation like
> julia> function silly_nworkers()
>   @parallel (+) for p in workers()
> 1
>   end
> end
> which, as expected, return the number of workers - just like nworkers().
> Now, running julia -p 2 (or any other number of processes)
> julia> @code_warntype silly_nworkers()
> I get the result
> Variables:
>
>
> Body:
>   begin  # none, line 2:
>   return (AST(:($(Expr(:lambda, Any[], Any[Any[Any[symbol("#8#
> therange"),Array{Int64,1},19]],Any[],Any[Function],Any[]], :(begin  #
> expr.jl, line 113:
> NewvarNode(symbol("#8#therange")) # multi.jl, line 1587:
> #8#therange = (Main.workers)()::Array{Int64,1} # multi.jl, line
> 1587: # multi.jl, line 1542:
> GenSym(0) = AST(:($(Expr(:lambda, Any[:(#9#lo::(top(getfield))(
> Base,:Int)::Any::Any),:(#10#hi::(top(getfield))(Base,:Int)::Any::Any)],
> Any[Any[Any[symbol("#9#lo"),Any,18],Any[symbol("#10#hi"),
> Any,18],Any[:p,Any,2],Any[symbol("#11#ac"),Any,2],Any[
> symbol("#s7"),Any,2]],Any[Any[symbol("#8#therange"),Array{Int64,1},19]],4,Any[]],
> :(begin
> #9#lo = (top(typeassert))(#9#lo,(top(getfield))(Base,:Int)::Any)::
> Any
> #10#hi = (top(typeassert))(#10#hi,(top(
> getfield))(Base,:Int)::Any)::Any # multi.jl, line 1543:
> p = (Main.getindex)(#8#therange,#9#lo)::Any # multi.jl, line
> 1544: # none, line 3:
> #11#ac = 1 # multi.jl, line 1545:
> unless ((top(getfield))(Base,:(!=))::Any)(#9#lo,#10#hi)::Any goto
> 0 # multi.jl, line 1546:
> GenSym(1) = (Main.getindex)(#8#therange,(
> Main.colon)(((top(getfield))(Base,:+)::Any)(#9#lo,1)::Any,#
> 10#hi)::Any)::Any
> #s7 = (top(start))(GenSym(1))::Any
> unless (top(!))((top(done))(GenSym(1),#s7)::Any)::Any goto 1
> 2:
> GenSym(2) = (top(next))(GenSym(1),#s7)::Any
> p = (top(getfield))(GenSym(2),1)::Any
> #s7 = (top(getfield))(GenSym(2),2)::Any # multi.jl, line 1547: #
> none, line 3:
> GenSym(3) = 1
> #11#ac = #11#ac + GenSym(3)::Any
> 3:
> unless (top(!))((top(!))((top(done))(GenSym(1),#s7)::Any)::Any)::Any
> goto 2
> 1:
> 0:  # multi.jl, line 1550:
> return #11#ac
> end::Any)
> return ((top(getfield))(Base,:preduce)::F)(Main.+,GenSym(0),(Base.
> arraylen)(#8#therange::Array{Int64,1})::Int64)::Any
> end::Any))()::Any
>   end::Any
> where there is a large number of undetermined types/Anys in the code.
> (Except for that, I must admit that I don't understand all the details of
> the code/output itself). The conventional Julia optimization wisdom tells
> me that I should have specific types in order to get fast code. What's
> going on here, and is there a way to "fix"/improve this situation? The
> silly_nworkers() itself seems to be rather straightforward to me, so I'm
> not sure why the compiler cannot make more type-specific code...
>

The inter process communication has a lot of overhead which means,

1. You should put more work in the loop body, otherwise it's not going to
speed things up.
2. The type instability of the multi processing infrastructure doesn't
really matter compare to the communication overhead.


[julia-users] Re: Why is BLAS.dot slower than BLAS.axpy!?

2016-09-09 Thread Andreas Noack
Try to time it again with threading disabled. Sometimes the 
threading heuristics can cause unintuitive performance.

On Friday, September 9, 2016 at 6:39:13 AM UTC-4, Sheehan Olver wrote:
>
>
> I have the following code that is part of a Householder routine, where 
> j::Int64, 
> N::Int64, R.cols::Vector{Int64}, wp::Ptr{Float64}, M::Int64, 
> v::Ptr{Float64}:
>
>   …
> for j=k:N
> v=r+(R.cols[j]+k-2)*sz
> dt=BLAS.dot(M,wp,1,v,1)
> BLAS.axpy!(M,-2*dt,wp,1,v,1)
> end
> …
>
>
>
> For some reason, the BLAS.dot call takes 3x as long as the BLAS.axpy! 
> call.  Is this expected, or is there something wrong?
>
>
>

[julia-users] Re: Parallel computation of Array of user-defined types

2016-09-09 Thread Germán Aquino
I usually use a combination of @spawn and fetch. @spawn fires a lightweigth 
task that can return a value of any type, which can be collected by the 
main thread with fetch:

refs = Vector{RemoteRef}(N)
for i in 1:N
refs[i] = @spawn begin doSomethingAndReturnValueOfTypeT end
end

for i in 1:N
v[i] = fetch(refs[i])
end

I'm not aware if there is a better way, as far as I know SharedArrays don't 
work with user-defined types.
You need to have worker threads for this to be of any use, by using 
addprocs() or by starting julia with the -p flag, for instance $ julia -p 4.

I hope that helps,
Germán.



On Friday, September 9, 2016 at 7:51:59 AM UTC-3, ami...@gmail.com wrote:
>
> Hello,
>
> What would be the best option to parallelize this code:
>
> type T a end
> f(i) = T(i)
> v = map(f, collect(1:1:100))
>
> This example could sound stupid but the point is that I have a function 
> ```f``` that returns a rather complicated user-defined type ```T```, and I 
> need to store a lot of these types in an ```Array```.
> I've read a bit about the parallel paradigm of Julia and I honestly 
> wouldn't know how to do such a thing.
>
> Any hint?
>
> Many thanks!
>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Isaiah Norton
(Disregard my suggestion about `Ptr{TestType}`, `jl_call1` only takes boxed
arguments so that won't work)

The problem is that the passed argument type does not match any available
method (because it isn't actually passed a julia type at all) so `jl_call1`
silently gives up. The `jl_call*` methods are in TRY/CATCH blocks to
prevent spilling errors across the API, and they do not print error
messages.

The following example works, it's not really efficient but it does
demonstrate type construction from C:

#include 
#include 
using namespace std;

struct TestType {
double a;
double b;
};
int main(int argc, char *argv[])
{
TestType A, *ret;
A.a=2.;
A.b=3.;
jl_init("/Users/inorton/git/jl71/usr/lib/");
jl_load("TestArg.jl");
jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");

   // construct a TestType instance

jl_value_t* jl_A =
jl_new_struct((jl_datatype_t*)jl_get_function((jl_module_t*)mod,
"TestType"),
 jl_box_float64(A.a),
jl_box_float64(A.b));

jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
jl_call1(func, jl_A);

jl_atexit_hook(0);
return 0;
}


Using the embedding API requires a substantial depth of understanding of ,
including stack vs heap and argument passing, as well as dynamic language
concepts such as boxing, and rooting. The embedding section of the manual
is designed to provide an overview, but ultimately you are going to have to
read and grok the Julia source to get every little detail.

On Fri, Sep 9, 2016 at 9:23 AM, K leo  wrote:

> Isaiah,
>
> Thanks for the reply.
>
> I tried your advice A, i.e. "change to an immutable on julia side, and
> change function signature to  'Ptr{TestType}'", and the code behaves the
> same as before, i.e. it compiles OK and runs OK but does not show the
> output of the println in the function.
>
> I guess at the moment what puzzles me is not whether the data get passed
> correctly (because I am not trying to access the data yet), but why the one
> single statement in the Julia function is not executed.  That function
> appears to be taken correctly because if I change the function name in
> Julia then there is a core dump.  Any thoughts?
>
> I have not yet tried your advice B as I am not too clear about it.
>
>
> On Friday, September 9, 2016 at 8:52:30 PM UTC+8, Isaiah wrote:
>>
>> In c, 'struct TestType' is plain old data, not a Julia type (jl_value_t).
>> Either change to an immutable on julia side, and change function signature
>> to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with the correct type tag, 
>> and
>> set the fields.
>>
>> On Friday, September 9, 2016, K leo  wrote:
>>
>>> I tried the following, it compiles OK and runs OK, but it appears the
>>> julia function is not called (because there is no output from the println
>>> statement).  What is wrong?
>>>
>>> #include 
 #include 
 using namespace std;
 struct TestType {
 double a;
 double b;
 };
 int main(int argc, char *argv[])
 {
 TestType A, *ret;
 A.a=2.;
 A.b=3.;
 jl_init(NULL);
 jl_load("TestArg.jl");
 jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
 jl_function_t * func = jl_get_function((jl_module_t*)
 mod,"TestFunc");
 jl_call1(func, (jl_value_t *)&A);
 jl_atexit_hook(0);
 return 0;
 }
 # TestArg.jl
 module TestArg
 type TestType
 a::Float64
 b::Float64
 end
 function TestFunc(data::TestType)
 println("in TestArg.TestFunc ")
 end
 end
>>>
>>>
>>>


[julia-users] Re: idiom for standard basis vector (eg [0,1,0])

2016-09-09 Thread Steven G. Johnson
On Friday, September 9, 2016 at 11:56:58 AM UTC-4, Christoph Ortner wrote:
>
> I predict that - right now - somebody is writing an answer explaining why 
> this is terrible and you need an abstract array type with lazy evaluation. 
> ;)


Well, we already have the built-in constant I.   I[i,j] is the j-th element 
of the i-th unit vector, computed lazily, i.e. the Kronecker delta function.

But yes, if you need unit vectors a lot you may be doing something wrong. 


[julia-users] Re: Assigning a field in Python via reference

2016-09-09 Thread Steven G. Johnson


On Friday, September 9, 2016 at 11:47:45 AM UTC-4, Christoph Ortner wrote:
>
> Because I want to reinterpret it as a Vector of fixed size arrays. Can 
> this be done with a PyArray directly? (I can't try it out right now)


No. 


[julia-users] "WARNING: replacing module" when invoking function with @everywhere - but module not available otherwise

2016-09-09 Thread Adrian Salceanu
Hi, 

I'm fumbling around with a little script with the end goal of running 
HttpServer handlers on multiple ports, in parallel, with each handler on a 
separate worker. 

The code looks like this: 

# parallel_http.jl
using HttpServer


function serve(port::Int)
  http = HttpHandler() do req::Request, res::Response
  Dates.now() |> string
  end


  server = Server(http)
  run(server, port)
end


function run_in_parallel()
  servers = Vector{RemoteRef}()
  for w in workers()
println("About to start server on $(8000 + w)")
push!(servers, @spawn serve(8000 + w))
  end


  servers
end


And in the REPL, running with julia -p 2: 

julia> @everywhere include("parallel_http.jl")
WARNING: replacing module HttpServer
WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src
/HttpServer.jl:178.
WARNING: replacing module HttpServer
WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src
/HttpServer.jl:178.


julia> servers = run_in_parallel()
About to start server on 8002
About to start server on 8003
2-element Array{RemoteRef{T<:AbstractChannel},1}:
  From worker 3: Listening on 0.0.0.0:8003...
 From worker 2: Listening on 0.0.0.0:8002...
RemoteRef{Channel{Any}}(2,1,17)
 RemoteRef{Channel{Any}}(3,1,18)


The WARNING seems to imply that I'm doing something wrong - but if I don't 
run "using" on each worker, to avoid the warning, the module is not 
available to the worker. Am i missing something? Is there a better way to 
do this? Thanks! 



[julia-users] Re: idiom for standard basis vector (eg [0,1,0])

2016-09-09 Thread Matt Bauman
You could implement:

Base.getindex(U::UniformScaling, I::AbstractArray, j::Int) = [U[i,j] for i 
in I]
Base.getindex(U::UniformScaling, i::Int, J::AbstractArray) = [U[i,j] for j 
in J]
Base.getindex(U::UniformScaling, I::AbstractArray, J::AbstractArray) = [U[i,
j] for i in I, j in J]

Then:

julia> I[1:4, 2]
4-element Array{Int64,1}:
 0
 1
 0
 0


On Friday, September 9, 2016 at 11:58:44 AM UTC-5, Steven G. Johnson wrote:
>
> On Friday, September 9, 2016 at 11:56:58 AM UTC-4, Christoph Ortner wrote:
>>
>> I predict that - right now - somebody is writing an answer explaining why 
>> this is terrible and you need an abstract array type with lazy evaluation. 
>> ;)
>
>
> Well, we already have the built-in constant I.   I[i,j] is the j-th 
> element of the i-th unit vector, computed lazily, i.e. the Kronecker delta 
> function.
>
> But yes, if you need unit vectors a lot you may be doing something wrong. 
>


Re: [julia-users] Re: idiom for standard basis vector (eg [0,1,0])

2016-09-09 Thread Erik Schnetter
Here is something short:
```Julia
bv(i,n) = [j==i for j in 1:n]
```
This returns a vector of `Bool`. In Julia, `Bool` is a numeric type that is
automatically promoted to `Int` / `Float` / etc. where necessary. If you
want, you can add an explicit type (e.g. `Float64`) in front of the array
comprehension.

-erik


On Fri, Sep 9, 2016 at 1:16 PM, Matt Bauman  wrote:

> You could implement:
>
> Base.getindex(U::UniformScaling, I::AbstractArray, j::Int) = [U[i,j] for
> i in I]
> Base.getindex(U::UniformScaling, i::Int, J::AbstractArray) = [U[i,j] for
> j in J]
> Base.getindex(U::UniformScaling, I::AbstractArray, J::AbstractArray) = [U[
> i,j] for i in I, j in J]
>
> Then:
>
> julia> I[1:4, 2]
> 4-element Array{Int64,1}:
>  0
>  1
>  0
>  0
>
>
> On Friday, September 9, 2016 at 11:58:44 AM UTC-5, Steven G. Johnson wrote:
>>
>> On Friday, September 9, 2016 at 11:56:58 AM UTC-4, Christoph Ortner wrote:
>>>
>>> I predict that - right now - somebody is writing an answer explaining
>>> why this is terrible and you need an abstract array type with lazy
>>> evaluation. ;)
>>
>>
>> Well, we already have the built-in constant I.   I[i,j] is the j-th
>> element of the i-th unit vector, computed lazily, i.e. the Kronecker delta
>> function.
>>
>> But yes, if you need unit vectors a lot you may be doing something wrong.
>>
>


-- 
Erik Schnetter 
http://www.perimeterinstitute.ca/personal/eschnetter/


[julia-users] Re: "WARNING: replacing module" when invoking function with @everywhere - but module not available otherwise

2016-09-09 Thread Patrick Belliveau
Hi,
 Running your code effectively executes

@everywhere using HttpServer

This is known to generate those method redefinition warnings. The behaviour 
of using in a parallel environment is a known unresolved bug. It seems like 
the best syntax to use right now is

import HttpServer #Executed only on master process
@everywhere using HttpServer

For a more detailed discussion and links to the relevant issues on github 
see this thread 

.

On Friday, September 9, 2016 at 10:04:53 AM UTC-7, Adrian Salceanu wrote:
>
> Hi, 
>
> I'm fumbling around with a little script with the end goal of running 
> HttpServer handlers on multiple ports, in parallel, with each handler on a 
> separate worker. 
>
> The code looks like this: 
>
> # parallel_http.jl
> using HttpServer
>
>
> function serve(port::Int)
>   http = HttpHandler() do req::Request, res::Response
>   Dates.now() |> string
>   end
>
>
>   server = Server(http)
>   run(server, port)
> end
>
>
> function run_in_parallel()
>   servers = Vector{RemoteRef}()
>   for w in workers()
> println("About to start server on $(8000 + w)")
> push!(servers, @spawn serve(8000 + w))
>   end
>
>
>   servers
> end
>
>
> And in the REPL, running with julia -p 2: 
>
> julia> @everywhere include("parallel_http.jl")
> WARNING: replacing module HttpServer
> WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
> HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
> overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/
> src/HttpServer.jl:178.
> WARNING: replacing module HttpServer
> WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
> HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
> overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/
> src/HttpServer.jl:178.
>
>
> julia> servers = run_in_parallel()
> About to start server on 8002
> About to start server on 8003
> 2-element Array{RemoteRef{T<:AbstractChannel},1}:
>   From worker 3: Listening on 0.0.0.0:8003...
>  From worker 2: Listening on 0.0.0.0:8002...
> RemoteRef{Channel{Any}}(2,1,17)
>  RemoteRef{Channel{Any}}(3,1,18)
>
>
> The WARNING seems to imply that I'm doing something wrong - but if I don't 
> run "using" on each worker, to avoid the warning, the module is not 
> available to the worker. Am i missing something? Is there a better way to 
> do this? Thanks! 
>
>

[julia-users] Re: Maps in Julia?

2016-09-09 Thread Kaj Wiik
Wow, that's interesting! Thanks for pointing that out!


On Friday, September 9, 2016 at 4:28:12 PM UTC+3, Michael Borregaard wrote:
>
> You can open esri shapefiles with shapefiles.jl. There is a plotting 
> function for shapefiles in plotrecipes.jl. You can layer shapefiles to 
> create vector maps. I am happy to help out if you want to use this.



Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Bart Janssens
On Fri, Sep 9, 2016 at 6:44 PM Isaiah Norton 
wrote:

>// construct a TestType instance
>
> jl_value_t* jl_A =
> jl_new_struct((jl_datatype_t*)jl_get_function((jl_module_t*)mod,
> "TestType"),
>  jl_box_float64(A.a),
> jl_box_float64(A.b));
>
>
The arguments to jl_new_struct need to be rooted, so you should do
something like:
jl_value_t* a = NULL;
jl_value_t* b = NULL;
JL_GC_PUSH2(a,b);
a = jl_box_float64(A.a);
b = jl_box_float64(A.b);
// use a and b in the new struct call
JL_GC_POP();

What is the objective here? If this is still to be used from C++, there may
be easier ways using Cxx.jl or CxxWrap.jl.

Cheers,

Bart


[julia-users] Re: "WARNING: replacing module" when invoking function with @everywhere - but module not available otherwise

2016-09-09 Thread Adrian Salceanu
Thanks for the info and for the link, it's a good read. I wonder if anybody 
else has run into the issues Tim Holy mentions, with @everywhere using X. 

Cheers! 


vineri, 9 septembrie 2016, 20:23:22 UTC+2, Patrick Belliveau a scris:
>
> Hi,
>  Running your code effectively executes
>
> @everywhere using HttpServer
>
> This is known to generate those method redefinition warnings. The 
> behaviour of using in a parallel environment is a known unresolved bug. It 
> seems like the best syntax to use right now is
>
> import HttpServer #Executed only on master process
> @everywhere using HttpServer
>
> For a more detailed discussion and links to the relevant issues on github 
> see this thread 
> 
> .
>
> On Friday, September 9, 2016 at 10:04:53 AM UTC-7, Adrian Salceanu wrote:
>>
>> Hi, 
>>
>> I'm fumbling around with a little script with the end goal of running 
>> HttpServer handlers on multiple ports, in parallel, with each handler on a 
>> separate worker. 
>>
>> The code looks like this: 
>>
>> # parallel_http.jl
>> using HttpServer
>>
>>
>> function serve(port::Int)
>>   http = HttpHandler() do req::Request, res::Response
>>   Dates.now() |> string
>>   end
>>
>>
>>   server = Server(http)
>>   run(server, port)
>> end
>>
>>
>> function run_in_parallel()
>>   servers = Vector{RemoteRef}()
>>   for w in workers()
>> println("About to start server on $(8000 + w)")
>> push!(servers, @spawn serve(8000 + w))
>>   end
>>
>>
>>   servers
>> end
>>
>>
>> And in the REPL, running with julia -p 2: 
>>
>> julia> @everywhere include("parallel_http.jl")
>> WARNING: replacing module HttpServer
>> WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
>> HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
>> overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/
>> src/HttpServer.jl:178.
>> WARNING: replacing module HttpServer
>> WARNING: Method definition write(Base.IO, HttpCommon.Response) in module 
>> HttpServer at /Users/adrian/.julia/v0.4/HttpServer/src/HttpServer.jl:178 
>> overwritten in module HttpServer at /Users/adrian/.julia/v0.4/HttpServer/
>> src/HttpServer.jl:178.
>>
>>
>> julia> servers = run_in_parallel()
>> About to start server on 8002
>> About to start server on 8003
>> 2-element Array{RemoteRef{T<:AbstractChannel},1}:
>>   From worker 3: Listening on 0.0.0.0:8003...
>>  From worker 2: Listening on 0.0.0.0:8002...
>> RemoteRef{Channel{Any}}(2,1,17)
>>  RemoteRef{Channel{Any}}(3,1,18)
>>
>>
>> The WARNING seems to imply that I'm doing something wrong - but if I 
>> don't run "using" on each worker, to avoid the warning, the module is not 
>> available to the worker. Am i missing something? Is there a better way to 
>> do this? Thanks! 
>>
>>

[julia-users] Re: Parallel computation of Array of user-defined types

2016-09-09 Thread amiksvi
Thanks German, indeed I have seen that SharedArrays couldn't be used for 
user-defined types...
I tried to compare the approach you suggested with the serial one, and 
results are so awfully slow with the parallel version that I might have 
done something wrong...
Here it is:

@everywhere type T a end
N = Int(1e5)
v = Array(T, N)
refs = Vector{RemoteRef}(N)
for i = 1:N
refs[i] = @spawn begin T(i) end
end
for i = 1:N
v[i] = fetch(refs[i])
end

called with:

time julia -p 4 parallel.jl

takes 0m31.706s, whereas

type T a end
N = Int(1e5)
v = Array(T, N)
for i = 1:N
v[i] = T(i)
end

called with:

time julia serial.jl

takes only 0m0.293s...


Re: [julia-users] Re: Why is BLAS.dot slower than BLAS.axpy!?

2016-09-09 Thread Sheehan Olver
I did blas_set_num_threads(1) with the same profile numbers.  This is using 
Apple’s BLAS.  

Maybe I’ll try 0.5 and OpenBLAS for comparison.

> On 10 Sep 2016, at 2:34 AM, Andreas Noack  
> wrote:
> 
> Try to time it again with threading disabled. Sometimes the threading 
> heuristics can cause unintuitive performance.
> 
> On Friday, September 9, 2016 at 6:39:13 AM UTC-4, Sheehan Olver wrote:
> 
> I have the following code that is part of a Householder routine, where 
> j::Int64, N::Int64, R.cols::Vector{Int64}, wp::Ptr{Float64}, M::Int64, 
> v::Ptr{Float64}:
> 
>   …
> for j=k:N
> v=r+(R.cols[j]+k-2)*sz
> dt=BLAS.dot(M,wp,1,v,1)
> BLAS.axpy!(M,-2*dt,wp,1,v,1)
> end
> …
> 
> 
> 
> For some reason, the BLAS.dot call takes 3x as long as the BLAS.axpy! call.  
> Is this expected, or is there something wrong?
> 
> 



[julia-users] ProfileView not compatible with julia-0.5?

2016-09-09 Thread Neal Becker
 using ProfileView
INFO: Precompiling module ProfileView.
WARNING: Module Compat with uuid 314389968181888 is missing from the cache.
This may mean module Compat does not support precompilation but is imported 
by a module that does.
ERROR: LoadError: Declaring __precompile__(false) is not allowed in files 
that are being precompiled.
 in macro expansion; at ./none:2 [inlined]
 in anonymous at ./:?
while loading /home/nbecker/.julia/v0.5/ProfileView/src/ProfileView.jl, in 
expression starting on line 5
ERROR: Failed to precompile ProfileView to 
/home/nbecker/.julia/lib/v0.5/ProfileView.ji.
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
 in macro expansion at ./REPL.jl:95 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68



[julia-users] Re: ProfileView not compatible with julia-0.5?

2016-09-09 Thread Chris Rackauckas
Did you checkout master?

On Friday, September 9, 2016 at 2:55:21 PM UTC-7, Neal Becker wrote:
>
> using ProfileView 
> INFO: Precompiling module ProfileView. 
> WARNING: Module Compat with uuid 314389968181888 is missing from the 
> cache. 
> This may mean module Compat does not support precompilation but is 
> imported 
> by a module that does. 
> ERROR: LoadError: Declaring __precompile__(false) is not allowed in files 
> that are being precompiled. 
>  in macro expansion; at ./none:2 [inlined] 
>  in anonymous at ./:? 
> while loading /home/nbecker/.julia/v0.5/ProfileView/src/ProfileView.jl, in 
> expression starting on line 5 
> ERROR: Failed to precompile ProfileView to 
> /home/nbecker/.julia/lib/v0.5/ProfileView.ji. 
>  in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64 
>  in macro expansion at ./REPL.jl:95 [inlined] 
>  in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68 
>
>

[julia-users] Re: Running octave scrips from julia

2016-09-09 Thread Chris Rackauckas
I guess not >1 year, but getting close to a year.

On Friday, September 9, 2016 at 4:32:56 AM UTC-7, Steven G. Johnson wrote:
>
>
>
> On Friday, February 6, 2015 at 2:03:23 PM UTC-5, astromono wrote:
>>
>>   in pyinitialize at /home/rober/.julia/v0.4/PyCall/src/pyinit.jl:245
>>
>
>  I think you must have pinned PyCall at some ancient version, because the 
> current pyinit.jl file only has 115 lines.
>


[julia-users] Re: Running octave scrips from julia

2016-09-09 Thread Chris Rackauckas
You accidentally revived a >1 year old thread.

On Friday, September 9, 2016 at 4:32:56 AM UTC-7, Steven G. Johnson wrote:
>
>
>
> On Friday, February 6, 2015 at 2:03:23 PM UTC-5, astromono wrote:
>>
>>   in pyinitialize at /home/rober/.julia/v0.4/PyCall/src/pyinit.jl:245
>>
>
>  I think you must have pinned PyCall at some ancient version, because the 
> current pyinit.jl file only has 115 lines.
>


[julia-users] Re: Parallel computation of Array of user-defined types

2016-09-09 Thread Germán Aquino
Hello, 
I think that if N is too large and the computation load of @spawn is too 
small then the overhead of creating and dispatching the tasks outweighs the 
gain of parallelization.
You can try @parallel, which distributes loop iterations across different 
workers.

f(i) = T(i)
@parallel for i in 1:N
 v[i] = T(i)
end

Other options include to use pmap instead of map, or to use @async, but I 
didn't see any improvement in this case.

Regards,
Germán.


[julia-users] Re: Maps in Julia?

2016-09-09 Thread Andy Ferris

>
> ... and transform geographic coordinates (GNSS logger lat, lon) to UTM 
> (cartesian, unit = metre) by calling libgeographic.
>

Geodesy.jl now has a native port of libgeographics UTM conversion code - 
you might possibly find that convenient.

Andy


[julia-users] Re: ProfileView not compatible with julia-0.5?

2016-09-09 Thread Neal Becker
Chris Rackauckas wrote:

> Did you checkout master?
> 

No I just did Pkg.add("ProfileView").  I don't actually know how to do 
otherwise - is that a Pkg option?

> On Friday, September 9, 2016 at 2:55:21 PM UTC-7, Neal Becker wrote:
>>
>> using ProfileView
>> INFO: Precompiling module ProfileView.
>> WARNING: Module Compat with uuid 314389968181888 is missing from the
>> cache.
>> This may mean module Compat does not support precompilation but is
>> imported
>> by a module that does.
>> ERROR: LoadError: Declaring __precompile__(false) is not allowed in files
>> that are being precompiled.
>>  in macro expansion; at ./none:2 [inlined]
>>  in anonymous at ./:?
>> while loading /home/nbecker/.julia/v0.5/ProfileView/src/ProfileView.jl,
>> in expression starting on line 5
>> ERROR: Failed to precompile ProfileView to
>> /home/nbecker/.julia/lib/v0.5/ProfileView.ji.
>>  in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
>>  in macro expansion at ./REPL.jl:95 [inlined]
>>  in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
>>
>>




[julia-users] Re: ProfileView not compatible with julia-0.5?

2016-09-09 Thread Chris Rackauckas
Yes, you can checkout a branch of the repository via 
Pkg.checkout("Package","branch"). Note that the default is for the master 
branch, i.e. Pkg.checkout("ProfileView") will checkout master. This will 
put you on the "current up-to-date" branch, which could be different than 
the most recent tagged version (which is what Julia gives you from Pkg.add 
by default). Many times the tags/releases will be behind on the bug fixes / 
version compatibility, so checking out master will usually fix this. 

I know that ProfileView works on master in Julia v0.5 and v0.6.

For completeness, you can always go back to the latest tag via 
Pkg.release("Package"). If you stay on master of any package, be prepared 
for "bleeding edge development issues" to crop up, as you're asking for 
using the current source and not the latest release.

On Friday, September 9, 2016 at 3:47:47 PM UTC-7, Neal Becker wrote:
>
> Chris Rackauckas wrote: 
>
> > Did you checkout master? 
> > 
>
> No I just did Pkg.add("ProfileView").  I don't actually know how to do 
> otherwise - is that a Pkg option? 
>
> > On Friday, September 9, 2016 at 2:55:21 PM UTC-7, Neal Becker wrote: 
> >> 
> >> using ProfileView 
> >> INFO: Precompiling module ProfileView. 
> >> WARNING: Module Compat with uuid 314389968181888 is missing from the 
> >> cache. 
> >> This may mean module Compat does not support precompilation but is 
> >> imported 
> >> by a module that does. 
> >> ERROR: LoadError: Declaring __precompile__(false) is not allowed in 
> files 
> >> that are being precompiled. 
> >>  in macro expansion; at ./none:2 [inlined] 
> >>  in anonymous at ./:? 
> >> while loading /home/nbecker/.julia/v0.5/ProfileView/src/ProfileView.jl, 
> >> in expression starting on line 5 
> >> ERROR: Failed to precompile ProfileView to 
> >> /home/nbecker/.julia/lib/v0.5/ProfileView.ji. 
> >>  in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64 
> >>  in macro expansion at ./REPL.jl:95 [inlined] 
> >>  in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68 
> >> 
> >> 
>
>
>

[julia-users] Re: Parallel computing and type-stability

2016-09-09 Thread Richard Dennis
When I run this code in Julia 0.5.0-rc4 the code is much shorter and most 
of the red indicating type instability is gone.

Cheers.


[julia-users] Re: whole arrays pass by reference while matrix columns by value?

2016-09-09 Thread Alexandros Fakos
thank you all for your helpful suggestions!
alex

On Wednesday, September 7, 2016 at 7:00:00 PM UTC-5, Alexandros Fakos wrote:
>
> Hi,
>
> a=rand(10,2)
> b=rand(10)
> sort!(b) modifies b
> but sort!(a[:,1]) does not modify the first column of matrix a 
>
> why is that? Does this mean that i cannot write functions that modify 
> their arguments and apply it to columns of matrices?
>
> Is trying to modify columns of matrices bad programming style? Is there a 
> better alternative?
>  How much more memory am I allocating if my functions return output 
> instead of modifying their arguments (matlab background - I am completely 
> unaware of memory allocation issues)? 
>
> Thanks,
> Alex
>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread K leo
Thanks again.
What is  jl_init("/Users/inorton/git/jl71/usr/lib/")?

On Saturday, September 10, 2016 at 12:44:32 AM UTC+8, Isaiah wrote:
>
> (Disregard my suggestion about `Ptr{TestType}`, `jl_call1` only takes 
> boxed arguments so that won't work)
>
> The problem is that the passed argument type does not match any available 
> method (because it isn't actually passed a julia type at all) so `jl_call1` 
> silently gives up. The `jl_call*` methods are in TRY/CATCH blocks to 
> prevent spilling errors across the API, and they do not print error 
> messages.
>
> The following example works, it's not really efficient but it does 
> demonstrate type construction from C:
>
> #include 
> #include 
> using namespace std;
>
> struct TestType {
> double a;
> double b;
> };
> int main(int argc, char *argv[])
> {
> TestType A, *ret;
> A.a=2.;
> A.b=3.;
> jl_init("/Users/inorton/git/jl71/usr/lib/");
> jl_load("TestArg.jl");
> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
>
>// construct a TestType instance
>
> jl_value_t* jl_A = 
> jl_new_struct((jl_datatype_t*)jl_get_function((jl_module_t*)mod, 
> "TestType"),
>  jl_box_float64(A.a), 
> jl_box_float64(A.b));
>
> jl_function_t * func = jl_get_function((jl_module_t*)mod,"TestFunc");
> jl_call1(func, jl_A);
>
> jl_atexit_hook(0);
> return 0;
> }
>
>
> Using the embedding API requires a substantial depth of understanding of , 
> including stack vs heap and argument passing, as well as dynamic language 
> concepts such as boxing, and rooting. The embedding section of the manual 
> is designed to provide an overview, but ultimately you are going to have to 
> read and grok the Julia source to get every little detail.
>
> On Fri, Sep 9, 2016 at 9:23 AM, K leo > 
> wrote:
>
>> Isaiah,
>>
>> Thanks for the reply.
>>
>> I tried your advice A, i.e. "change to an immutable on julia side, and 
>> change function signature to  'Ptr{TestType}'", and the code behaves the 
>> same as before, i.e. it compiles OK and runs OK but does not show the 
>> output of the println in the function.
>>
>> I guess at the moment what puzzles me is not whether the data get passed 
>> correctly (because I am not trying to access the data yet), but why the one 
>> single statement in the Julia function is not executed.  That function 
>> appears to be taken correctly because if I change the function name in 
>> Julia then there is a core dump.  Any thoughts?
>>
>> I have not yet tried your advice B as I am not too clear about it.
>>
>>
>> On Friday, September 9, 2016 at 8:52:30 PM UTC+8, Isaiah wrote:
>>>
>>> In c, 'struct TestType' is plain old data, not a Julia type 
>>> (jl_value_t). Either change to an immutable on julia side, and change 
>>> function signature to  'Ptr{TestType}'; or allocate a 'jl_value_t*' with 
>>> the correct type tag, and set the fields.
>>>
>>> On Friday, September 9, 2016, K leo  wrote:
>>>
 I tried the following, it compiles OK and runs OK, but it appears the 
 julia function is not called (because there is no output from the println 
 statement).  What is wrong?

 #include 
> #include 
> using namespace std;
> struct TestType {
> double a;
> double b;
> };
> int main(int argc, char *argv[])
> {
> TestType A, *ret;
> A.a=2.;
> A.b=3.;
> jl_init(NULL);
> jl_load("TestArg.jl");
> jl_value_t * mod = (jl_value_t*)jl_eval_string("TestArg");
> jl_function_t * func = 
> jl_get_function((jl_module_t*)mod,"TestFunc");
> jl_call1(func, (jl_value_t *)&A);
> jl_atexit_hook(0);
> return 0;
> }
> # TestArg.jl
> module TestArg
> type TestType
> a::Float64
> b::Float64
> end
> function TestFunc(data::TestType)
> println("in TestArg.TestFunc ")
> end
> end



>

[julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread Drew Mahedy
Here is what the code looks like in MATLAB:

AA = cell( size(trimcoorddir,1), 1 );

figpathdir2 = dir( strrep( figpath2, '\', filesep ) );
fignames2 = {figpathdir2.name};

for i = 1:length(trimcoorddir);

if all( strcmp( fignames2, trimcoord{i}.filename ) == 0 );
A = imread( strrep( [figpath, '\', trimcoord{i}.filename], '\', 
filesep ) );
AA{i} = rgb2gray( A );
AA{i} = 255 - medfilt2( AA{i}, [25 25] ) + AA{i};  %Time Consuming!
AA{i} = imadjust( AA{i}, [0.96 1], [0 1], 1.0 );

imwrite( AA{i}, strrep( [figpath2, '\', trimcoord{i}.filename], 
'\', filesep ) );
else
AA{i} = imread( strrep( [figpath2, '\', trimcoord{i}.filename], 
'\', filesep ) ); 
end

end


On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>
> Could you post code, that reproduces the problem? 
>
> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>
>> I'm just wondering if there is a way to load several RGB .jpg images into 
>> a 4-D array like can be done in MATLAB using cell array. I have the Images 
>> package installed but concatenating 2 images in the 3rd or 4th dimension 
>> says that 'only two-dimensional images are supported in assert2d' when I 
>> try.
>>
>

[julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread Drew Mahedy
In Julia, if I try and concatenate two images together of type:

Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2} via

cat( 3, img, img ),

I get the following error:

Only two-dimensional images are supported

On Friday, September 9, 2016 at 5:01:39 PM UTC-7, Drew Mahedy wrote:
>
> Here is what the code looks like in MATLAB:
>
> AA = cell( size(trimcoorddir,1), 1 );
>
> figpathdir2 = dir( strrep( figpath2, '\', filesep ) );
> fignames2 = {figpathdir2.name};
>
> for i = 1:length(trimcoorddir);
>
> if all( strcmp( fignames2, trimcoord{i}.filename ) == 0 );
> A = imread( strrep( [figpath, '\', trimcoord{i}.filename], '\', 
> filesep ) );
> AA{i} = rgb2gray( A );
> AA{i} = 255 - medfilt2( AA{i}, [25 25] ) + AA{i};  %Time Consuming!
> AA{i} = imadjust( AA{i}, [0.96 1], [0 1], 1.0 );
> 
> imwrite( AA{i}, strrep( [figpath2, '\', trimcoord{i}.filename], 
> '\', filesep ) );
> else
> AA{i} = imread( strrep( [figpath2, '\', trimcoord{i}.filename], 
> '\', filesep ) ); 
> end
>
> end
>
>
> On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>>
>> Could you post code, that reproduces the problem? 
>>
>> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>>
>>> I'm just wondering if there is a way to load several RGB .jpg images 
>>> into a 4-D array like can be done in MATLAB using cell array. I have the 
>>> Images package installed but concatenating 2 images in the 3rd or 4th 
>>> dimension says that 'only two-dimensional images are supported in assert2d' 
>>> when I try.
>>>
>>

[julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread Drew Mahedy
In Julia, if I try and concatenate two images together of type:

Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2} via

cat( 3, img, img ),

I get the following error:

Only two-dimensional images are supported

On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>
> Could you post code, that reproduces the problem? 
>
> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>
>> I'm just wondering if there is a way to load several RGB .jpg images into 
>> a 4-D array like can be done in MATLAB using cell array. I have the Images 
>> package installed but concatenating 2 images in the 3rd or 4th dimension 
>> says that 'only two-dimensional images are supported in assert2d' when I 
>> try.
>>
>

[julia-users] newest stable version of julia on EC2 AWS instances - starcluster

2016-09-09 Thread Alexandros Fakos
Hi,

I am trying to run julia in parallel on EC2 AWS. I use the starcluster 
package to create a cluster of instances.

The problem is that the instances have already installed the 0.3.0 
prerelease. 

I log in the starcluster master node and use the instructions 
from http://julialang.org/downloads/platform.html 

sudo add-apt-repository ppa:staticfloat/juliareleases
sudo add-apt-repository ppa:staticfloat/julia-deps
sudo apt-get update   (this command is giving me errors: W:Failed to fetch 
http://us-west-1.ec2.archive.ubuntu.com/ubuntu/distrs/raring etc. and other 
similar messages)
sudo apt-get install julia

Unfortunately, when  I type  julia in the terminal the 0.3.0 prerelease 
comes up. 

Note that in my regular EC2 instance the above commands work and install 
julia 0.4.6

As a general question, how can I launch instances with the latest stable 
version of julia preinstalled? If I cannot do that, how can I install the 
latest version of julia in all my cluster nodes?

Thanks a lot,
Alex


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread K leo
Bart,

Can you explain what you mean by "need to be rooted"?  The jl_new_struct 
statement as Isaiah suggested works, why do we need the additional 
statements as you suggested?


On Saturday, September 10, 2016 at 3:38:27 AM UTC+8, Bart Janssens wrote:
>
>
>
> On Fri, Sep 9, 2016 at 6:44 PM Isaiah Norton  > wrote:
>
>>// construct a TestType instance
>>
>> jl_value_t* jl_A = 
>> jl_new_struct((jl_datatype_t*)jl_get_function((jl_module_t*)mod, 
>> "TestType"),
>>  jl_box_float64(A.a), 
>> jl_box_float64(A.b));
>>
>>
> The arguments to jl_new_struct need to be rooted, so you should do 
> something like:
> jl_value_t* a = NULL;
> jl_value_t* b = NULL;
> JL_GC_PUSH2(a,b);
> a = jl_box_float64(A.a);
> b = jl_box_float64(A.b);
> // use a and b in the new struct call
> JL_GC_POP();
>
> What is the objective here? If this is still to be used from C++, there 
> may be easier ways using Cxx.jl or CxxWrap.jl.
>
> Cheers,
>
> Bart
>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Yichao Yu
On Fri, Sep 9, 2016 at 8:36 PM, K leo  wrote:

> Bart,
>
> Can you explain what you mean by "need to be rooted"?  The jl_new_struct
> statement as Isaiah suggested works, why do we need the additional
> statements as you suggested?
>

Because it doesn't, it'll segfault at any time if the GC feels like giving
you a bad day.

http://julia.readthedocs.io/en/latest/manual/embedding/#memory-management


>
>
> On Saturday, September 10, 2016 at 3:38:27 AM UTC+8, Bart Janssens wrote:
>>
>>
>>
>> On Fri, Sep 9, 2016 at 6:44 PM Isaiah Norton  wrote:
>>
>>>// construct a TestType instance
>>>
>>> jl_value_t* jl_A = jl_new_struct((jl_datatype_t*)
>>> jl_get_function((jl_module_t*)mod, "TestType"),
>>>  jl_box_float64(A.a),
>>> jl_box_float64(A.b));
>>>
>>>
>> The arguments to jl_new_struct need to be rooted, so you should do
>> something like:
>> jl_value_t* a = NULL;
>> jl_value_t* b = NULL;
>> JL_GC_PUSH2(a,b);
>> a = jl_box_float64(A.a);
>> b = jl_box_float64(A.b);
>> // use a and b in the new struct call
>> JL_GC_POP();
>>
>> What is the objective here? If this is still to be used from C++, there
>> may be easier ways using Cxx.jl or CxxWrap.jl.
>>
>> Cheers,
>>
>> Bart
>>
>


Re: [julia-users] How to use jl_call1 with a struct argument?

2016-09-09 Thread Yichao Yu
On Fri, Sep 9, 2016 at 9:03 PM, Yichao Yu  wrote:

>
>
> On Fri, Sep 9, 2016 at 8:36 PM, K leo  wrote:
>
>> Bart,
>>
>> Can you explain what you mean by "need to be rooted"?  The jl_new_struct
>> statement as Isaiah suggested works, why do we need the additional
>> statements as you suggested?
>>
>
> Because it doesn't, it'll segfault at any time if the GC feels like giving
> you a bad day.
>
> http://julia.readthedocs.io/en/latest/manual/embedding/#memory-management
>


Also, having a C compatible object model, there's no need to use the boxed
version. You can simply let julia allocate the struct for you using
`jl_new_struct_uninit` and then initialize it as what you would do in C
(the pointer returns points to the object with the layout you declare in
julia, which should map directly to a c struct).

For types with only `isbits` fields, you can simply copy the memoy into
newly allocated memory. For non-isbits fields, you can do that for
initialization too, but not setting the field afterward (no matter how the
object was allocated), requires a few more code, see the same section of
manual linked above.



>
>
>>
>>
>> On Saturday, September 10, 2016 at 3:38:27 AM UTC+8, Bart Janssens wrote:
>>>
>>>
>>>
>>> On Fri, Sep 9, 2016 at 6:44 PM Isaiah Norton 
>>> wrote:
>>>
// construct a TestType instance

 jl_value_t* jl_A = jl_new_struct((jl_datatype_t*)
 jl_get_function((jl_module_t*)mod, "TestType"),
  jl_box_float64(A.a),
 jl_box_float64(A.b));


>>> The arguments to jl_new_struct need to be rooted, so you should do
>>> something like:
>>> jl_value_t* a = NULL;
>>> jl_value_t* b = NULL;
>>> JL_GC_PUSH2(a,b);
>>> a = jl_box_float64(A.a);
>>> b = jl_box_float64(A.b);
>>> // use a and b in the new struct call
>>> JL_GC_POP();
>>>
>>> What is the objective here? If this is still to be used from C++, there
>>> may be easier ways using Cxx.jl or CxxWrap.jl.
>>>
>>> Cheers,
>>>
>>> Bart
>>>
>>
>


[julia-users] Re: newest stable version of julia on EC2 AWS instances - starcluster

2016-09-09 Thread Michael Prentiss
I do not know an answer, but you may want  to use the amazon cluster 
generator (cfncluster).  It is under constant development, unlike 
starcluster.  It may be easier. 

https://github.com/awslabs/cfncluster


On Friday, September 9, 2016 at 7:21:33 PM UTC-5, Alexandros Fakos wrote:
>
> Hi,
>
> I am trying to run julia in parallel on EC2 AWS. I use the starcluster 
> package to create a cluster of instances.
>
> The problem is that the instances have already installed the 0.3.0 
> prerelease. 
>
> I log in the starcluster master node and use the instructions from 
> http://julialang.org/downloads/platform.html 
>
> sudo add-apt-repository ppa:staticfloat/juliareleases
> sudo add-apt-repository ppa:staticfloat/julia-deps
> sudo apt-get update   (this command is giving me errors: W:Failed to fetch 
> http://us-west-1.ec2.archive.ubuntu.com/ubuntu/distrs/raring etc. and 
> other similar messages)
> sudo apt-get install julia
>
> Unfortunately, when  I type  julia in the terminal the 0.3.0 prerelease 
> comes up. 
>
> Note that in my regular EC2 instance the above commands work and install 
> julia 0.4.6
>
> As a general question, how can I launch instances with the latest stable 
> version of julia preinstalled? If I cannot do that, how can I install the 
> latest version of julia in all my cluster nodes?
>
> Thanks a lot,
> Alex
>


[julia-users] Installation error

2016-09-09 Thread Yuanchu Dang


Was told:

Error installing Atom.jl package
Go to the Packages → Julia → Open Terminal menu and
run `Pkg.add("Atom")` in Julia, then try again.
If you still see an issue, please report it to:
julia-users@googlegroups.com

But doesn't work:





[julia-users] Cannot start Julia in Atom

2016-09-09 Thread Yuanchu Dang
ERROR: LoadError: ArgumentError: Juno not found in path
 in require at loading.jl:249
 in include at boot.jl:261
 in include_from_node1 at loading.jl:320
 in process_options at client.jl:280
 in _start at client.jl:378
while loading C:\Users\think\.atom\packages\julia-client\script\boot.jl, in 
expression starting on line 36


Re: [julia-users] IBM Power port

2016-09-09 Thread Viral Shah
One more nightly on power:

http://s3.amazonaws.com/julianightlies/bin/linux/ppc64le/0.6/julia-0.6.0-5f91c39b1c-linuxppc64.tar.gz


With this PR being merged, I am hoping 0.5 will build fine on the powerpc 
buildbot, and that we should start getting regular nightlies (until something 
break).


https://github.com/JuliaLang/julia/pull/18418


-viral

On Friday, September 2, 2016 at 10:32:47 PM UTC+5:30, Paulito Palmes wrote:
>
> Hi Viral, 
>
> That is what I thought and read in the docs but if you run the code I 
> attached, merely 'using' would spit some errors where the workers are not 
> aware of the existence of certain function. 
>
> It can be in the name resolution or is it because the function is inside 
> the a macro? I thin not a lot of packages are tested in using @parallel 
> for. So far, the only solution so that my code work is to use using first 
> and the @everywhere using.
>
> Sent from my iPhone
>
> On 2 Sep 2016, at 17:29, Viral Shah  wrote:
>
> You do not need @everywhere. `using` will load on all nodes.
>
> -viral
>
> On Friday, September 2, 2016 at 2:39:34 PM UTC+5:30, Paulito Palmes wrote:
>>
>> I also noticed (not specific to Power machines) that when you want to 
>> load packages in Julia with several workers, I have to do the following to 
>> have successful loading of packages:
>>
>> nprocs()==1 && addprocs()
>> using Knet
>> @everywhere using Knet
>> using RDatasets
>> @everywhere using RDatasets
>> using MLBase
>> @everywhere using MLBase
>>
>>
>> If I use, 
>> nprocs()==1 && addprocs()
>> @everywhere using RDatasets
>> @everywhere using Knet
>> @everywhere using MLBase
>>
>> I have this error:
>> ERROR: On worker 2:
>> LoadError: LoadError: UndefVarError: @knet not defined
>>
>> If I use,
>> nprocs()==1 && addprocs()
>> using RDatasets
>> using Knet
>> using MLBase
>>
>> ERROR (unhandled task failure): On worker 4:
>> On worker 4:
>> On worker 4:
>> UndefVarError: Gaussian not defined
>>
>> Attached is the code that I use which uses 3 @parallel for syntax
>>
>> My insight is that you need to load first all the packages into the 
>> process id 1 to avoid clashes during pre-cache compilation and use 
>> @everywhere using 
>> to export the functions to other processes. It seems that just *using* 
>> directives does not immediately export those functions to all processes 
>> based on the code attached such that I have to use "@everywhere using" 
>> directives. Is this a bug?
>>
>> Please try to reproduce the errors I have with the attached code. This 
>> error only happens if you do addprocs() to run parallel julia.
>>
>> I'm using Julia 0.4.6 (2016-06-19 17:16 UTC)
>>
>> On Fri, Sep 2, 2016 at 9:52 AM, Paulito Palmes  wrote:
>>
>>> Hi All,
>>>
>>> I noticed that some of the packages are not aware that Julia has power 
>>> port now and when you install those packages, they include some compiler 
>>> directives specific to Intel processor such as SSE. In the Makefile, I 
>>> removed this extra option and the package compiles. However, if I do 
>>> Pkg.build("Package"), it does not respect the edited Makefile and starts to 
>>> download from github. I don't know the sequence of operations behind but is 
>>> there a way to manually compile and install the local package downloaded 
>>> after you edit some files to make it work for the power machine?
>>>
>>> I think the long term solution is to have a test server running power 
>>> machine to flag that the package did not compile successfully to the power 
>>> port.
>>>
>>> -paulito
>>>
>>> On Fri, Sep 2, 2016 at 8:02 AM, Viral Shah  wrote:
>>>
 Can you try this one? I believe this error is addressed now.


 http://s3.amazonaws.com/julianightlies/bin/linux/ppc64le/julia-latest-linuxppc64.tar.gz

 Also, Elliot enabled the nightlies:

 https://build.julialang.org/builders/package_tarballppc64le

 -viral


 > On Sep 2, 2016, at 4:15 AM, James Fairbanks  
 wrote:
 >
 > Hi Viral,
 >
 > I got negative results on my power8 machine.
 > After untarring the link above I got the following errors when just 
 running the repl.
 >
 >
 > [jpf@power8 julia-3005940a21]$ ./bin/julia
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized processor for this target (ignoring 
 processor)
 > 'powerpc64le' is not a recognized proc

[julia-users] Re: Parallel computing and type-stability

2016-09-09 Thread Sleort
@Yichao Yu: Sure. I'm aware that there is a lot of overhead in the inter 
process communication. This was just a minimal test case, not something I 
expect to run fast(er). (A silly nworker() implementation indeed;-)) I was 
just curious if it is possible to reduce the type instability showing up in 
parallel programming situations like this (and others). One reason is that 
such a type instability seem to "mask" @time results (number of allocations 
and memory usage is typically much larger for type unstable code, right?), 
making it harder to get a quick idea of the performance/type stability of 
parts of the code that really matters...

@Richard Dennis: That's interesting! Do you (or anyone else) have an idea 
why? What is updated/changed in 0.5.0-rc4 compared to 0.4.6?


Re: [julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread El suisse
julia version???

julia>versioninfo()
​

2016-09-09 21:19 GMT-03:00 Drew Mahedy :

> In Julia, if I try and concatenate two images together of type:
>
> Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2} via
>
> cat( 3, img, img ),
>
> I get the following error:
>
> Only two-dimensional images are supported
>
> On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>
>> Could you post code, that reproduces the problem?
>>
>> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>>
>>> I'm just wondering if there is a way to load several RGB .jpg images
>>> into a 4-D array like can be done in MATLAB using cell array. I have the
>>> Images package installed but concatenating 2 images in the 3rd or 4th
>>> dimension says that 'only two-dimensional images are supported in assert2d'
>>> when I try.
>>>
>>


[julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread Uwe Fechner
Sorry, but this is not a complete example that I could run to reproduce the 
problem.

On Saturday, September 10, 2016 at 2:19:19 AM UTC+2, Drew Mahedy wrote:
>
> In Julia, if I try and concatenate two images together of type:
>
> Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2} via
>
> cat( 3, img, img ),
>
> I get the following error:
>
> Only two-dimensional images are supported
>
> On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>>
>> Could you post code, that reproduces the problem? 
>>
>> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>>
>>> I'm just wondering if there is a way to load several RGB .jpg images 
>>> into a 4-D array like can be done in MATLAB using cell array. I have the 
>>> Images package installed but concatenating 2 images in the 3rd or 4th 
>>> dimension says that 'only two-dimensional images are supported in assert2d' 
>>> when I try.
>>>
>>

[julia-users] Re: Cell array of images like Matlab

2016-09-09 Thread Matt Bauman
I cannot reproduce that error, and I know that the lead author of Images 
uses stacked image arrays quite frequently.

julia> using TestImages, Images
   src = testimage("mandrill")
   arr = convert(Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8
}},2}, src)
   cat(3, arr, arr)
512x512x2 Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},3}:
...

julia>img = Image(arr)
   cat(3, img, img)
Gray Images.Image with:
  data: 512x512x2 Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},3
}
…

Are you doing this in an IJulia notebook?  It may be that the error you're 
seeing is simply that IJulia doesn't know how to display a stack of images.

On another note, the Julia equivalent to a cell array is an `Any[]` array, 
which is quite different from concatenating the images together in a higher 
dimension.  You can even use the Matlab-like `cell( size(trimcoorddir,1) )` 
to initialize an array that can hold anything like a cell array.

, 
On Friday, September 9, 2016 at 7:19:19 PM UTC-5, Drew Mahedy wrote:
>
> In Julia, if I try and concatenate two images together of type:
>
> Array{ColorTypes.Gray{FixedPointNumbers.UFixed{UInt8,8}},2} via
>
> cat( 3, img, img ),
>
> I get the following error:
>
> Only two-dimensional images are supported
>
> On Wednesday, September 7, 2016 at 7:24:14 PM UTC-7, Uwe Fechner wrote:
>>
>> Could you post code, that reproduces the problem? 
>>
>> On Thursday, September 8, 2016 at 1:28:00 AM UTC+2, Drew Mahedy wrote:
>>>
>>> I'm just wondering if there is a way to load several RGB .jpg images 
>>> into a 4-D array like can be done in MATLAB using cell array. I have the 
>>> Images package installed but concatenating 2 images in the 3rd or 4th 
>>> dimension says that 'only two-dimensional images are supported in assert2d' 
>>> when I try.
>>>
>>

[julia-users] Re: Maps in Julia?

2016-09-09 Thread Kaj Wiik
Perfect, thanks!

Kaj

On Saturday, September 10, 2016 at 1:30:49 AM UTC+3, Andy Ferris wrote:
>
> ... and transform geographic coordinates (GNSS logger lat, lon) to UTM 
>> (cartesian, unit = metre) by calling libgeographic.
>>
>
> Geodesy.jl now has a native port of libgeographics UTM conversion code - 
> you might possibly find that convenient.
>
> Andy
>