Re: [julia-users] Re: Julia T-shirt and Sticker

2015-03-10 Thread Mike Innes
The distance between Julia and insanity is measured only in segfaults


Re: [julia-users] Re: Julia T-shirt and Sticker

2015-03-10 Thread Sorami Hisamoto
 Any sufficiently advanced programing language is indistinguishable from 
 Julia

+1


Re: [julia-users] Computed type for parametrized method definition

2015-03-10 Thread Mauro
 abstract typeA

 immutable typeA1 : typeA end
 immutable typeA2 : typeA end

 type typeB1 end
 type typeB2 end

More Julian would be to write:

transformType(T::Type{typeA1}) = typeB1
transformType(T::Type{typeA2}) = typeB2
transformType(T::Type) = error(Cannot handle type $T)

 function transformType(T)
 if T == typeA1
return typeB1
 elseif T == typeA2
return typeB2
 end
 error(Cannot handle type $T)
 end

 function compute{T:typeA}(a::transformType(T), b::transformType(T))
 return (a, b)
 end

 but it failed with the following error message

 ERROR: Cannot handle type T:typeA
  in error at error.jl:21
  in transformType at /Users/bpiwowar/Desktop/test.jl:15
  in include at 
 /opt/homebrew-cask/Caskroom/julia/0.3.5/Julia-0.3.5.app/Contents/Resources/julia/lib/julia/sys.dylib
  in include_from_node1 at loading.jl:128
  in process_options at 
 /opt/homebrew-cask/Caskroom/julia/0.3.5/Julia-0.3.5.app/Contents/Resources/julia/lib/julia/sys.dylib
  in _start at 
 /opt/homebrew-cask/Caskroom/julia/0.3.5/Julia-0.3.5.app/Contents/Resources/julia/lib/julia/sys.dylib
 while loading /Users/bpiwowar/Desktop/test.jl, in expression starting on 
 line 18

 The type transformType(T)is hence computed when the method is defined, but 
 not when the method is called. Is there any way to prevent this (to defer 
 evaluation at compilation time?). 

Have a look at stagedfunction (v0.4).

 The only other way (I can think of) to get this result would be to use 
 macros and enumerate the different possible types, but if somebody can 
 think of a better solution, thanks!

why not write:
type typeB1 : typeB end
type typeB2 : typeB end
compute(a::typeB, b::typeB) = return (a, b)


[julia-users] Dimension mismatch error in Julia!

2015-03-10 Thread Kacem HARIZ
*Here is the code:*

*w=1;*
*γ=0.01;*
*f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];*

*for i=1:sizeof(Sx)*
*x0=Sx[i+2];*
*y0=Sy[i+2];*
*for j=1:sizeU*
*u=U[i];*
*t,NX=ODE.ode45(f,[0,0.1],[x0,y0])*
*end*
*end*

with Sx and Sy vectors of the same size, and U an other vector of size 
sizeU.

*and here is the error message:*

mismatch in dimension 1
while loading In[69], in expression starting on line 5

 in cat at abstractarray.jl:631
 in hcat at abstractarray.jl:671
 in hvcat at abstractarray.jl:966
 in f at In[69]:3
 in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208
 in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303
 in anonymous at no file:10

Does anyone know how to fix it, please let me know, I'd be very grateful!


[julia-users] Dimension mismatch error in Julia!​

2015-03-10 Thread Kacem HARIZ


I got stuck by an error in Julia! please I need help!

*here is the code:*

 
*w=1;*
*γ=0.01;*
*f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];*

*for i=1 : numberOfStates*
*x0=Sx[i+2];*
*y0=Sy[i+2];*
*for j=1:sizeU*
*u=U[i];*
*t,NX=ODE.ode45(f(x,y,u),[0,0.1],[x0,y0])*
*end*
*end*

with Sx and Sy two vectors of the same size, and U is a vector of size 
sizeU.

*and here is the error message:*

mismatch in dimension 1
while loading In[94], in expression starting on line 5

 in cat at abstractarray.jl:631
 in hcat at abstractarray.jl:671
 in hvcat at abstractarray.jl:966
 in f at In[90]:3
 in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208
 in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303
 in anonymous at no file:10


Best regards,
Kacem


Re: [julia-users] Dimension mismatch error in Julia!

2015-03-10 Thread Andreas Noack
It is more helpful if you can provide a self contained example that we can
run. However, I think you've been bitten by our white space concatenation.
When you define f, the second element is written

*-w^2*sin(x)-u*w^2*cos(x) -2γ*y*

*but I think that is getting parsed as*

*hvcat(**-w^2*sin(x)-u*w^2*cos(x), -2γ*y**)*

*if instead you had a space after the minus, it would work. Like*

*-w^2*sin(x)-u*w^2*cos(x) - 2γ*y*

*That is a bit unfortunate and something that is heavily discussed right
now.*

2015-03-10 5:17 GMT-04:00 Kacem HARIZ kacem.ha...@gmail.com:

 *Here is the code:*

 *w=1;*
 *γ=0.01;*
 *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];*

 *for i=1:sizeof(Sx)*
 *x0=Sx[i+2];*
 *y0=Sy[i+2];*
 *for j=1:sizeU*
 *u=U[i];*
 *t,NX=ODE.ode45(f,[0,0.1],[x0,y0])*
 *end*
 *end*

 with Sx and Sy vectors of the same size, and U an other vector of size
 sizeU.

 *and here is the error message:*

 mismatch in dimension 1
 while loading In[69], in expression starting on line 5

  in cat at abstractarray.jl:631
  in hcat at abstractarray.jl:671
  in hvcat at abstractarray.jl:966
  in f at In[69]:3
  in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208
  in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303
  in anonymous at no file:10

 Does anyone know how to fix it, please let me know, I'd be very grateful!



Re: [julia-users] Re: Julia T-shirt and Sticker

2015-03-10 Thread Michele Zaffalon
No segfaults means zero distance?

On Tue, Mar 10, 2015 at 1:22 PM, Mike Innes mike.j.in...@gmail.com wrote:

 The distance between Julia and insanity is measured only in segfaults



Re: [julia-users] Re: Strange behaviour

2015-03-10 Thread Milan Bouchet-Valat
Le mardi 10 mars 2015 à 01:40 -0700, David van Leeuwen a écrit :
 Hello,
 
 On Friday, March 6, 2015 at 2:22:42 AM UTC+1, Tony Kelman wrote:
  I suppose this is related to + and - being unary operators?
 
 
 Ding ding. Unfortunately space being the horizontal
 concatenation operator means some operations parse very
 differently and in highly whitespace-sensitive ways depending
 whether they are inside or outside an array literal. Would be
 nice if that were not the case, but I think we'd need another
 delimiter character aside from , or ; to really separate
 horizontal concatenation from vertical concatenation from list
 construction.
 
 
 I've always found the space as operator a kind-of-upsetting thing in
 Julia.  (I refused to use Python---to my own disadvantage---for many
 years because there are semantics in the amount of space used, but I
 finally got over that.)  
 
 
 Is it really necessary to have separate operators for horizontal and
 vertical list construction?  In most other respects, Julia seems not
 to treat the second dimension really special.  E.g., I've argued for
 `nrow()` and `ncol()` because---to me---this is more intuitive than
 the `size(, dim)`, but it was very clear in the discussions that this
 was a wrong way to think about arrays.  So now I actually got used to
 `size()`.  
 
 
 Do we really use literal matrix construction that often in code?  I
 guess one would use it for examples, but in these cases, can't we just
 `hcat()` the columns? 
That's exactly the discussion that is going on at
https://github.com/JuliaLang/julia/issues/7128

