Re: [julia-users] Re: navigating the help & documentation system

2015-07-15 Thread Forrest Curo
Eventually a search for Cairo.jl information led me blundering into the
following two pieces (which should be added to the tutorials under a heading
like "Graphics Usage in Julia"):

http://julialang.org/blog/2013/05/graphical-user-interfaces-part1/
http://julialang.org/blog/2013/05/graphical-user-interfaces-part2/

These seem quite necessary to anyone not already familiar with the subject!

On Wed, Jul 15, 2015 at 2:06 AM, Andreas Lobinger 
wrote:

> For 2)
> 2) A good lightweight graphics package for such simple-minded tasks as a
> 2D game board with round pieces on a square grid.
> The lowest common denominator for just drawing would be Cairo.jl, a
> declarative way to draw something would be Compose.jl (which then does the
> drawing via Cairo.jl).
>
>
>


[julia-users] Re: Proposal to internationalize the Julia web page.

2015-07-15 Thread Jeffrey Sarnoff
⟅1⟆ for the 3rd language

On Wednesday, July 15, 2015 at 10:05:59 PM UTC-4, Jeffrey Sarnoff wrote:
>
> +1
>
> On Wednesday, July 15, 2015 at 8:54:37 PM UTC-4, Ismael VC wrote:
>>
>> You can see the pull request here: 
>> https://github.com/JuliaLang/julialang.github.com/pull/252
>>
>> Working demo here: http://julialanges.github.io
>>
>> Please let me know what do you think.
>>
>

[julia-users] Re: Proposal to internationalize the Julia web page.

2015-07-15 Thread Jeffrey Sarnoff
+1

On Wednesday, July 15, 2015 at 8:54:37 PM UTC-4, Ismael VC wrote:
>
> You can see the pull request here: 
> https://github.com/JuliaLang/julialang.github.com/pull/252
>
> Working demo here: http://julialanges.github.io
>
> Please let me know what do you think.
>


[julia-users] Proposal to internationalize the Julia web page.

2015-07-15 Thread Ismael VC
You can see the pull request 
here: https://github.com/JuliaLang/julialang.github.com/pull/252

Working demo here: http://julialanges.github.io

Please let me know what do you think.


Re: [julia-users] scoping rule help for functions within functions

2015-07-15 Thread Ethan Anderes


Thanks Mauro. I took a look at your new manual entry for scoping rules. 
Very nice. It clears up a lot of questions. I still have two more.

Question 1) In your post you say that….

 The rule is that inside a function any variable assignment
which would write to a *global* variable, makes that variable local. 

I guess I still don’t understand how the nested function scoping behavior 
is described by the above sentence. Maybe I don’t understand what you mean 
by *global* and how I could determine if an assignment “would write to a 
*global* variable”. My best attempt at describing this behavior in my own 
way would be as follows: the assignment x = repmat(y.', 2, 1) within mesh 
within foo treats x as “local-to-foo” and “global-to-mesh”. Is this 
consistent with what your saying?

Question 2) What advantage is there for changing the scoping rules for 
nested functions? I did notice the following example in your manual but it 
is not clear to me how it (or if it was intended to) explain the usefulness 
of different scoping rules for nested functions.

even(n) = n == 0 ? true  :  odd(n-1)
odd(n)  = n == 0 ? false : even(n-1)

julia> even(3)
false

julia> odd(3)
true


On Wednesday, July 15, 2015 at 1:29:40 PM UTC-7, Mauro wrote:

This is the hard local scope of functions, which is currently not 
> documented.  The rule is that inside a function any variable assignment 
> which would write to a *global* variable, makes that variable local. 
> See below for inline comments. 
>
> Funnily enough, I just rewrote the scope section of the manual which now 
> includes that rule.  You seem uniquely qualified to read it and give 
> feedback: 
> https://github.com/JuliaLang/julia/pull/12146 
> a semi-rendered version is here: 
>
> https://github.com/mauro3/julia/blob/41911d96d86397168ade1f39914a8d7ed1653558/doc/manual/variables-and-scoping.rst#id7
>  
>
> Thanks! 
>
>
> On Wed, 2015-07-15 at 20:40, Ethan Anderes  > wrote: 
> > Hi Everyone. I hope this isn’t a stupid question but I can’t seem to 
> > understand the following 
> > scoping behavior. The basic story is that mesh in the following two 
> > examples behaves differently when defined in global scope vrs within a 
> > function. I’m worried that I’m completely ignorant of how functions work 
> > within other functions. Some help would be much appreciated. Thanks! 
> > 
> > In this block of code mesh is defined as a global variable. 
> > 
> > julia> mesh(y) = (x = repmat(y.', 2, 1); return x) 
> > mesh (generic function with 1 method) 
>
> Here x is implicitly local as assigning to it would result in a modified 
> global. 
>
> > julia> x = mesh(1:2); 
> > 
> > julia> y = mesh(2:3); 
>
> Thus above call will *not* modify x. 
>
> > julia> x 
> > 2x2 Array{Int64,2}: 
> >  1  2 
> >  1  2 
> > 
> > When I quit, restart Julia and define mesh within foo I get a different 
> > answer. 
> > 
> > julia> function foo() 
> > mesh(y) = (x = repmat(y.', 2, 1); return x) 
>
> Here x is inherited from the scope of foo as x is a local variable. 
>
> > x = mesh(1:2) 
> > y = mesh(2:3) # <- this line is necessary to see the effect 
>
> Thus above call will modify x. 
>
> > return x 
> > end 
> > foo (generic function with 1 method) 
> > 
> > julia> x = foo()  # <- different than the x in the global case. 
> > 2x2 Array{Int64,2}: 
> >  2  3 
> >  2  3 
> > 
> > Here is my version info 
> > 
> > julia> versioninfo() 
> > Julia Version 0.4.0-dev+5994 
> > Commit 8efc44d (2015-07-15 15:42 UTC) 
> > Platform Info: 
> >   System: Darwin (x86_64-apple-darwin14.4.0) 
> >   CPU: Intel(R) Core(TM) M-5Y51 CPU @ 1.10GHz 
> >   WORD_SIZE: 64 
> >   BLAS: libopenblas (USE64BITINT NO_AFFINITY HASWELL) 
> >   LAPACK: libopenblas 
> >   LIBM: libopenlibm 
> >   LLVM: libLLVM-3.3 
> > 
> > ​ 
>
> ​


[julia-users] Re: scoping rule help for functions within functions

2015-07-15 Thread Richard Dennis
Mauro,

are there any new scoping issues raised by the use of parallelization?  Are 
variables in global scope automatically available to different processors?

R 


Re: [julia-users] Re: Azure: Which VM?

2015-07-15 Thread Simon Byrne
Also, if you want to test on Windows, Microsoft have some prebuilt VM 
images available:
http://dev.modern.ie/tools/vms/#downloads
They don't come with a licence, so expire after 90 days, but they're quite 
handy for testing and debugging packages.

On Wednesday, 15 July 2015 21:26:55 UTC+1, Tony Kelman wrote:
>
> I don't see why not. I added a template to the Example.jl package that 
> could pretty easily be created automatically during Pkg.generate as well.
>
>
> On Wednesday, July 15, 2015 at 1:47:42 PM UTC-4, David Anthoff wrote:
>>
>> Maybe one thing that would help on the package ecosystem side is to add 
>> an appveyor.yml file in addition to a .travis.yml file to the template 
>> generated by Pkg.generate?
>>
>>  
>>
>> *From:* julia...@googlegroups.com [mailto:julia...@googlegroups.com] *On 
>> Behalf Of *Tony Kelman
>> *Sent:* Tuesday, July 14, 2015 6:49 PM
>> *To:* julia...@googlegroups.com
>> *Subject:* [julia-users] Re: Azure: Which VM?
>>
>>  
>>
>> If you're comfortable using Linux and have a choice in the matter, I 
>> would recommend avoiding using Julia on Windows if you can, especially for 
>> production purposes. Jameson, Isaiah, myself and others have put in a lot 
>> of effort to try to make things work, but there remains a lot of work to do 
>> across the package ecosystem (which was the point behind my JuliaCon talk), 
>> and there are a number of persistent bugs and usability issues that remain 
>> unsolved for a variety of reasons.
>>
>>
>>
>> On Tuesday, July 14, 2015 at 2:07:16 AM UTC-7, Eric Forgy wrote:
>>
>> I am about to do some experiments running Julia from an Azure VM. The 
>> first decision to make is "Which VM?" Azure has a "Quick Create" option for 
>> creating VM's and the options are:
>>
>> · Windows Server
>>
>>- Ubuntu Server
>>
>> · OpenLogic
>>
>>- Oracle Linux
>>
>> · CoreOS
>>
>>- SUSE Linux Enterprise Server
>>
>> I presume Azure has a good reason to shortlist these VM's (and shortlist 
>> them in that order) so unless there is a good reason to deviate, I'll 
>> probably choose one of the above.
>>
>>  
>>
>> If I look at the Julia downloads  page, 
>> I see the following selections:
>>
>> · Windows
>>
>>- Mac OS X
>>
>> · Ubuntu
>>
>>- Fedora/RHEL/CentOS/SL
>>
>> · Generic Linux
>>
>> I presume you guys have a good reason to shortlist these OSs (but not 
>> sure if the order is significant). I am agnostic about which OS to use, but 
>> I prefer to use one that has the best Julia support and will cause the 
>> least headaches, which presumably might be related to the OS most Julia 
>> developers are using.
>>
>>  
>>
>> If I could, I would probably prefer to run Julia on a Windows VM, but I 
>> get the impression Windows has the fewest Julia developers working on it 
>> (see Stephen's comment here 
>> )
>>  
>> so I predict there to be some pain points. Is that impression misguided? 
>> Any thoughts?
>>
>>  
>>
>> If not Windows, comparing the above two lists, I'd be inclined to 
>> consider using Ubuntu.
>>
>>  
>>
>> My use case is ultimately going to be distributed computing in the cloud 
>> (Azure) driven by a web app (ASP.NET MVC) with communication via REST 
>> and/or ZMQ.
>>
>>  
>>
>> In a nutshell:
>>
>> 1.  I have a slight preference for a Windows VM, but could be 
>> dissuaded if there is some pain to be expected. Is there?
>>
>> 2.  If not Windows, it seems Ubuntu VM is the next likely candidate 
>> with apparently solid support in the Julia community. Is that true?
>>
>> 3.  Any other recommendation better than the above two?
>>
>> Any thoughts would be appreciated. Thanks!
>>
>>

Re: [julia-users] scoping rule help for functions within functions

2015-07-15 Thread Mauro
This is the hard local scope of functions, which is currently not
documented.  The rule is that inside a function any variable assignment
which would write to a *global* variable, makes that variable local.
See below for inline comments.

Funnily enough, I just rewrote the scope section of the manual which now
includes that rule.  You seem uniquely qualified to read it and give
feedback:
https://github.com/JuliaLang/julia/pull/12146
a semi-rendered version is here:
https://github.com/mauro3/julia/blob/41911d96d86397168ade1f39914a8d7ed1653558/doc/manual/variables-and-scoping.rst#id7

Thanks!


On Wed, 2015-07-15 at 20:40, Ethan Anderes  wrote:
> Hi Everyone. I hope this isn’t a stupid question but I can’t seem to 
> understand the following
> scoping behavior. The basic story is that mesh in the following two 
> examples behaves differently when defined in global scope vrs within a 
> function. I’m worried that I’m completely ignorant of how functions work 
> within other functions. Some help would be much appreciated. Thanks!
>
> In this block of code mesh is defined as a global variable.
>
> julia> mesh(y) = (x = repmat(y.', 2, 1); return x)
> mesh (generic function with 1 method)

Here x is implicitly local as assigning to it would result in a modified
global.

> julia> x = mesh(1:2);
>
> julia> y = mesh(2:3);

Thus above call will *not* modify x.

> julia> x
> 2x2 Array{Int64,2}:
>  1  2
>  1  2
>
> When I quit, restart Julia and define mesh within foo I get a different 
> answer.
>
> julia> function foo()
> mesh(y) = (x = repmat(y.', 2, 1); return x)

Here x is inherited from the scope of foo as x is a local variable.

> x = mesh(1:2)
> y = mesh(2:3) # <- this line is necessary to see the effect

Thus above call will modify x.

> return x
> end
> foo (generic function with 1 method)
>
> julia> x = foo()  # <- different than the x in the global case.
> 2x2 Array{Int64,2}:
>  2  3
>  2  3
>
> Here is my version info
>
> julia> versioninfo()
> Julia Version 0.4.0-dev+5994
> Commit 8efc44d (2015-07-15 15:42 UTC)
> Platform Info:
>   System: Darwin (x86_64-apple-darwin14.4.0)
>   CPU: Intel(R) Core(TM) M-5Y51 CPU @ 1.10GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT NO_AFFINITY HASWELL)
>   LAPACK: libopenblas
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
> ​



Re: [julia-users] Re: Azure: Which VM?

2015-07-15 Thread Tony Kelman
I don't see why not. I added a template to the Example.jl package that 
could pretty easily be created automatically during Pkg.generate as well.


On Wednesday, July 15, 2015 at 1:47:42 PM UTC-4, David Anthoff wrote:
>
> Maybe one thing that would help on the package ecosystem side is to add an 
> appveyor.yml file in addition to a .travis.yml file to the template 
> generated by Pkg.generate?
>
>  
>
> *From:* julia...@googlegroups.com  [mailto:
> julia...@googlegroups.com ] *On Behalf Of *Tony Kelman
> *Sent:* Tuesday, July 14, 2015 6:49 PM
> *To:* julia...@googlegroups.com 
> *Subject:* [julia-users] Re: Azure: Which VM?
>
>  
>
> If you're comfortable using Linux and have a choice in the matter, I would 
> recommend avoiding using Julia on Windows if you can, especially for 
> production purposes. Jameson, Isaiah, myself and others have put in a lot 
> of effort to try to make things work, but there remains a lot of work to do 
> across the package ecosystem (which was the point behind my JuliaCon talk), 
> and there are a number of persistent bugs and usability issues that remain 
> unsolved for a variety of reasons.
>
>
>
> On Tuesday, July 14, 2015 at 2:07:16 AM UTC-7, Eric Forgy wrote:
>
> I am about to do some experiments running Julia from an Azure VM. The 
> first decision to make is "Which VM?" Azure has a "Quick Create" option for 
> creating VM's and the options are:
>
> · Windows Server
>
>- Ubuntu Server
>
> · OpenLogic
>
>- Oracle Linux
>
> · CoreOS
>
>- SUSE Linux Enterprise Server
>
> I presume Azure has a good reason to shortlist these VM's (and shortlist 
> them in that order) so unless there is a good reason to deviate, I'll 
> probably choose one of the above.
>
>  
>
> If I look at the Julia downloads  page, 
> I see the following selections:
>
> · Windows
>
>- Mac OS X
>
> · Ubuntu
>
>- Fedora/RHEL/CentOS/SL
>
> · Generic Linux
>
> I presume you guys have a good reason to shortlist these OSs (but not sure 
> if the order is significant). I am agnostic about which OS to use, but I 
> prefer to use one that has the best Julia support and will cause the least 
> headaches, which presumably might be related to the OS most Julia 
> developers are using.
>
>  
>
> If I could, I would probably prefer to run Julia on a Windows VM, but I 
> get the impression Windows has the fewest Julia developers working on it 
> (see Stephen's comment here 
> ) 
> so I predict there to be some pain points. Is that impression misguided? 
> Any thoughts?
>
>  
>
> If not Windows, comparing the above two lists, I'd be inclined to consider 
> using Ubuntu.
>
>  
>
> My use case is ultimately going to be distributed computing in the cloud 
> (Azure) driven by a web app (ASP.NET MVC) with communication via REST 
> and/or ZMQ.
>
>  
>
> In a nutshell:
>
> 1.  I have a slight preference for a Windows VM, but could be 
> dissuaded if there is some pain to be expected. Is there?
>
> 2.  If not Windows, it seems Ubuntu VM is the next likely candidate 
> with apparently solid support in the Julia community. Is that true?
>
> 3.  Any other recommendation better than the above two?
>
> Any thoughts would be appreciated. Thanks!
>
>

[julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread Ferran Mazzanti
Thanks guys for all your answers and help! sub() seems the easiest way to 
do what I want to do, although understanding better array handling in Julia 
seems *very* interesting also.
I wonder if Julia will after all replace my fortran needs...

On Wednesday, July 15, 2015 at 12:14:14 PM UTC+2, Ferran Mazzanti wrote:
>
> Hi folks,
>
> I have a little mess with the way arrays are being handled in Julia. I 
> come from C and fortran95 and I know I can do the following things there 
> using pointers: imagine I have a big array A. Then I can use pointers to 
> define W a subsection of A, such that if I modify W then A is modified, and 
> if I modify A then W is modified. In this way I have one and the same data, 
> which I can manipulate by acting on A or on W.
>
> I'd like to do the same thing in Julia, but don't know how. Somehow it 
> works if I use the whole array. For instance in this exemple:
>
> Wall = ones(2,2) 
> 1.0 1.0
> 1.0 1.0
>
> W = Wall
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 0.
> 0.0
>
> Wall
> 2x2 Array{Float64,2}:
> 0.0  1.0
> 1.0  1.0
>
> Wall[1,2] = 2.
> 0.0 2.0
> 1.0 1.0
>
> W
> 2x2 Array{Float64,2}:
> 0.0  2.0
> 1.0  1.0
>
> ...so it works both ways. That's exactly what I want, but now not just 
> with W and Wall being the same, but with W being a part of Wall.
> I could try something like
>
> Wall = ones(3,3)
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> W = Wall[2:end,2:end]
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 3.
> 3.0
>
> W
> 2x2 Array{Float64,2}:
> 3.0  1.0
> 1.0  1.0
>
> Wall
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> ...so W has been updated but not Wall. If I update W itdoesn't get copied 
> to Wall either.
>
> So I know how to do automatic updating when the two arrays are of the same 
> size, but can it be done with subsections of arrays as (I want it to be) in 
> the example above?
>
> Thanks for your help and patience,
>
> Ferran.
>


[julia-users] Re: scoping rule help for functions within functions

2015-07-15 Thread David Gold
Unless I'm mistaken, this is a consequence of lexical scoping. See the 
fifth paragraph down 
http://docs.julialang.org/en/latest/manual/variables-and-scoping/.

Since mesh() is defined inside of foo(), the call to `mesh(2:3) in the line 
`y = mesh(2:3)` actually reassigns the name `x` from the line above to 
`repmat(2:3.', 2, 1)`. This is because after `x` is defined in the previous 
line, it is a valid name that the scope of `mesh` inherits.

Note that if wrap the `x` assignment in a `let` block, trying to return `x` 
incurs an error:

julia> function foo() 
mesh(y) = (x = repmat(y.', 2, 1); return x) 
let x = mesh(1:2) end 
y = mesh(2:3) # <- this line is necessary to see the effect 
return x 
 end 
foo (generic function with 1 method) 

julia> foo() 
ERROR: UndefVarError: x not defined 
in foo at none:5

In the above case, the `let` block introduces a new local scope that is not 
inheritable by `mesh`. The `x` variable within `mesh`'s body is then 
contained entirely within `mesh`'s scope and inaccessible to `foo`'s, hence 
the error.


On Wednesday, July 15, 2015 at 2:40:17 PM UTC-4, Ethan Anderes wrote:
>
> Hi Everyone. I hope this isn’t a stupid question but I can’t seem to 
> understand the following
> scoping behavior. The basic story is that mesh in the following two 
> examples behaves differently when defined in global scope vrs within a 
> function. I’m worried that I’m completely ignorant of how functions work 
> within other functions. Some help would be much appreciated. Thanks!
>
> In this block of code mesh is defined as a global variable.
>
> julia> mesh(y) = (x = repmat(y.', 2, 1); return x)
> mesh (generic function with 1 method)
>
> julia> x = mesh(1:2);
>
> julia> y = mesh(2:3);
>
> julia> x
> 2x2 Array{Int64,2}:
>  1  2
>  1  2
>
> When I quit, restart Julia and define mesh within foo I get a different 
> answer.
>
> julia> function foo()
> mesh(y) = (x = repmat(y.', 2, 1); return x)
> x = mesh(1:2)
> y = mesh(2:3) # <- this line is necessary to see the effect
> return x
> end
> foo (generic function with 1 method)
>
> julia> x = foo()  # <- different than the x in the global case.
> 2x2 Array{Int64,2}:
>  2  3
>  2  3
>
> Here is my version info
>
> julia> versioninfo()
> Julia Version 0.4.0-dev+5994
> Commit 8efc44d (2015-07-15 15:42 UTC)
> Platform Info:
>   System: Darwin (x86_64-apple-darwin14.4.0)
>   CPU: Intel(R) Core(TM) M-5Y51 CPU @ 1.10GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT NO_AFFINITY HASWELL)
>   LAPACK: libopenblas
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
> ​
>


Re: [julia-users] Wrong number of arguments?

2015-07-15 Thread David P. Sanders


El miércoles, 15 de julio de 2015, 14:03:16 (UTC-5), Mauricio Esteban Cuak 
escribió:
>
> Just in case it seems a bit more transparent, this also works:
>
> r = rand(5)
> map( x -> x[1] + x[2], enumerate(r))
>
>
>
I personally find the following array comprehension the most transparent 
option:

[i+v for (i,v) in enumerate(r)]

It also has the benefit of being much faster (Julia 0.3.11-pre):

julia> f1(r) = [i+v for (i,v) in enumerate(r)]
f1 (generic function with 1 method)

julia> f2(r) = map( x -> x[1] + x[2], enumerate(r))
f2 (generic function with 1 method)

# warm-up:
r = rand(5)
f1(r)
f2(r);

r = rand(10^6)

julia> @time f1(r);
elapsed time: 0.007597053 seconds (8000144 bytes allocated)

julia> @time f2(r);
elapsed time: 0.313020208 seconds (160753984 bytes allocated, 35.39% gc 
time)



 

>
> El martes, 14 de julio de 2015, 20:20:14 (UTC-5), Yichao Yu escribió:
>>
>> On Tue, Jul 14, 2015 at 7:09 PM, Ritchie Lee  wrote: 
>> > Sorry if this is a newbie question.  I am trying to get map() to work 
>> with 
>> > with enumerate() but I am getting an error. 
>> > 
>> > r=rand(5) 
>> > map((i,v)->i+v, enumerate(r)) 
>> > ERROR: wrong number of arguments 
>> >  in anonymous at none:1 
>> >  in map at abstractarray.jl:1207 
>> > 
>> > collect(enumerate(r)) generates an array of 2-tuples as expected. 
>>
>> `map` does not splat each element of the iteration and only pass each 
>> element as a single argument to the function 
>>
>> ```julia 
>> julia> r = rand(5) 
>>   map(x->((i, v) = x; i + v), enumerate(r)) 
>> 5-element Array{Any,1}: 
>> 1.6277 
>> 2.41751 
>> 3.34848 
>> 4.70194 
>> 5.89139 
>>
>> ``` 
>>
>> > 
>> > Is the syntax incorrect? 
>> > 
>> > Thanks, 
>> > 
>> > Ritchie 
>>
>

Re: [julia-users] Re: Which Packages Should be Registered?

2015-07-15 Thread Christoph Ortner
Thank you everyone for the comments and discussion. 


Re: [julia-users] Wrong number of arguments?

2015-07-15 Thread Mauricio Esteban Cuak
Just in case it seems a bit more transparent, this also works:

r = rand(5)
map( x -> x[1] + x[2], enumerate(r))



El martes, 14 de julio de 2015, 20:20:14 (UTC-5), Yichao Yu escribió:
>
> On Tue, Jul 14, 2015 at 7:09 PM, Ritchie Lee  > wrote: 
> > Sorry if this is a newbie question.  I am trying to get map() to work 
> with 
> > with enumerate() but I am getting an error. 
> > 
> > r=rand(5) 
> > map((i,v)->i+v, enumerate(r)) 
> > ERROR: wrong number of arguments 
> >  in anonymous at none:1 
> >  in map at abstractarray.jl:1207 
> > 
> > collect(enumerate(r)) generates an array of 2-tuples as expected. 
>
> `map` does not splat each element of the iteration and only pass each 
> element as a single argument to the function 
>
> ```julia 
> julia> r = rand(5) 
>   map(x->((i, v) = x; i + v), enumerate(r)) 
> 5-element Array{Any,1}: 
> 1.6277 
> 2.41751 
> 3.34848 
> 4.70194 
> 5.89139 
>
> ``` 
>
> > 
> > Is the syntax incorrect? 
> > 
> > Thanks, 
> > 
> > Ritchie 
>


[julia-users] scoping rule help for functions within functions

2015-07-15 Thread Ethan Anderes


Hi Everyone. I hope this isn’t a stupid question but I can’t seem to 
understand the following
scoping behavior. The basic story is that mesh in the following two 
examples behaves differently when defined in global scope vrs within a 
function. I’m worried that I’m completely ignorant of how functions work 
within other functions. Some help would be much appreciated. Thanks!

In this block of code mesh is defined as a global variable.

julia> mesh(y) = (x = repmat(y.', 2, 1); return x)
mesh (generic function with 1 method)

julia> x = mesh(1:2);

julia> y = mesh(2:3);

julia> x
2x2 Array{Int64,2}:
 1  2
 1  2

When I quit, restart Julia and define mesh within foo I get a different 
answer.

julia> function foo()
mesh(y) = (x = repmat(y.', 2, 1); return x)
x = mesh(1:2)
y = mesh(2:3) # <- this line is necessary to see the effect
return x
end
foo (generic function with 1 method)

julia> x = foo()  # <- different than the x in the global case.
2x2 Array{Int64,2}:
 2  3
 2  3

Here is my version info

julia> versioninfo()
Julia Version 0.4.0-dev+5994
Commit 8efc44d (2015-07-15 15:42 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin14.4.0)
  CPU: Intel(R) Core(TM) M-5Y51 CPU @ 1.10GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT NO_AFFINITY HASWELL)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

​


RE: [julia-users] Re: Azure: Which VM?

2015-07-15 Thread David Anthoff
Maybe one thing that would help on the package ecosystem side is to add an 
appveyor.yml file in addition to a .travis.yml file to the template generated 
by Pkg.generate?

 

From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On 
Behalf Of Tony Kelman
Sent: Tuesday, July 14, 2015 6:49 PM
To: julia-users@googlegroups.com
Subject: [julia-users] Re: Azure: Which VM?

 

If you're comfortable using Linux and have a choice in the matter, I would 
recommend avoiding using Julia on Windows if you can, especially for production 
purposes. Jameson, Isaiah, myself and others have put in a lot of effort to try 
to make things work, but there remains a lot of work to do across the package 
ecosystem (which was the point behind my JuliaCon talk), and there are a number 
of persistent bugs and usability issues that remain unsolved for a variety of 
reasons.



On Tuesday, July 14, 2015 at 2:07:16 AM UTC-7, Eric Forgy wrote:

I am about to do some experiments running Julia from an Azure VM. The first 
decision to make is "Which VM?" Azure has a "Quick Create" option for creating 
VM's and the options are:

* Windows Server

*   Ubuntu Server

* OpenLogic

*   Oracle Linux

* CoreOS

*   SUSE Linux Enterprise Server

I presume Azure has a good reason to shortlist these VM's (and shortlist them 
in that order) so unless there is a good reason to deviate, I'll probably 
choose one of the above.

 

If I look at the Julia downloads   page, I see 
the following selections:

* Windows

*   Mac OS X

* Ubuntu

*   Fedora/RHEL/CentOS/SL

* Generic Linux

I presume you guys have a good reason to shortlist these OSs (but not sure if 
the order is significant). I am agnostic about which OS to use, but I prefer to 
use one that has the best Julia support and will cause the least headaches, 
which presumably might be related to the OS most Julia developers are using.

 

If I could, I would probably prefer to run Julia on a Windows VM, but I get the 
impression Windows has the fewest Julia developers working on it (see Stephen's 
comment here 
 ) 
so I predict there to be some pain points. Is that impression misguided? Any 
thoughts?

 

If not Windows, comparing the above two lists, I'd be inclined to consider 
using Ubuntu.

 

My use case is ultimately going to be distributed computing in the cloud 
(Azure) driven by a web app (ASP.NET   MVC) with communication 
via REST and/or ZMQ.

 

In a nutshell:

1.  I have a slight preference for a Windows VM, but could be dissuaded if 
there is some pain to be expected. Is there?

2.  If not Windows, it seems Ubuntu VM is the next likely candidate with 
apparently solid support in the Julia community. Is that true?

3.  Any other recommendation better than the above two?

Any thoughts would be appreciated. Thanks!



Re: [julia-users] Performance question on a dictionary of arrays

2015-07-15 Thread Stefan Karpinski
Relevant: https://github.com/JuliaLang/julia/pull/12162 – PR renaming
FloatingPoint to AbstractFloat.

On Mon, Jul 13, 2015 at 12:08 PM, Jeremy Kozdon  wrote:

> Yes, now things work as expected.
>
> This caused me to look back at the code where my problems originally
> arose, and I discovered that I had used FloatingPoint when defining my
> dictionaries and not Float64. I think that this was the real culprit of my
> problems, and then I was led astray by coding up my test problem
> inefficiently.
>
> Thanks for your help.
>
>
> On Saturday, July 11, 2015 at 2:33:44 PM UTC-7, Mauro wrote:
>
>> Two things:
>>
>> - call your functions once before timing them so JIT-compilation is not
>>   included in the @time
>>
>> - @time needs a warm-up too, so I usually do:
>>   @time 1
>>
>> - currently methods not defined in global scope are (often) slower.
>>   Your let-block means that you are in a local scope.  This not-so-good
>>   performance stems from Julia struggling with type inference and it
>>   doesn't know what types are used. This means it has to box the values
>>   which leads to the allocations you see (why straight arrays work ok, I
>>   don't know)
>>
>> After these two modifications I get on 0.3.9:
>>
>> elapsed time: 0.000502229 seconds (13880 bytes allocated)  # the @time 1
>> warm-up
>> pass array
>> elapsed time: 0.002038221 seconds (80 bytes allocated)
>>
>> Get array from typed dictionary
>> elapsed time: 0.002790512 seconds (80 bytes allocated)
>>
>> Get array from untyped dictionary
>> elapsed time: 0.549008381 seconds (268783784 bytes allocated, 14.63% gc
>> time)
>>
>> work with typed dictionary
>> elapsed time: 0.181315189 seconds (80 bytes allocated)
>>
>> work with untyped dictionary
>> elapsed time: 0.86460421 seconds (268783784 bytes allocated, 9.26% gc
>> time)
>>
>> get array from typed dict and call scale1!
>> elapsed time: 0.001979506 seconds (96 bytes allocated)
>>
>> get array from untyped dict and call scale1!
>> elapsed time: 0.002014811 seconds (96 bytes allocated)
>>
>> Is that in-line with your expectations?  If not, please report back.
>>
>> On Fri, 2015-07-10 at 23:07, Jeremy Kozdon  wrote:
>> > Hello all,
>> >
>> > The following minimal example is confusing me. In each case the same
>> > operations are performed, in several cases it seems that a copy of the
>> > array seems to be made even though the original array is the one
>> getting
>> > modified.
>> >
>> > Any assistance as to what I am doing incorrectly would be appreciated
>> (my
>> > preference would be to do something like scale2! and not have to use
>> > scale4! as a work around).
>> >
>> > let
>> >   function scale1!(f, a)
>> > for n = 1:length(f)
>> >   f[n] = f[n] * a
>> > end
>> >   end
>> >
>> >   function scale2!(V, a)
>> > f = V["f"]
>> > for n = 1:length(f)
>> >   f[n] = f[n] * a
>> > end
>> >   end
>> >
>> >   function scale3!(V, a)
>> > for n = 1:length(V["f"])
>> >   V["f"][n] = V["f"][n] * a
>> > end
>> >   end
>> >
>> >   function scale4!(f, a)
>> > f = V["f"]
>> > scale1!(f,a)
>> >   end
>> >
>> >   f = ones(4,60)
>> >   a = 2.
>> >
>> >   # Typed dictionary
>> >   V = Dict{String,Array{Float64,2}}()
>> >   V["f"] = f
>> >
>> >   # untyped dictionary
>> >   U = Dict()
>> >   U["f"] = f
>> >
>> >   println("pass array")
>> >   @time scale1!(f,a)
>> >   println()
>> >
>> >   println("Get array from typed dictionary")
>> >   @time scale2!(V,a)
>> >   println()
>> >
>> >   println("Get array from untyped dictionary")
>> >   @time scale2!(U,a)
>> >   println()
>> >
>> >   println("work with typed dictionary")
>> >   @time scale3!(V,a)
>> >   println()
>> >
>> >   println("work with untyped dictionary")
>> >   @time scale3!(U,a)
>> >   println()
>> >
>> >   println("get array from typed dict and call scale1!")
>> >   @time scale4!(V,a)
>> >   println()
>> >
>> >   println("get array from untyped dict and call scale1!")
>> >   @time scale4!(U,a)
>> > end
>> >
>> >
>> > 'The output I get for Julia 0.3.10 is
>> >
>> > pass array
>> > elapsed time: 0.00631541 seconds (108104 bytes allocated)
>> >
>> > Get array from typed dictionary
>> > elapsed time: 0.769137049 seconds (230636428 bytes allocated, 13.57% gc
>> > time)
>> >
>> > Get array from untyped dictionary
>> > elapsed time: 0.689766861 seconds (230487160 bytes allocated, 16.58% gc
>> > time)
>> >
>> > work with typed dictionary
>> > elapsed time: 0.218875407 seconds (167668 bytes allocated)
>> >
>> > work with untyped dictionary
>> > elapsed time: 1.057047219 seconds (268889924 bytes allocated, 13.12% gc
>> > time)
>> >
>> > get array from typed dict and call scale1!
>> > elapsed time: 0.006385067 seconds (27196 bytes allocated)
>> >
>> > get array from untyped dict and call scale1!
>> > elapsed time: 0.005792765 seconds (26724 bytes allocated)
>> >
>> >
>> > The output I get for Julia 0.4.0-dev is
>> >
>> > pass array
>> >6.036 milliseconds (2148 allocations: 104 KB)
>> >
>> > Get array from typ

[julia-users] Re: ZMQ Publish, Subscribe

2015-07-15 Thread Andrei Zh
To start with 

zmq_socket.connect(zmq_tcp1) 

is not Julia syntax, correct syntax is 

connect(zmq_socket, zmq_tcp1) 

In other words, you don't invoke method of an object with 1 argument, but 
instead invoke a function with 2 arguments.

On Wednesday, July 15, 2015 at 1:54:48 AM UTC+3, Dejan Miljkovic wrote:
>
> Hi there,
>
> I would like to use ZMQ in order to connect several processes  that are 
> publishing messages and one that is receiving the messages.
> I am having problem creating subscribe code.
>
> The publish code for one process looks like this:
>
> using ZMQ
>
> zmq_tcp ="tcp://*:5554"
> zmq_ctx = Context(1)
> zmq_socket = Socket(zmq_ctx, PUB)
> ZMQ.bind(zmq_socket, zmq_tcp)
> while true
> msg = "aaa"
> ZMQ.send(zmq_socket, Message(msg))
> println("Publish: ", msg)
> end
>
> I found python example (
> http://learning-0mq-with-pyzmq.readthedocs.org/en/latest/pyzmq/patterns/pubsub.html)
>  
> but I am not able to find corresponding Julia calls.
>
> Subscriber code should be something like this:
>
> using ZMQ
>
> zmq_tcp1 ="tcp://localhost:5553"
> zmq_tcp2 ="tcp://localhost:5554"
> zmq_ctx = Context(1)
> zmq_socket = Socket(zmq_ctx, SUB)
> zmq_socket.connect (zmq_tcp1)
> zmq_socket.connect (zmq_tcp2)
>
> while true
>println("Waiting")
>msg = bytestring(ZMQ.recv(zmq_socket))
>println(msg)
>
> end
>  
>
> Thanks,
>
> Dejan
>


[julia-users] Re: no method for int64

2015-07-15 Thread Andreas Lobinger

julia> methods(Cairo.set_source_rgb)
# 2 methods for generic function "set_source_rgb":
set_source_rgb(ctx::CairoContext,r::Real,g::Real,b::Real) at 
/home/lobi/.julia/v0.3/Cairo/src/Cairo.jl:510
set_source_rgb(gc::GraphicsContext,::Real,::Real,::Real)

and btw: set_source_rgb needs a context as first argument.



[julia-users] no method for int64

2015-07-15 Thread Forrest Curo
Finding Cairo to be reasonably well-documented with examples, and already 
installed,

I did 'using Cairo' and then typed in "set_source_rgb(0, 0, 0)" -- 

with the result: "error -- no method for int64".

"help" tells me that yes, "set_source_rgb") is a function, and has two 
methods.

Neither of these methods like a float64 diet either.

How do I find out what flavor arguments a package's methods want? 
--including how many, for what purpose -- and if something doesn't like "0" 
as an int64,

how to tell it that "0" is really an int32, if it likes...?



Re: [julia-users] Re: Displaying multiple images in IJulia (similar to Gadfly's hstack)?

2015-07-15 Thread Harold Soh
Thanks Tim. Will have a go at Steven's suggestion and write a writemime 
method. 

On Wednesday, 15 July 2015 19:29:22 UTC+8, Tim Holy wrote:
>
> On Tuesday, July 14, 2015 09:21:13 PM Harold Soh wrote: 
> > Thanks! That's what I'm currently doing but it would be nice to be able 
> to 
> > stack images in IJulia. I'm currently looking into how I can code this 
> up; 
> > any pointers? 
>
> Well, I guess one approach would be to explicitly tile the images into a 
> single larger array. ImageView doesn't take this approach because I wanted 
> to 
> provide zoom/pan capability for each panel separately. 
>
> I suspect replicating this in IJulia would involve understanding a bit 
> about 
> jupyter internals, something I haven't dug into yet. So unfortunately I 
> can't 
> offer any tips there. 
>
> --Tim 
>
> > 
> > On Wednesday, 8 July 2015 21:37:39 UTC+8, Tim Holy wrote: 
> > > It's not IJulia, but ImageView can do this (see canvasgrid). 
> > > 
> > > --Tim 
> > > 
> > > On Wednesday, July 08, 2015 05:29:29 AM Steven G. Johnson wrote: 
> > > > On Wednesday, July 8, 2015 at 6:37:16 AM UTC-4, Harold Soh wrote: 
> > > > > Is there a simple way to display multiple Julia Images (Images.jl) 
> in 
> > > 
> > > one 
> > > 
> > > > > IJulia output cell similar to stacking plots using hstack or 
> vstack in 
> > > > > Gadfly? Thanks! 
> > > > 
> > > > You could call display(image) on multiple images. 
> > > > 
> > > > (A more complete solution would be to write a writemime method for 
> an 
> > > 
> > > array 
> > > 
> > > > of images, perhaps for outputting SVG.) 
>
>

[julia-users] Re: Displaying multiple images in IJulia (similar to Gadfly's hstack)?

2015-07-15 Thread Harold Soh
Thanks Steven. I'll take a look at writemime. 

On Wednesday, 8 July 2015 20:29:29 UTC+8, Steven G. Johnson wrote:
>
>
>
> On Wednesday, July 8, 2015 at 6:37:16 AM UTC-4, Harold Soh wrote:
>>
>> Is there a simple way to display multiple Julia Images (Images.jl) in one 
>> IJulia output cell similar to stacking plots using hstack or vstack in 
>> Gadfly? Thanks! 
>>
>
> You could call display(image) on multiple images. 
>
> (A more complete solution would be to write a writemime method for an 
> array of images, perhaps for outputting SVG.)
>


Re: [julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread Tim Holy
Though note those docs only apply if you're running 0.4. (Also FYI: if you're 
running 0.3, SubArray performance will be relatively poor for many tasks.)

--Tim

On Wednesday, July 15, 2015 05:49:07 AM David Gold wrote:
> Also see http://docs.julialang.org/en/latest/devdocs/subarrays/
> 
> On Wednesday, July 15, 2015 at 6:14:14 AM UTC-4, Ferran Mazzanti wrote:
> > Hi folks,
> > 
> > I have a little mess with the way arrays are being handled in Julia. I
> > come from C and fortran95 and I know I can do the following things there
> > using pointers: imagine I have a big array A. Then I can use pointers to
> > define W a subsection of A, such that if I modify W then A is modified,
> > and
> > if I modify A then W is modified. In this way I have one and the same
> > data,
> > which I can manipulate by acting on A or on W.
> > 
> > I'd like to do the same thing in Julia, but don't know how. Somehow it
> > works if I use the whole array. For instance in this exemple:
> > 
> > Wall = ones(2,2)
> > 1.0 1.0
> > 1.0 1.0
> > 
> > W = Wall
> > 1.0 1.0
> > 1.0 1.0
> > 
> > W[1,1] = 0.
> > 0.0
> > 
> > Wall
> > 2x2 Array{Float64,2}:
> > 0.0  1.0
> > 1.0  1.0
> > 
> > Wall[1,2] = 2.
> > 0.0 2.0
> > 1.0 1.0
> > 
> > W
> > 2x2 Array{Float64,2}:
> > 0.0  2.0
> > 1.0  1.0
> > 
> > ...so it works both ways. That's exactly what I want, but now not just
> > with W and Wall being the same, but with W being a part of Wall.
> > I could try something like
> > 
> > Wall = ones(3,3)
> > 3x3 Array{Float64,2}:
> > 1.0  1.0  1.0
> > 1.0  1.0  1.0
> > 1.0  1.0  1.0
> > 
> > W = Wall[2:end,2:end]
> > 1.0 1.0
> > 1.0 1.0
> > 
> > W[1,1] = 3.
> > 3.0
> > 
> > W
> > 2x2 Array{Float64,2}:
> > 3.0  1.0
> > 1.0  1.0
> > 
> > Wall
> > 3x3 Array{Float64,2}:
> > 1.0  1.0  1.0
> > 1.0  1.0  1.0
> > 1.0  1.0  1.0
> > 
> > ...so W has been updated but not Wall. If I update W itdoesn't get copied
> > to Wall either.
> > 
> > So I know how to do automatic updating when the two arrays are of the same
> > size, but can it be done with subsections of arrays as (I want it to be)
> > in
> > the example above?
> > 
> > Thanks for your help and patience,
> > 
> > Ferran.



[julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread David Gold
Also see http://docs.julialang.org/en/latest/devdocs/subarrays/

On Wednesday, July 15, 2015 at 6:14:14 AM UTC-4, Ferran Mazzanti wrote:
>
> Hi folks,
>
> I have a little mess with the way arrays are being handled in Julia. I 
> come from C and fortran95 and I know I can do the following things there 
> using pointers: imagine I have a big array A. Then I can use pointers to 
> define W a subsection of A, such that if I modify W then A is modified, and 
> if I modify A then W is modified. In this way I have one and the same data, 
> which I can manipulate by acting on A or on W.
>
> I'd like to do the same thing in Julia, but don't know how. Somehow it 
> works if I use the whole array. For instance in this exemple:
>
> Wall = ones(2,2) 
> 1.0 1.0
> 1.0 1.0
>
> W = Wall
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 0.
> 0.0
>
> Wall
> 2x2 Array{Float64,2}:
> 0.0  1.0
> 1.0  1.0
>
> Wall[1,2] = 2.
> 0.0 2.0
> 1.0 1.0
>
> W
> 2x2 Array{Float64,2}:
> 0.0  2.0
> 1.0  1.0
>
> ...so it works both ways. That's exactly what I want, but now not just 
> with W and Wall being the same, but with W being a part of Wall.
> I could try something like
>
> Wall = ones(3,3)
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> W = Wall[2:end,2:end]
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 3.
> 3.0
>
> W
> 2x2 Array{Float64,2}:
> 3.0  1.0
> 1.0  1.0
>
> Wall
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> ...so W has been updated but not Wall. If I update W itdoesn't get copied 
> to Wall either.
>
> So I know how to do automatic updating when the two arrays are of the same 
> size, but can it be done with subsections of arrays as (I want it to be) in 
> the example above?
>
> Thanks for your help and patience,
>
> Ferran.
>


[julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread Andreas Noack
You can use sub or slice for this, e.g. W = slice(Wall, 2:size(Wall, 1), 
2:size(Wall, 2))

Den onsdag den 15. juli 2015 kl. 06.14.14 UTC-4 skrev Ferran Mazzanti:
>
> Hi folks,
>
> I have a little mess with the way arrays are being handled in Julia. I 
> come from C and fortran95 and I know I can do the following things there 
> using pointers: imagine I have a big array A. Then I can use pointers to 
> define W a subsection of A, such that if I modify W then A is modified, and 
> if I modify A then W is modified. In this way I have one and the same data, 
> which I can manipulate by acting on A or on W.
>
> I'd like to do the same thing in Julia, but don't know how. Somehow it 
> works if I use the whole array. For instance in this exemple:
>
> Wall = ones(2,2) 
> 1.0 1.0
> 1.0 1.0
>
> W = Wall
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 0.
> 0.0
>
> Wall
> 2x2 Array{Float64,2}:
> 0.0  1.0
> 1.0  1.0
>
> Wall[1,2] = 2.
> 0.0 2.0
> 1.0 1.0
>
> W
> 2x2 Array{Float64,2}:
> 0.0  2.0
> 1.0  1.0
>
> ...so it works both ways. That's exactly what I want, but now not just 
> with W and Wall being the same, but with W being a part of Wall.
> I could try something like
>
> Wall = ones(3,3)
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> W = Wall[2:end,2:end]
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 3.
> 3.0
>
> W
> 2x2 Array{Float64,2}:
> 3.0  1.0
> 1.0  1.0
>
> Wall
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> ...so W has been updated but not Wall. If I update W itdoesn't get copied 
> to Wall either.
>
> So I know how to do automatic updating when the two arrays are of the same 
> size, but can it be done with subsections of arrays as (I want it to be) in 
> the example above?
>
> Thanks for your help and patience,
>
> Ferran.
>


Re: [julia-users] Re: Displaying multiple images in IJulia (similar to Gadfly's hstack)?

2015-07-15 Thread Tim Holy
On Tuesday, July 14, 2015 09:21:13 PM Harold Soh wrote:
> Thanks! That's what I'm currently doing but it would be nice to be able to
> stack images in IJulia. I'm currently looking into how I can code this up;
> any pointers?

Well, I guess one approach would be to explicitly tile the images into a 
single larger array. ImageView doesn't take this approach because I wanted to 
provide zoom/pan capability for each panel separately.

I suspect replicating this in IJulia would involve understanding a bit about 
jupyter internals, something I haven't dug into yet. So unfortunately I can't 
offer any tips there.

--Tim

> 
> On Wednesday, 8 July 2015 21:37:39 UTC+8, Tim Holy wrote:
> > It's not IJulia, but ImageView can do this (see canvasgrid).
> > 
> > --Tim
> > 
> > On Wednesday, July 08, 2015 05:29:29 AM Steven G. Johnson wrote:
> > > On Wednesday, July 8, 2015 at 6:37:16 AM UTC-4, Harold Soh wrote:
> > > > Is there a simple way to display multiple Julia Images (Images.jl) in
> > 
> > one
> > 
> > > > IJulia output cell similar to stacking plots using hstack or vstack in
> > > > Gadfly? Thanks!
> > > 
> > > You could call display(image) on multiple images.
> > > 
> > > (A more complete solution would be to write a writemime method for an
> > 
> > array
> > 
> > > of images, perhaps for outputting SVG.)



[julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread Kaj Wiik
ArrayViews might do what you are after:

https://github.com/JuliaLang/ArrayViews.jl

Kaj


On Wednesday, July 15, 2015 at 1:14:14 PM UTC+3, Ferran Mazzanti wrote:
>
> Hi folks,
>
> I have a little mess with the way arrays are being handled in Julia. I 
> come from C and fortran95 and I know I can do the following things there 
> using pointers: imagine I have a big array A. Then I can use pointers to 
> define W a subsection of A, such that if I modify W then A is modified, and 
> if I modify A then W is modified. In this way I have one and the same data, 
> which I can manipulate by acting on A or on W.
>
> I'd like to do the same thing in Julia, but don't know how. Somehow it 
> works if I use the whole array. For instance in this exemple:
>
> Wall = ones(2,2) 
> 1.0 1.0
> 1.0 1.0
>
> W = Wall
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 0.
> 0.0
>
> Wall
> 2x2 Array{Float64,2}:
> 0.0  1.0
> 1.0  1.0
>
> Wall[1,2] = 2.
> 0.0 2.0
> 1.0 1.0
>
> W
> 2x2 Array{Float64,2}:
> 0.0  2.0
> 1.0  1.0
>
> ...so it works both ways. That's exactly what I want, but now not just 
> with W and Wall being the same, but with W being a part of Wall.
> I could try something like
>
> Wall = ones(3,3)
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> W = Wall[2:end,2:end]
> 1.0 1.0
> 1.0 1.0
>
> W[1,1] = 3.
> 3.0
>
> W
> 2x2 Array{Float64,2}:
> 3.0  1.0
> 1.0  1.0
>
> Wall
> 3x3 Array{Float64,2}:
> 1.0  1.0  1.0
> 1.0  1.0  1.0
> 1.0  1.0  1.0
>
> ...so W has been updated but not Wall. If I update W itdoesn't get copied 
> to Wall either.
>
> So I know how to do automatic updating when the two arrays are of the same 
> size, but can it be done with subsections of arrays as (I want it to be) in 
> the example above?
>
> Thanks for your help and patience,
>
> Ferran.
>


[julia-users] How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread Ferran Mazzanti
Hi folks,

I have a little mess with the way arrays are being handled in Julia. I come 
from C and fortran95 and I know I can do the following things there using 
pointers: imagine I have a big array A. Then I can use pointers to define W 
a subsection of A, such that if I modify W then A is modified, and if I 
modify A then W is modified. In this way I have one and the same data, 
which I can manipulate by acting on A or on W.

I'd like to do the same thing in Julia, but don't know how. Somehow it 
works if I use the whole array. For instance in this exemple:

Wall = ones(2,2) 
1.0 1.0
1.0 1.0

W = Wall
1.0 1.0
1.0 1.0

W[1,1] = 0.
0.0

Wall
2x2 Array{Float64,2}:
0.0  1.0
1.0  1.0

Wall[1,2] = 2.
0.0 2.0
1.0 1.0

W
2x2 Array{Float64,2}:
0.0  2.0
1.0  1.0

...so it works both ways. That's exactly what I want, but now not just with 
W and Wall being the same, but with W being a part of Wall.
I could try something like

Wall = ones(3,3)
3x3 Array{Float64,2}:
1.0  1.0  1.0
1.0  1.0  1.0
1.0  1.0  1.0

W = Wall[2:end,2:end]
1.0 1.0
1.0 1.0

W[1,1] = 3.
3.0

W
2x2 Array{Float64,2}:
3.0  1.0
1.0  1.0

Wall
3x3 Array{Float64,2}:
1.0  1.0  1.0
1.0  1.0  1.0
1.0  1.0  1.0

...so W has been updated but not Wall. If I update W itdoesn't get copied 
to Wall either.

So I know how to do automatic updating when the two arrays are of the same 
size, but can it be done with subsections of arrays as (I want it to be) in 
the example above?

Thanks for your help and patience,

Ferran.


[julia-users] Re: navigating the help & documentation system

2015-07-15 Thread Andreas Lobinger
For 2)
2) A good lightweight graphics package for such simple-minded tasks as a 2D 
game board with round pieces on a square grid.
The lowest common denominator for just drawing would be Cairo.jl, a 
declarative way to draw something would be Compose.jl (which then does the 
drawing via Cairo.jl).