Regards

 ---david
  
 
 julia j=2; [ 1 +j ]
 1x2 Array{Int64,2}:
  1  2
 
 
 julia j=2; [ 1 + j ]
 1-element Array{Int64,1}:
  3
 
 
 julia j=2; 1 +j
 3
 
 
 julia j=2; 1 + j
 3
 
 
 
 
 On Thursday, March 5, 2015 at 4:56:20 PM UTC-8, Amuthan A.
 Ramabathiran wrote:
 Not sure if this has been discussed earlier... can
 someone explain whats happening here?
 
 julia b = [ 1 +j for j = 1:5 ]
 ERROR: syntax: invalid comprehension syntax
 
 
 julia b = [ 1 + j for j = 1:5 ]
 5-element Array{Int64,1}:
  2
  3
  4
  5
  6
 
 
 
 
 This happens with both + and -, but not with * or /. I
 suppose this is related to + and - being unary
 operators?
 
 
 Thanks!
 Amuthan.



[julia-users] Re: Dimension mismatch error in Julia!​

2015-03-10 Thread Jonathan Goldfarb
Looks like a couple things going on here:

- The error is due to a mix of hcat and vcat in the definition of f; 
replacing it with either 
*f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x); -2γ*y];*
or
*f(x,y)= [y, -w^2*sin(x)-u*w^2*cos(x), -2γ*y];*
will fix this error.
I predict 
other errors down the line:
- f is a function of two arguments, but it is passed to ode45 with three. 
ode45 expects a function f=f(x,y) where y is a vector of length (in this 
case) 3, I guess. You could define f as a function of 3 arguments, then 
pass the anonymous function (x,y)-f(x,y,u) to ode4
- if U is a vector of length sizeU, you may get a BoundsError calling U[i] 
rather than U[j]


On Tuesday, March 10, 2015 at 8:33:10 AM UTC-4, Kacem HARIZ wrote:



 I got stuck by an error in Julia! please I need help!

 *here is the code:*

  
 *w=1;*
 *γ=0.01;*
 *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];*

 *for i=1 : numberOfStates*
 *x0=Sx[i+2];*
 *y0=Sy[i+2];*
 *for j=1:sizeU*
 *u=U[i];*
 *t,NX=ODE.ode45(f(x,y,u),[0,0.1],[x0,y0])*
 *end*
 *end*

 with Sx and Sy two vectors of the same size, and U is a vector of size 
 sizeU.

 *and here is the error message:*

 mismatch in dimension 1
 while loading In[94], in expression starting on line 5

  in cat at abstractarray.jl:631
  in hcat at abstractarray.jl:671
  in hvcat at abstractarray.jl:966
  in f at In[90]:3
  in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208
  in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303
  in anonymous at no file:10


 Best regards,
 Kacem



Re: [julia-users] Dimension mismatch error in Julia!​

2015-03-10 Thread Mauro
It would be helpful if you could post an example which runs with just
copy-paste into the REPL.

On Tue, 2015-03-10 at 10:55, Kacem HARIZ kacem.ha...@gmail.com wrote:
 I got stuck by an error in Julia! please I need help!

 *here is the code:*

  
 *w=1;*
 *γ=0.01;*
 *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];*

 *for i=1 : numberOfStates*
 *x0=Sx[i+2];*
 *y0=Sy[i+2];*
 *for j=1:sizeU*
 *u=U[i];*
 *t,NX=ODE.ode45(f(x,y,u),[0,0.1],[x0,y0])*
 *end*
 *end*

 with Sx and Sy two vectors of the same size, and U is a vector of size 
 sizeU.

 *and here is the error message:*

 mismatch in dimension 1
 while loading In[94], in expression starting on line 5

  in cat at abstractarray.jl:631
  in hcat at abstractarray.jl:671
  in hvcat at abstractarray.jl:966
  in f at In[90]:3
  in oderkf at /home/juser/.julia/v0.3/ODE/src/ODE.jl:208
  in ode45_dp at /home/juser/.julia/v0.3/ODE/src/ODE.jl:303
  in anonymous at no file:10


 Best regards,
 Kacem



Re: [julia-users] @async weirdness

2015-03-10 Thread Sam L
I see the behavior on OS X.  It also occurs with three println's.

  | | |_| | | | (_| |  |  Version 0.3.7-pre+1 (2015-02-17 22:12 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit d15f183* (21 days old release-0.3)
|__/   |  x86_64-apple-darwin13.4.0

julia t = @async (println(foo);println(bar); println(baz))
foo
Task (queued) @0x7fa0faf0e520bar


julia
_

The _ indicates the cursor position after running the line of code. I hit 
return only once after the first line starting with 't = @async...', and I 
got two blank lines after Task was displayed, before the julia prompt, and 
the cursor ended up in the first column on a new line after the julia 
prompt. 


On Tuesday, March 10, 2015 at 8:17:30 PM UTC-7, Amit Murthy wrote:

 Works fine on Linux. 



 On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjart...@gmail.com 
 javascript: wrote:

 in my continuing quest to understand Julia tasks, i have created the 
 following contrived example which does not behave as i would expect. can 
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo) 
  println(bar) 
  end 

 printfoobar (generic function with 1 method) 

 julia printfoobar()   # great, it works
 foo 
 bar 

 julia println(honey); println(wagon)   # no surprise again
 honey 
 wagon 

 julia t = @async (println(honey); println(wagon))  #  works too, 
 modulo 'Task' being inbetween
 honey 
 Task (queued) @0x7fb59e832500wagon 

 julia t = @async printfoobar()   # ditto:  foo and bar both printed, 
 albeit with 'Task' inbetween
 foo 
 Task (queued) @0x7fb59f2e1720bar 

 julia t = @async (println(honey); printfoobar(); println(wagon))   # 
 WHERE ARE bar AND wagon ???
 honey 
 Task (queued) @0x7fb59f2e1840foo 

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t) 
 true

 is it that println(foo) and println(wagon) never get executed?  or 
 that the output stream is just not making it to the REPL?  this is in 0.3.6 
 by the way.  similar things happen on a 0 day old master.




[julia-users] Re: How to generate composite types with a macro?

2015-03-10 Thread Spencer Lyon


Seems like you have a good answer already, but for what it’s worth I have 
the following code in a package I’m developing:

# Some helpful typealiases to keep things tidy
typealias SymExpr Union(Symbol, Expr)
typealias VecSymExpr Union(Vector{Symbol}, Vector{Expr})

# Take a name and type and return an argument
make_arg(nm::Symbol, typ::SymExpr) = Expr(:(::), nm, typ)
make_arg(nm::Symbol, typ::DataType) = Expr(:(::), nm, :($typ))

# Construct a type_name and correct subtype expression
function type_name(name::Symbol, super::SymExpr)
if super == :Any
return name
else
return Expr(:(:), name, super)
end
end

# From a name, a vector of fields, and a vector of field types, make an
# expression that defines a new type
function make_type(name::Symbol, fields::Vector{Symbol}, super::SymExpr=:Any,
   typs=fill(:Float64, length(fields));
   mutable::Bool=false)

fs = map(x-make_arg(x...), zip(fields, typs))
t_name = type_name(name, super)
Expr(:type, mutable, t_name, Expr(:block, fs...))
end

the make_type function can easily be called from within a macro as follows

macro foo(...)

typ = make_type(args...)
# Do other stuff

esc(quote
$(typ)
# return parts of block expression
end)

end

On Monday, March 9, 2015 at 12:44:24 PM UTC-4, Kaj Wiik wrote:

Unfortunately parametric types did not pass through new() correctly 
 resulting gibberish. Specifying the type explicitly works fine:

 macro gentype(N, typename, fieldtype)
fields = [:($(symbol(I_$i))::$(symbol($fieldtype))) for i=1
 :N]
quote
immutable $(typename)
$(fields...)
end
end
 end

 Thanks,
 Kaj



 On Monday, March 9, 2015 at 6:05:10 PM UTC+2, Kaj Wiik wrote:



 This is more elegant Julian way that I tried to find, thanks!

 Kaj


 On Monday, March 9, 2015 at 1:43:14 PM UTC+2, Simon Danisch wrote:

 Hi,
 I'm working on FixedSizeArrays, which does pretty much what you have 
 tried here.
 Simplified version from constructors.jl 
 https://github.com/SimonDanisch/FixedSizeArrays.jl/blob/master/src/constructors.jl
  :
 macro gentype(N, typename)
 fields = [:($(symbol(I_$i))::T) for i=1:N]
 quote
 immutable $(typename){T}
 $(fields...)
 end
 end
 end


 Am Donnerstag, 5. März 2015 11:02:51 UTC+1 schrieb Kaj Wiik:

 I have been trying to write a macro that would generate fields in a 
 for-loop.

 However, when I try to generate the first line I get an error:

 julia macro deftype(name,artype,num)
ex1 = :(esc( immutable $name))
 ERROR: syntax: unexpected )

 julia macro deftype(name,artype,num)
ex1 = :(esc(quote immutable $name end))
 ERROR: syntax: extra token ) after end of expression


 There must be a way to do this, I cannot find how...

 Thanks,
 Kaj

 ​


[julia-users] @async weirdness

2015-03-10 Thread Ben Arthur
in my continuing quest to understand Julia tasks, i have created the 
following contrived example which does not behave as i would expect. can 
anyone help explain please? thanks in advance.

julia function printfoobar()
 println(foo) 
 println(bar) 
 end 

printfoobar (generic function with 1 method) 

julia printfoobar()   # great, it works
foo 
bar 

julia println(honey); println(wagon)   # no surprise again
honey 
wagon 

julia t = @async (println(honey); println(wagon))  #  works too, 
modulo 'Task' being inbetween
honey 
Task (queued) @0x7fb59e832500wagon 

julia t = @async printfoobar()   # ditto:  foo and bar both printed, 
albeit with 'Task' inbetween
foo 
Task (queued) @0x7fb59f2e1720bar 

julia t = @async (println(honey); printfoobar(); println(wagon))   # 
WHERE ARE bar AND wagon ???
honey 
Task (queued) @0x7fb59f2e1840foo 

julia # ENTER  #nope, they still don't appear

julia # ENTER

julia # ENTER

julia wait(t)   # nope, still no further printed output

julia yield()   # still no joy

julia istaskdone(t) 
true

is it that println(foo) and println(wagon) never get executed?  or that 
the output stream is just not making it to the REPL?  this is in 0.3.6 by 
the way.  similar things happen on a 0 day old master.


Re: [julia-users] Computed type for parametrized method definition

2015-03-10 Thread Mauro
 Have a look at stagedfunction (v0.4). 

 I tried with the nightly build, but without success (using stagedfunction 
 instead of function) - however, it looks like it is the solution, maybe I 
 will just have to wait until this is implemented (and the syntax set).

You will need to adapt the code to work with stagedfunctions.  They work
in stages: with the types of the arguments the code for the actual
function is produced.  Sadly there is no documentation, I think.  See:
https://github.com/JuliaLang/julia/issues/7311

  The only other way (I can think of) to get this result would be to use 
  macros and enumerate the different possible types, but if somebody can 
  think of a better solution, thanks! 

 why not write: 
 type typeB1 : typeB end 
 type typeB2 : typeB end 
 compute(a::typeB, b::typeB) = return (a, b) 

 Because I would like to ensure that a and b are of the same type 

In that case use:

compute{T:typeB}(a::T, b::T) = return (a, b)

T will be set to the concrete type of a and there will be a no-method
error if isa(b,T) is not true.


Re: [julia-users] Intel Xeon Phi support?

2015-03-10 Thread Jeff Waller


On Tuesday, March 10, 2015 at 1:39:42 PM UTC-4, Stefan Karpinski wrote:

 I'm not sure what that would mean – CPUs don't ship with software. Julia 
 will support Kinght's Landing, however, although it probably won't do so 
 until version 0.5.

 On Tue, Mar 10, 2015 at 1:36 PM, Karel Zapfe kza...@gmail.com 
 javascript: wrote:

 Hello:

 Is it true then, that Knight's Landing will have Julia out-of-the-box? I 
 was checking the page of Intel, but found nothing to the respect. At my 
 laboratory we had some extra money, and were considering on getting one, 
 but the point is that none of us is really good at using fortran+mpi or 
 c+mpi, so with Julia most of us non-programers-but-researchers could have 
 hope of really using it. 


Knight's Landing is not supposed to be available until Q2 which strictly 
speaking, I guess is just a couple of weeks but I would have expected to 
see some big announce.  Maybe it won't really be readily available with 
(non-reference) motherboards until summer?  do you expect dev 0.5 by say 
July (kinda like last year)? 


[julia-users] Re: How to embed Julia into Visual Studoi 2013?

2015-03-10 Thread Jeff Waller


On Tuesday, March 10, 2015 at 12:25:20 PM UTC-4, Yuhui ZHI wrote:

 Hello everyone,

 I have a question: how to embed Julia into VS2013?

 I have read this: 
 https://github.com/JuliaLang/julia/blob/release-0.3/doc/manual/embedding.rst

 But I still have no idea.

 I am using vs2013 in the system of Windows10.
 I have created a project and now I want to use Julia in it. So I want to 
 know how to embed Julia here.



Julia is compiled using gcc and MSYS2 on Windows, and though support for 
compilation using VSC++ is kinda there, it's
early.  Tony would be able to explain way better, though.

However, I've been doing some reading, and there might be a way to link to 
libjulia and thus embed Julia in a Visual Studio
C/C++ program 
http://stackoverflow.com/questions/2096519/from-mingw-static-library-a-to-visual-studio-static-library-lib.
 
 All
of the exported symbols of libjulia should be C symbols, so you don't have 
to worry about how gcc and VSC++ name mangle
differently, making things easier.  libjulia is a .dll, but if you need a 
.lib, then there's a technique to do that 
https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/

I would be very interested in making libjulia accessable to VS.






Re: [julia-users] Intel Xeon Phi support?

2015-03-10 Thread Viral Shah
LLVM support for KNL is already in place. So yes, it will come quickly, but in 
a released version of Julia, that is certainly no earlier than 0.5. It is also 
quite likely that we need good multi-threading support to ensure a good 
experience for KNL - which is also happening simultaneously.

I am personally quite excited about the socketable KNL, and the possibilities 
with Julia.

-viral



 On 10-Mar-2015, at 11:34 pm, Stefan Karpinski ste...@karpinski.org wrote:
 
 0.5 should be released around end of 2015, but there will be support on 
 master before that.
 
 On Tue, Mar 10, 2015 at 2:00 PM, Jeff Waller truth...@gmail.com wrote:
 
 
 On Tuesday, March 10, 2015 at 1:39:42 PM UTC-4, Stefan Karpinski wrote:
 I'm not sure what that would mean – CPUs don't ship with software. Julia will 
 support Kinght's Landing, however, although it probably won't do so until 
 version 0.5.
 
 On Tue, Mar 10, 2015 at 1:36 PM, Karel Zapfe kza...@gmail.com wrote:
 Hello:
 
 Is it true then, that Knight's Landing will have Julia out-of-the-box? I was 
 checking the page of Intel, but found nothing to the respect. At my 
 laboratory we had some extra money, and were considering on getting one, but 
 the point is that none of us is really good at using fortran+mpi or c+mpi, so 
 with Julia most of us non-programers-but-researchers could have hope of 
 really using it. 
 
 Knight's Landing is not supposed to be available until Q2 which strictly 
 speaking, I guess is just a couple of weeks but I would have expected to see 
 some big announce.  Maybe it won't really be readily available with 
 (non-reference) motherboards until summer?  do you expect dev 0.5 by say July 
 (kinda like last year)? 
 



[julia-users] Re: Could it be a bug of PyCall or PyPlot?

2015-03-10 Thread Jerry Xiong
Many thanks!

On Monday, March 9, 2015 at 10:24:42 PM UTC+1, Steven G. Johnson wrote:



 On Monday, March 9, 2015 at 5:24:22 PM UTC-4, Steven G. Johnson wrote:

 On Monday, March 9, 2015 at 5:18:52 PM UTC-4, Steven G. Johnson wrote:

 Yes, I should probably define a pycall method for ColorMap.   For now, 
 you can do pycall(cmap2.o, PyAny, 0.5).


 Just fixed it in PyCall (master branch on github).


 I mean in PyPlot. 



Re: [julia-users] Referencing function scope variables from @async blocks

2015-03-10 Thread Ben Arthur
+1 for documenting whether @async introduces a scope block.  is what amit 
said true?

On Saturday, July 20, 2013 at 4:23:21 AM UTC-4, Amit Murthy wrote:

 My understanding is that let blocks only localize variables explicitly 
 specified on the first line, while @async localizes all variables.



Re: [julia-users] How to embed Julia into Visual Studoi 2013?

2015-03-10 Thread Stefan Karpinski
The embedding talked about in that page is how to call Julia from C/C++
programs. While VS2013 is a C++ program, unless you have the source for it,
that doesn't really help. It may be possible to write a Julia plugin for
VS2013, however, but that would take a lot of time, effort and expertise.

On Tue, Mar 10, 2015 at 12:22 PM, Yuhui ZHI yuhui.zh...@gmail.com wrote:

 Hello everyone,

 I have a question: how to embed Julia into VS2013?

 I have read this:
 https://github.com/JuliaLang/julia/blob/release-0.3/doc/manual/embedding.rst

 But I still have no idea.

 I am using vs2013 in the system of Windows10.
 I have created a project and now I want to use Julia in it. So I want to
 know how to embed Julia here.


 Could someone help me???

 thanks a lot!



Re: [julia-users] Intel Xeon Phi support?

2015-03-10 Thread Stefan Karpinski
I'm not sure what that would mean – CPUs don't ship with software. Julia
will support Kinght's Landing, however, although it probably won't do so
until version 0.5.

On Tue, Mar 10, 2015 at 1:36 PM, Karel Zapfe kza...@gmail.com wrote:

 Hello:

 Is it true then, that Knight's Landing will have Julia out-of-the-box? I
 was checking the page of Intel, but found nothing to the respect. At my
 laboratory we had some extra money, and were considering on getting one,
 but the point is that none of us is really good at using fortran+mpi or
 c+mpi, so with Julia most of us non-programers-but-researchers could have
 hope of really using it.

 El sábado, 8 de noviembre de 2014, 18:40:20 (UTC-6), John Drummond
 escribió:

 http://www.colfax-intl.com/nd/xeonphi/31s1p-promo.aspx is a link from a
 distributor. Presumably Intel are trying to encourage the growth of the
 use, also with knight's landing turning up and they made a lot of them. In
 lots of 10 they're selling at 125 usd each.

 On Saturday, November 8, 2014 7:20:17 AM UTC, Jeff Waller wrote:



 On Thursday, November 6, 2014 1:14:51 PM UTC-5, Viral Shah wrote:

 We had ordered a couple, but they are really difficult to get working.
 There is a fair bit of compiler work that is required to get it to work -
 so it is safe to assume that this is not coming anytime soon. However, the
 Knight's Landing should work out of the box with Julia whenever it comes
 and we will most likely have robust multi-threading support by then to
 leverage it.


 Aww!



 Out of curiosity, what would you like to run on the Xeon Phi? It may be
 a good multi-threading benchmark for us in general.


 Something that requires 1TFlop, or maybe 1000 things that take 1 GFlop?

 Hmm, how about realtime photogrammetry?



 -viral

 On Thursday, November 6, 2014 9:35:57 PM UTC+5:30, John Drummond wrote:

 Did you have any success?
 There's an offer of the cards for 200usd at the moment


 That's like 1/10th the price?





RE: [julia-users] How to embed Julia into Visual Studoi 2013?

2015-03-10 Thread David Anthoff
There is actually an open source pluging for python for VS that is developed by 
MS. The whole package is VERY smooth (including debugger etc). If someone 
wanted to create a julia plugin for VS, that would probably be a great starting 
point. Certainly not me, though :)

 

From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On 
Behalf Of Stefan Karpinski
Sent: Tuesday, March 10, 2015 6:17 PM
To: Julia Users
Subject: Re: [julia-users] How to embed Julia into Visual Studoi 2013?

 

The embedding talked about in that page is how to call Julia from C/C++ 
programs. While VS2013 is a C++ program, unless you have the source for it, 
that doesn't really help. It may be possible to write a Julia plugin for 
VS2013, however, but that would take a lot of time, effort and expertise.

 

On Tue, Mar 10, 2015 at 12:22 PM, Yuhui ZHI yuhui.zh...@gmail.com 
mailto:yuhui.zh...@gmail.com  wrote:

Hello everyone,

 

I have a question: how to embed Julia into VS2013?

 

I have read this: 
https://github.com/JuliaLang/julia/blob/release-0.3/doc/manual/embedding.rst

 

But I still have no idea.

 

I am using vs2013 in the system of Windows10.

I have created a project and now I want to use Julia in it. So I want to know 
how to embed Julia here.

 

 

Could someone help me???

 

thanks a lot!

 



Re: [julia-users] Re: Create formatted string

2015-03-10 Thread Tony Fong
Try Formatting.jl? (https://github.com/lindahua/Formatting.jl)

On Wednesday, March 11, 2015 at 7:16:55 AM UTC+7, Dominique Orban wrote:

 This is an old question about computed format strings, but it's still 
 biting me. I've been following your suggestion and I defined

 print_formatted(fmt, args...) = @eval @printf($fmt, $(args...))

 Now I am in a situation where fmt is computed inside a function, and my 
 function executes in roughly 26 seconds when using the above 
 print_formatted(). If I cheat and pretend I know the format beforehand and 
 use @printf, the function executes in under one tenth of a second!

 My question:

 Once the format is known, is there a way to take advantage of this fact 
 performance-wise? What I mean is something of the form

print_formatted(args...) = @eval @printf($fmt, $(args...));  # now fmt 
 is known and fixed

 Unfortunately, defining the above after fmt has been computed isn't any 
 faster than the first print_formatted. Is there a better option?

 Falling back on my old c_printf (that calls libc directly; see a previous 
 message in this thread) proves to be the fastest option so far after 
 @printf, with a run time of just under one second.

 Thanks!


 On Sunday, April 13, 2014 at 6:22:58 PM UTC-4, Stefan Karpinski wrote:

 Please don't do this – or if you do and your program is amazingly slow, 
 then consider yourself warned. You can define a custom formatting function 
 pretty easily:

 julia fmt = %8.1e
 %8.1e

 julia @eval dofmt(x) = @sprintf($fmt, x)
 dofmt (generic function with 1 method)

 julia dofmt(1)
  1.0e+00

 julia dofmt(123.456)
  1.2e+02


 The difference is that you compile the function definition with eval 
 *once* and then call it many times, rather than calling eval every time you 
 want to print something.
  

 On Sun, Apr 13, 2014 at 6:17 PM, Mike Innes mike.j...@gmail.com wrote:

 It occurs to me that, if you really need this, you can define

 sprintf(args...) = eval(:@sprintf($(args...)))

 It's not pretty or ideal in terms of performance, but it will do the job.

 fmt = %8.1e
 sprintf(fmt, 3.141) #=  3.1e+00

 On Sunday, 13 April 2014 22:47:12 UTC+1, Dominique Orban wrote:

 So what's the preferred Julia syntax to achieve what I meant here:

 julia fmt = %8.1e;
 julia @sprintf(fmt, 3.1415)
 ERROR: first or second argument must be a format string



 On Sunday, April 13, 2014 1:31:57 PM UTC-7, John Myles White wrote:

 As far as the macro is concerned, the splat isn’t executed: it’s just 
 additional syntax that gets taken in as a whole expression. 

 The contrast between how a function with splatting works and how a 
 macro with splatting works might be helpful: 

 julia function splat(a, b...) 
println(a) 
println(b) 
return 
end 
 splat (generic function with 2 methods) 

 julia splat(1, 2, 3) 
 1 
 (2,3) 

 julia splat(1, [2, 3]...) 
 1 
 (2,3) 

 julia macro splat(a, b...) 
   println(a) 
   println(b) 
   :() 
   end 

 julia @splat(1, 2, 3) 
 1 
 (2,3) 
 () 

 julia @splat(1, [2, 3]...) 
 1 
 (:([2,3]...),) 
 () 


  — John 

 On Apr 13, 2014, at 1:20 PM, Jeff Waller trut...@gmail.com wrote: 

  Likewise I am having problems with @sprintf 
  
  Is this because @sprinf is macro?  The shorthand of expanding a 
 printf with format the contents of an array is desirable.  I would have 
 expected the ... operator to take an array of length 2 and turn it into 2 
 arguments. 
  
  julia X=[1 2] 
 1x2 Array{Int64,2}: 
  1  2 
  
  julia @sprintf(%d%d,1,2) 
  12 
  
  julia @sprintf(%d%d,X...) 
  ERROR: @sprintf: wrong number of arguments 
  
  julia @sprintf(%d%d,(1,2)...) 
  ERROR: @sprintf: wrong number of arguments 
  
  julia @sprintf(%d,X...) 
  ERROR: error compiling anonymous: unsupported or misplaced 
 expression ... in function anonymous 
  in sprint at io.jl:460 
  in sprint at io.jl:464 
  
  julia macroexpand(quote @sprintf(%d%d,X...) end) 
  :($(Expr(:error, ErrorException(@sprintf: wrong number of 
 arguments 
  




Re: [julia-users] @async weirdness

2015-03-10 Thread Amit Murthy
What about if you don't print t .

t = @async (println(foo);println(bar); println(baz));

On Wed, Mar 11, 2015 at 9:31 AM, Sam L sam.len...@gmail.com wrote:

 Same thing on arch linux actually:

   | | |_| | | | (_| |  |  Version 0.3.7-pre+15 (2015-03-02 23:43 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit 0f0b136 (8 days old release-0.3)
 |__/   |  x86_64-unknown-linux-gnu

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x03c57080bar


 julia
 _



 On Tuesday, March 10, 2015 at 8:59:52 PM UTC-7, Sam L wrote:

 I see the behavior on OS X.  It also occurs with three println's.

   | | |_| | | | (_| |  |  Version 0.3.7-pre+1 (2015-02-17 22:12 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit d15f183* (21 days old release-0.3)
 |__/   |  x86_64-apple-darwin13.4.0

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x7fa0faf0e520bar


 julia
 _

 The _ indicates the cursor position after running the line of code. I hit
 return only once after the first line starting with 't = @async...', and I
 got two blank lines after Task was displayed, before the julia prompt, and
 the cursor ended up in the first column on a new line after the julia
 prompt.


 On Tuesday, March 10, 2015 at 8:17:30 PM UTC-7, Amit Murthy wrote:

 Works fine on Linux.



 On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjart...@gmail.com wrote:

 in my continuing quest to understand Julia tasks, i have created the
 following contrived example which does not behave as i would expect. can
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo)
  println(bar)
  end

 printfoobar (generic function with 1 method)

 julia printfoobar()   # great, it works
 foo
 bar

 julia println(honey); println(wagon)   # no surprise again
 honey
 wagon

 julia t = @async (println(honey); println(wagon))  #  works too,
 modulo 'Task' being inbetween
 honey
 Task (queued) @0x7fb59e832500wagon

 julia t = @async printfoobar()   # ditto:  foo and bar both printed,
 albeit with 'Task' inbetween
 foo
 Task (queued) @0x7fb59f2e1720bar

 julia t = @async (println(honey); printfoobar(); println(wagon))
 # WHERE ARE bar AND wagon ???
 honey
 Task (queued) @0x7fb59f2e1840foo

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t)
 true

 is it that println(foo) and println(wagon) never get executed?  or
 that the output stream is just not making it to the REPL?  this is in 0.3.6
 by the way.  similar things happen on a 0 day old master.





Re: [julia-users] @async weirdness

2015-03-10 Thread Sam Lendle
Baz shows up then.  From OS X:

julia t = @async (println(foo);println(bar); println(baz));
foo

julia bar
julia baz
_



On Tue, Mar 10, 2015 at 9:28 PM, Amit Murthy amit.mur...@gmail.com wrote:

 What about if you don't print t .

 t = @async (println(foo);println(bar); println(baz));

 On Wed, Mar 11, 2015 at 9:31 AM, Sam L sam.len...@gmail.com wrote:

 Same thing on arch linux actually:

   | | |_| | | | (_| |  |  Version 0.3.7-pre+15 (2015-03-02 23:43 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit 0f0b136 (8 days old release-0.3)
 |__/   |  x86_64-unknown-linux-gnu

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x03c57080bar


 julia
 _



 On Tuesday, March 10, 2015 at 8:59:52 PM UTC-7, Sam L wrote:

 I see the behavior on OS X.  It also occurs with three println's.

   | | |_| | | | (_| |  |  Version 0.3.7-pre+1 (2015-02-17 22:12 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit d15f183* (21 days old release-0.3)
 |__/   |  x86_64-apple-darwin13.4.0

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x7fa0faf0e520bar


 julia
 _

 The _ indicates the cursor position after running the line of code. I
 hit return only once after the first line starting with 't = @async...',
 and I got two blank lines after Task was displayed, before the julia
 prompt, and the cursor ended up in the first column on a new line after the
 julia prompt.


 On Tuesday, March 10, 2015 at 8:17:30 PM UTC-7, Amit Murthy wrote:

 Works fine on Linux.



 On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjart...@gmail.com
 wrote:

 in my continuing quest to understand Julia tasks, i have created the
 following contrived example which does not behave as i would expect. can
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo)
  println(bar)
  end

 printfoobar (generic function with 1 method)

 julia printfoobar()   # great, it works
 foo
 bar

 julia println(honey); println(wagon)   # no surprise again
 honey
 wagon

 julia t = @async (println(honey); println(wagon))  #  works too,
 modulo 'Task' being inbetween
 honey
 Task (queued) @0x7fb59e832500wagon

 julia t = @async printfoobar()   # ditto:  foo and bar both printed,
 albeit with 'Task' inbetween
 foo
 Task (queued) @0x7fb59f2e1720bar

 julia t = @async (println(honey); printfoobar(); println(wagon))
   # WHERE ARE bar AND wagon ???
 honey
 Task (queued) @0x7fb59f2e1840foo

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t)
 true

 is it that println(foo) and println(wagon) never get executed?  or
 that the output stream is just not making it to the REPL?  this is in 
 0.3.6
 by the way.  similar things happen on a 0 day old master.






Re: [julia-users] @async weirdness

2015-03-10 Thread elextr
And same on 0.3.6 from the PPA on Linux

  | | |_| | | | (_| |  |  Version 0.3.6 (2015-01-08 22:33 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org release
|__/   |  x86_64-linux-gnu

julia t = @async (println(foo);println(bar); println(baz))
foo
Task (queued) @0x040bed80bar


julia 
julia 

Note only one return gave two julia prompts

Cheers
Lex

On Wednesday, March 11, 2015 at 2:01:48 PM UTC+10, Sam L wrote:

 Same thing on arch linux actually:

   | | |_| | | | (_| |  |  Version 0.3.7-pre+15 (2015-03-02 23:43 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit 0f0b136 (8 days old release-0.3)
 |__/   |  x86_64-unknown-linux-gnu

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x03c57080bar


 julia
 _



 On Tuesday, March 10, 2015 at 8:59:52 PM UTC-7, Sam L wrote:

 I see the behavior on OS X.  It also occurs with three println's.

   | | |_| | | | (_| |  |  Version 0.3.7-pre+1 (2015-02-17 22:12 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit d15f183* (21 days old release-0.3)
 |__/   |  x86_64-apple-darwin13.4.0

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x7fa0faf0e520bar


 julia
 _

 The _ indicates the cursor position after running the line of code. I hit 
 return only once after the first line starting with 't = @async...', and I 
 got two blank lines after Task was displayed, before the julia prompt, and 
 the cursor ended up in the first column on a new line after the julia 
 prompt. 


 On Tuesday, March 10, 2015 at 8:17:30 PM UTC-7, Amit Murthy wrote:

 Works fine on Linux. 



 On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjart...@gmail.com wrote:

 in my continuing quest to understand Julia tasks, i have created the 
 following contrived example which does not behave as i would expect. can 
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo) 
  println(bar) 
  end 

 printfoobar (generic function with 1 method) 

 julia printfoobar()   # great, it works
 foo 
 bar 

 julia println(honey); println(wagon)   # no surprise again
 honey 
 wagon 

 julia t = @async (println(honey); println(wagon))  #  works too, 
 modulo 'Task' being inbetween
 honey 
 Task (queued) @0x7fb59e832500wagon 

 julia t = @async printfoobar()   # ditto:  foo and bar both printed, 
 albeit with 'Task' inbetween
 foo 
 Task (queued) @0x7fb59f2e1720bar 

 julia t = @async (println(honey); printfoobar(); println(wagon))   
 # WHERE ARE bar AND wagon ???
 honey 
 Task (queued) @0x7fb59f2e1840foo 

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t) 
 true

 is it that println(foo) and println(wagon) never get executed?  or 
 that the output stream is just not making it to the REPL?  this is in 
 0.3.6 
 by the way.  similar things happen on a 0 day old master.




Re: [julia-users] @async weirdness

2015-03-10 Thread Amit Murthy
Works fine on Linux.



On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjarthu...@gmail.com wrote:

 in my continuing quest to understand Julia tasks, i have created the
 following contrived example which does not behave as i would expect. can
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo)
  println(bar)
  end

 printfoobar (generic function with 1 method)

 julia printfoobar()   # great, it works
 foo
 bar

 julia println(honey); println(wagon)   # no surprise again
 honey
 wagon

 julia t = @async (println(honey); println(wagon))  #  works too,
 modulo 'Task' being inbetween
 honey
 Task (queued) @0x7fb59e832500wagon

 julia t = @async printfoobar()   # ditto:  foo and bar both printed,
 albeit with 'Task' inbetween
 foo
 Task (queued) @0x7fb59f2e1720bar

 julia t = @async (println(honey); printfoobar(); println(wagon))   #
 WHERE ARE bar AND wagon ???
 honey
 Task (queued) @0x7fb59f2e1840foo

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t)
 true

 is it that println(foo) and println(wagon) never get executed?  or
 that the output stream is just not making it to the REPL?  this is in 0.3.6
 by the way.  similar things happen on a 0 day old master.



Re: [julia-users] @async weirdness

2015-03-10 Thread Sam L
Same thing on arch linux actually:

  | | |_| | | | (_| |  |  Version 0.3.7-pre+15 (2015-03-02 23:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 0f0b136 (8 days old release-0.3)
|__/   |  x86_64-unknown-linux-gnu

julia t = @async (println(foo);println(bar); println(baz))
foo
Task (queued) @0x03c57080bar


julia
_



On Tuesday, March 10, 2015 at 8:59:52 PM UTC-7, Sam L wrote:

 I see the behavior on OS X.  It also occurs with three println's.

   | | |_| | | | (_| |  |  Version 0.3.7-pre+1 (2015-02-17 22:12 UTC)
  _/ |\__'_|_|_|\__'_|  |  Commit d15f183* (21 days old release-0.3)
 |__/   |  x86_64-apple-darwin13.4.0

 julia t = @async (println(foo);println(bar); println(baz))
 foo
 Task (queued) @0x7fa0faf0e520bar


 julia
 _

 The _ indicates the cursor position after running the line of code. I hit 
 return only once after the first line starting with 't = @async...', and I 
 got two blank lines after Task was displayed, before the julia prompt, and 
 the cursor ended up in the first column on a new line after the julia 
 prompt. 


 On Tuesday, March 10, 2015 at 8:17:30 PM UTC-7, Amit Murthy wrote:

 Works fine on Linux. 



 On Tue, Mar 10, 2015 at 11:28 PM, Ben Arthur bjart...@gmail.com wrote:

 in my continuing quest to understand Julia tasks, i have created the 
 following contrived example which does not behave as i would expect. can 
 anyone help explain please? thanks in advance.

 julia function printfoobar()
  println(foo) 
  println(bar) 
  end 

 printfoobar (generic function with 1 method) 

 julia printfoobar()   # great, it works
 foo 
 bar 

 julia println(honey); println(wagon)   # no surprise again
 honey 
 wagon 

 julia t = @async (println(honey); println(wagon))  #  works too, 
 modulo 'Task' being inbetween
 honey 
 Task (queued) @0x7fb59e832500wagon 

 julia t = @async printfoobar()   # ditto:  foo and bar both printed, 
 albeit with 'Task' inbetween
 foo 
 Task (queued) @0x7fb59f2e1720bar 

 julia t = @async (println(honey); printfoobar(); println(wagon))   
 # WHERE ARE bar AND wagon ???
 honey 
 Task (queued) @0x7fb59f2e1840foo 

 julia # ENTER  #nope, they still don't appear

 julia # ENTER

 julia # ENTER

 julia wait(t)   # nope, still no further printed output

 julia yield()   # still no joy

 julia istaskdone(t) 
 true

 is it that println(foo) and println(wagon) never get executed?  or 
 that the output stream is just not making it to the REPL?  this is in 0.3.6 
 by the way.  similar things happen on a 0 day old master.




Re: [julia-users] Re: Julia T-shirt and Sticker

2015-03-10 Thread Ismael VC
 Any sufficiently advanced programing language is indistinguishable from
Julia

That's so much better Paulo! [?]

On Tue, Mar 10, 2015 at 6:44 AM, Michele Zaffalon 
michele.zaffa...@gmail.com wrote:

 No segfaults means zero distance?

 On Tue, Mar 10, 2015 at 1:22 PM, Mike Innes mike.j.in...@gmail.com
 wrote:

 The distance between Julia and insanity is measured only in segfaults





[julia-users] How to embed Julia into Visual Studoi 2013?

2015-03-10 Thread Yuhui ZHI
Hello everyone,

I have a question: how to embed Julia into VS2013?

I have read 
this: 
https://github.com/JuliaLang/julia/blob/release-0.3/doc/manual/embedding.rst

But I still have no idea.

I am using vs2013 in the system of Windows10.
I have created a project and now I want to use Julia in it. So I want to 
know how to embed Julia here.


Could someone help me???

thanks a lot!


[julia-users] Re: Julia T-shirt and Sticker

2015-03-10 Thread Daniel Carrera


On Monday, 9 March 2015 19:20:11 UTC+1, Paulo Jabardo wrote:

 Well, if that is the case, why not go one step further:
 Any sufficiently advanced programing language is indistinguishable from 
 Julia


+1

I would buy that t-shirt. 


[julia-users] Re: Sparse matrix with diagonal index

2015-03-10 Thread Amit Jamadagni
Just was curious why it was not matching with the implementations in python 
library. I was working on the angular momentum operators and relating stuff 
from QuTiP which does similar stuff in python. 

On Wednesday, March 11, 2015 at 1:23:55 AM UTC+5:30, Steven G. Johnson 
wrote:



 On Tuesday, March 10, 2015 at 2:40:24 PM UTC-4, Amit Jamadagni wrote:

 Thank you very much for the response.
 But the behavior of the same in scipy is different i.e., it omits the 
 elements. Is this not the expected behavior ?? 


 Why would you expect the function to silently ignore some of your inputs? 



Re: [julia-users] How to unpack a .tar file in Julia?

2015-03-10 Thread Stefan Karpinski
I would just shell out to the tar command and then work with the untarred
directory.

On Tue, Mar 10, 2015 at 4:05 PM, Weijian Zhang zweiji...@gmail.com wrote:

 Hello,

 I have a .tar.gz file. With GZip.jl, I can write code to unzip it to a
 .tar file.
 But how can I unpack this .tar file in Julia?

 Thanks,

 Weijian




[julia-users] Re: Sparse matrix with diagonal index

2015-03-10 Thread Steven G. Johnson



 But when I give in 
 julia spdiagm(x, 1, length(x), length(x))
 ERROR: BoundsError
  in sparse at sparse/csparse.jl:50
  in spdiagm at sparse/sparsematrix.jl:2133
  in spdiagm at sparse/sparsematrix.jl:2141

 I get the above error. Any leads on this would be great. Thanks.


You need to use length(x)+1.   If you have an MxM matrix, then the k-th 
diagonal has M-k entries.   You are supplying M entries for the 1st 
diagonal, which is too many. 


[julia-users] Re: Sparse matrix with diagonal index

2015-03-10 Thread Amit Jamadagni
Thank you very much for the response.
But the behavior of the same in scipy is different i.e., it omits the 
elements. Is this not the expected behavior ?? The same result is as 
follows using scipy and numpy :
 import numpy as np
 import scipy.sparse as sp
 m = np.arange(3, -4, -1)
 t = sp.spdiags(m,1,len(m),len(m))
 t
7x7 sparse matrix of type 'type 'numpy.int64''
with 6 stored elements (1 diagonals) in DIAgonal format
 t.toarray()
array([[ 0,  2,  0,  0,  0,  0,  0],
   [ 0,  0,  1,  0,  0,  0,  0],
   [ 0,  0,  0,  0,  0,  0,  0],
   [ 0,  0,  0,  0, -1,  0,  0],
   [ 0,  0,  0,  0,  0, -2,  0],
   [ 0,  0,  0,  0,  0,  0, -3],
   [ 0,  0,  0,  0,  0,  0,  0]])
 

On Tuesday, March 10, 2015 at 11:58:39 PM UTC+5:30, Steven G. Johnson wrote:


 But when I give in 
 julia spdiagm(x, 1, length(x), length(x))
 ERROR: BoundsError
  in sparse at sparse/csparse.jl:50
  in spdiagm at sparse/sparsematrix.jl:2133
  in spdiagm at sparse/sparsematrix.jl:2141

 I get the above error. Any leads on this would be great. Thanks.


 You need to use length(x)+1.   If you have an MxM matrix, then the k-th 
 diagonal has M-k entries.   You are supplying M entries for the 1st 
 diagonal, which is too many. 



[julia-users] How to unpack a .tar file in Julia?

2015-03-10 Thread Weijian Zhang
Hello,

I have a .tar.gz file. With GZip.jl, I can write code to unzip it to a .tar 
file.
But how can I unpack this .tar file in Julia?

Thanks,

Weijian



Re: [julia-users] Intel Xeon Phi support?

2015-03-10 Thread Jeff Waller


On Tuesday, March 10, 2015 at 2:07:34 PM UTC-4, Viral Shah wrote:

 LLVM support for KNL is already in place. So yes, it will come quickly, 
 but in a released version of Julia, that is certainly no earlier than 0.5. 
 It is also quite likely that we need good multi-threading support to ensure 
 a good experience for KNL - which is also happening simultaneously. 

 I am personally quite excited about the socketable KNL, and the 
 possibilities with Julia. 

 -viral 


You and me both.  For though the Tesla will probably continue to enjoy some 
edge for Neural Networks, that's not the only thing going.  Something 
balanced that marries deep leaning and traditional stuff is going to be a 
cool place to be. 


[julia-users] Creating custom distribution

2015-03-10 Thread Benjamin Deonovic
I'm trying to create a custom distribution. I define:

immutable myDist : DiscreteMultivariateDistribution
  #code
end




function _logpdf{T:Real}(d::myDist, X::AbstractVector{T})
  # code
end


_pdf(d::myDist, X::AbstractVector) = exp(_logpdf(d, X))



I can succesfully create a distribution (i.e. d = myDist(...)) and I can 
directly call _logpdf(d,x) on some data x. However, if I try to call 
logpdf(d,x) (which is defined by the Distributions package) I get 

ERROR: `_logpdf` has no method matching _logpdf(::myDist, ::Array{Int64,1})
 in logpdf at 
/Users/bdeonovic/.julia/v0.3/Distributions/src/multivariates.jl:66

why is this??


[julia-users] ERROR: `convert` has no method matching convert(::Type{Int64...}, ::Int64)

2015-03-10 Thread Maxwell
Hello folks,

I am trying to run a little bootstrap in Julia using pmap and I am getting 
the following error from each process:

fatal error on fatal error on fatal error on fatal error on fatal error on 
fatal error on fatal error on fatal error on fatal error on fatal error on 
fatal error on fatal error on fatal error on fatal error on fatal error on 
2141612: : : : 46: : 8: 91071131315: : : : : : : 5: ERROR: `convert` has no 
method matching convert(::Type{Int64...}, ::Int64)
ERROR: `convert` has no method matching convert(::Type{Int64...}, ::Int64)
ERROR: `convert` has no method matching convert(::Type{Int64...}, ::Int64)
ERROR: `convert` has no method matching convert(::Type{Int64...}, ::Int64)
ERROR: `convert` has no method matching convert(::Type{Int64...}, ::Int64)

However, running the code for one case works just perfectly. I am been 
scratching my head about this for few days now. Any help will be greatly 
appreciated.
Find attached my code.

Thanks.




  _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type help() for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.3.6
 _/ |\__'_|_|_|\__'_|  |  
|__/   |  x86_64-redhat-linux




Boot_code.jl
Description: Binary data


[julia-users] for and function don't work in the same way in terms of scope

2015-03-10 Thread Wendell Zheng
*Input 1:*
y = 0
function foo()
y = 10
end
foo()
y

*Output 1:*
0

*Input 2:*
y = 0
for i = 1:1
y = 10 
end
y

*Output 2:*
10

In the first example, y introduces a local variable. 
In the second example, y is still a global variable.

This is not consistent to what the official document said.

I tried these examples in JuliaBox.


Re: [julia-users] Specifying return type of a function

2015-03-10 Thread Shivkumar Chandrasekaran
Thanks! I guess I will put the return type in the calling code instead. 
Nuisance though.

On Tuesday, March 10, 2015 at 2:39:37 PM UTC-7, Mauro wrote:

 Sadly not.  Have a look at 
 https://github.com/JuliaLang/julia/issues/1090 
 and 
 https://github.com/JuliaLang/julia/pull/10269 

 The complication in Julia is that with its multimethods, it is not so 
 clear what the return type of a generic function actually means. 

 On Tue, 2015-03-10 at 21:24, Shivkumar Chandrasekaran 00s...@gmail.com 
 javascript: wrote: 
  I am new to Julia, so forgive the elementary question, but I could not 
 seem 
  to find the answer in the docs or by googling the news group. 
  
  Is it possible to specify the return type of a function in Julia? 
  
  Thanks. 
  
  --shiv-- 



Re: [julia-users] Specifying return type of a function

2015-03-10 Thread Milan Bouchet-Valat
Le mardi 10 mars 2015 à 15:12 -0700, Shivkumar Chandrasekaran a écrit :
 Thanks! I guess I will put the return type in the calling code
 instead. Nuisance though.
But you shouldn't need to. Julia is able to find out what the return
type is as long as you write type-stable code. Can you give more details
about what you're trying to achieve?


Regards

 On Tuesday, March 10, 2015 at 2:39:37 PM UTC-7, Mauro wrote:
 Sadly not.  Have a look at 
 https://github.com/JuliaLang/julia/issues/1090 
 and 
 https://github.com/JuliaLang/julia/pull/10269 
 
 The complication in Julia is that with its multimethods, it is
 not so 
 clear what the return type of a generic function actually
 means. 
 
 On Tue, 2015-03-10 at 21:24, Shivkumar Chandrasekaran
 00s...@gmail.com wrote: 
  I am new to Julia, so forgive the elementary question, but I
 could not seem 
  to find the answer in the docs or by googling the news
 group. 
  
  Is it possible to specify the return type of a function in
 Julia? 
  
  Thanks. 
  
  --shiv-- 
 



[julia-users] Re: Creating custom distribution

2015-03-10 Thread Sam L
Your _logpdf is not the same as Distributions._logpdf, so when you define 
it on ::myDist, you're not extending Distributions.jl's function.  You can 
either import it with import Distributions._logpdf and define it as you do 
above, or define it as

function *Distributions*._logpdf{T:Real}(d::myDist, X::AbstractVector{T})
  # code
end

Sam

On Tuesday, March 10, 2015 at 12:58:38 PM UTC-7, Benjamin Deonovic wrote:

 I'm trying to create a custom distribution. I define:

 immutable myDist : DiscreteMultivariateDistribution
   #code
 end




 function _logpdf{T:Real}(d::myDist, X::AbstractVector{T})
   # code
 end


 _pdf(d::myDist, X::AbstractVector) = exp(_logpdf(d, X))



 I can succesfully create a distribution (i.e. d = myDist(...)) and I can 
 directly call _logpdf(d,x) on some data x. However, if I try to call 
 logpdf(d,x) (which is defined by the Distributions package) I get 

 ERROR: `_logpdf` has no method matching _logpdf(::myDist, ::Array{Int64,1})
  in logpdf at 
 /Users/bdeonovic/.julia/v0.3/Distributions/src/multivariates.jl:66

 why is this??



[julia-users] Re: Strange behaviour

2015-03-10 Thread David van Leeuwen
Hello,

On Friday, March 6, 2015 at 2:22:42 AM UTC+1, Tony Kelman wrote:

  I suppose this is related to + and - being unary operators?

 Ding ding. Unfortunately space being the horizontal concatenation operator 
 means some operations parse very differently and in highly 
 whitespace-sensitive ways depending whether they are inside or outside an 
 array literal. Would be nice if that were not the case, but I think we'd 
 need another delimiter character aside from , or ; to really separate 
 horizontal concatenation from vertical concatenation from list construction.

 I've always found the space as operator a kind-of-upsetting thing in 
Julia.  (I refused to use Python---to my own disadvantage---for many years 
because there are semantics in the amount of space used, but I finally got 
over that.)  

Is it really necessary to have separate operators for horizontal and 
vertical list construction?  In most other respects, Julia seems not to 
treat the second dimension really special.  E.g., I've argued for `nrow()` 
and `ncol()` because---to me---this is more intuitive than the `size(, 
dim)`, but it was very clear in the discussions that this was a wrong way 
to think about arrays.  So now I actually got used to `size()`.  

Do we really use literal matrix construction that often in code?  I guess 
one would use it for examples, but in these cases, can't we just `hcat()` 
the columns? 

---david
 

 julia j=2; [ 1 +j ]
 1x2 Array{Int64,2}:
  1  2

 julia j=2; [ 1 + j ]
 1-element Array{Int64,1}:
  3

 julia j=2; 1 +j
 3

 julia j=2; 1 + j
 3


 On Thursday, March 5, 2015 at 4:56:20 PM UTC-8, Amuthan A. Ramabathiran 
 wrote:

 Not sure if this has been discussed earlier... can someone explain whats 
 happening here?

 julia b = [ 1 +j for j = 1:5 ]
 ERROR: syntax: invalid comprehension syntax

 julia b = [ 1 + j for j = 1:5 ]
 5-element Array{Int64,1}:
  2
  3
  4
  5
  6


 This happens with both + and -, but not with * or /. I suppose this is 
 related to + and - being unary operators?

 Thanks!
 Amuthan.



[julia-users] Error array could not be broadcast to a common size

2015-03-10 Thread Rafael Guariento
Hi I am trying to run the following code but I get an error when I try to 
run the model (evaluate the result variable (calling the ODE23))

the error is: Error array could not be broadcast to a common size

Does anyone have any idea why? Thanks in advance


# Load libraries
using ODE
using DataFrames
using Gadfly

# Define the model
# Has to return a column vector
function SIR(t,x,p)
S=x[1]
I=x[2]
R=x[3]
beta=p[1]
gamma=p[2]
N=S+I
dS=-beta*S*I/N
dI=beta*S*I/N-gamma*I
dR=gamma*I
return([dS;dI;dR])
end

# Initialise model
t = linspace(0,500,101);
inits=[,1,0];
p=[0.1,0.05];


# Run model
result=ode23((t,x)- SIR(t,x,p),t,inits);






Re: [julia-users] Re: Create formatted string

2015-03-10 Thread Dominique Orban
This is an old question about computed format strings, but it's still 
biting me. I've been following your suggestion and I defined

print_formatted(fmt, args...) = @eval @printf($fmt, $(args...))

Now I am in a situation where fmt is computed inside a function, and my 
function executes in roughly 26 seconds when using the above 
print_formatted(). If I cheat and pretend I know the format beforehand and 
use @printf, the function executes in under one tenth of a second!

My question:

Once the format is known, is there a way to take advantage of this fact 
performance-wise? What I mean is something of the form

   print_formatted(args...) = @eval @printf($fmt, $(args...));  # now fmt 
is known and fixed

Unfortunately, defining the above after fmt has been computed isn't any 
faster than the first print_formatted. Is there a better option?

Falling back on my old c_printf (that calls libc directly; see a previous 
message in this thread) proves to be the fastest option so far after 
@printf, with a run time of just under one second.

Thanks!


On Sunday, April 13, 2014 at 6:22:58 PM UTC-4, Stefan Karpinski wrote:

 Please don't do this – or if you do and your program is amazingly slow, 
 then consider yourself warned. You can define a custom formatting function 
 pretty easily:

 julia fmt = %8.1e
 %8.1e

 julia @eval dofmt(x) = @sprintf($fmt, x)
 dofmt (generic function with 1 method)

 julia dofmt(1)
  1.0e+00

 julia dofmt(123.456)
  1.2e+02


 The difference is that you compile the function definition with eval 
 *once* and then call it many times, rather than calling eval every time you 
 want to print something.
  

 On Sun, Apr 13, 2014 at 6:17 PM, Mike Innes mike.j...@gmail.com 
 javascript: wrote:

 It occurs to me that, if you really need this, you can define

 sprintf(args...) = eval(:@sprintf($(args...)))

 It's not pretty or ideal in terms of performance, but it will do the job.

 fmt = %8.1e
 sprintf(fmt, 3.141) #=  3.1e+00

 On Sunday, 13 April 2014 22:47:12 UTC+1, Dominique Orban wrote:

 So what's the preferred Julia syntax to achieve what I meant here:

 julia fmt = %8.1e;
 julia @sprintf(fmt, 3.1415)
 ERROR: first or second argument must be a format string



 On Sunday, April 13, 2014 1:31:57 PM UTC-7, John Myles White wrote:

 As far as the macro is concerned, the splat isn’t executed: it’s just 
 additional syntax that gets taken in as a whole expression. 

 The contrast between how a function with splatting works and how a 
 macro with splatting works might be helpful: 

 julia function splat(a, b...) 
println(a) 
println(b) 
return 
end 
 splat (generic function with 2 methods) 

 julia splat(1, 2, 3) 
 1 
 (2,3) 

 julia splat(1, [2, 3]...) 
 1 
 (2,3) 

 julia macro splat(a, b...) 
   println(a) 
   println(b) 
   :() 
   end 

 julia @splat(1, 2, 3) 
 1 
 (2,3) 
 () 

 julia @splat(1, [2, 3]...) 
 1 
 (:([2,3]...),) 
 () 


  — John 

 On Apr 13, 2014, at 1:20 PM, Jeff Waller trut...@gmail.com wrote: 

  Likewise I am having problems with @sprintf 
  
  Is this because @sprinf is macro?  The shorthand of expanding a 
 printf with format the contents of an array is desirable.  I would have 
 expected the ... operator to take an array of length 2 and turn it into 2 
 arguments. 
  
  julia X=[1 2] 
 1x2 Array{Int64,2}: 
  1  2 
  
  julia @sprintf(%d%d,1,2) 
  12 
  
  julia @sprintf(%d%d,X...) 
  ERROR: @sprintf: wrong number of arguments 
  
  julia @sprintf(%d%d,(1,2)...) 
  ERROR: @sprintf: wrong number of arguments 
  
  julia @sprintf(%d,X...) 
  ERROR: error compiling anonymous: unsupported or misplaced 
 expression ... in function anonymous 
  in sprint at io.jl:460 
  in sprint at io.jl:464 
  
  julia macroexpand(quote @sprintf(%d%d,X...) end) 
  :($(Expr(:error, ErrorException(@sprintf: wrong number of 
 arguments