Re: [julia-users] Re: Git submodules vs Julia submodules

2016-06-15 Thread Jacob Quinn
You're correct Eric; libgit2 isn't doing anything related to what you're
doing here. You're really just telling Julia one more location to look in
order to find a module definition. There's an open issue I created recently
about how to do this more generally (i.e. without having to explicitly
touch LOAD_PATH)

Ref: https://github.com/JuliaLang/julia/issues/16830

-Jacob

On Thu, Jun 16, 2016 at 12:29 AM, Eric Forgy  wrote:

> Hi Tony,
>
> I'm not sure I understand. I am using Julia 0.4.5 (Windows), but not using
> anything explicit from package manager to handle the Git submodules. I just
> do a `git submodule add ...` from the command line (not REPL). I can't
> imagine package manager breaking this in 0.5. Will it? This libgit2 seems
> to be causing all kinds of problems for Windows users, e.g. I still cannot
> even play with 0.5 until this
>  is resolved.
>
> Eric
>
> On Thursday, June 16, 2016 at 3:10:03 AM UTC+8, Tony Kelman wrote:
>>
>> Assuming you're using Julia 0.4 here? Since Julia 0.5 has transitioned to
>> using libgit2 for the package manager, I don't think you'll have explicit
>> support for git submodules right away.
>>
>


[julia-users] Conditional Definition of Functions?

2016-06-15 Thread Chris Rackauckas
There seems to be an interesting change between v0.4.5 and v0.5. Take a 
look at the following code:

  if largeFluctuations
function σ(y,t)
  dσ = zeros(19)
  dσ[1] = noiseLevel*1.5y[1]
  dσ[18]= noiseLevel*6y[18]
  return(dσ)
end
  else
function σ(y,t)
  dσ = zeros(19)
  dσ[1] = 0.02y[1]
  dσ[16]= 0.02y[16]
  dσ[18]= 0.2y[18]
  dσ[17]= 0.02y[17]
  return(dσ)
end
  end

In v0.4.5, this would work as expected: if largeFluctuations was set to 
true, then you would get the first function and if false the second. In 
v0.5, I tracked down to this error where it will always define sigma as the 
second function.

Is this change intentional? If so, why?

Is the proper way to do this in v0.5 using anonymous functions? I know 
there was a change to faster anonymous functions, but is it as fast as 
regular function, or are there some notable differences?


[julia-users] Re: Git submodules vs Julia submodules

2016-06-15 Thread Eric Forgy
Hi Tony,

I'm not sure I understand. I am using Julia 0.4.5 (Windows), but not using 
anything explicit from package manager to handle the Git submodules. I just 
do a `git submodule add ...` from the command line (not REPL). I can't 
imagine package manager breaking this in 0.5. Will it? This libgit2 seems 
to be causing all kinds of problems for Windows users, e.g. I still cannot 
even play with 0.5 until this 
 is resolved.

Eric

On Thursday, June 16, 2016 at 3:10:03 AM UTC+8, Tony Kelman wrote:
>
> Assuming you're using Julia 0.4 here? Since Julia 0.5 has transitioned to 
> using libgit2 for the package manager, I don't think you'll have explicit 
> support for git submodules right away.
>


[julia-users] printing specific RGB colors

2016-06-15 Thread Anonymous
So I've gotten about as much mileage out of print_with_color() as I can, 
which is to say not much, it doesn't even print the right colors half the 
time.  There's a bunch of color packages which seem to be concerned with 
abstractly manipulating different color parameterizations, but no mention 
in the documentation about how to use these for practical purposes.  How 
can I print a string in a specific color?


[julia-users] Re: Custom string escaping in docstrings

2016-06-15 Thread Scott Jones
I think that the docstring system is looking for a normal string, not a 
string with any string macro.
You can get around this by using the `@doc` macro directly, i.e.
@doc R"""
My docstring $a+\alpha$
""" ->
function myfunc()
end

works fine.

On Wednesday, June 15, 2016 at 7:51:27 PM UTC-4, Marius Millea wrote:
>
> My docstrings often contain Latex so they have $ and \ characters in them, 
> so I'd like to not have to escape them manually every time. I'm trying to 
> do so by defining an R_str macro, but it seems to prevent the docstring 
> from attaching to its function. Is there a way to achieve this?
>
> macro R_str(s)
> s
> end
>
> R"""
> My docstring $a+\alpha$
> """
> function myfunc()
> end
>
> >?myfunc
>   No documentation found.
>
>
>
> Thanks. 
>


Re: [julia-users] Re: parse.(Int64, x)

2016-06-15 Thread Tony Kelman
Try parse.([Int64], x)
note that the output will be an Array{Any} because issue #4883 hasn't been 
fixed yet. The issue here is that broadcast doesn't treat types as 
"scalar-like."


On Wednesday, June 15, 2016 at 4:19:09 PM UTC-7, David Anthoff wrote:
>
> map of course works, but it is quite verbose. I’ve been working a group of 
> new julia users lately, many of them from other languages like R, Python 
> etc., and they roll their eyes when something that simple takes
>
>  
>
> df[:x] = map(q->parse(Int64,q), df[:x])
>
>  
>
> It just is quite complicated for something pretty simple… Maybe there are 
> other simple constructs for this?
>
>  
>
> Thanks,
>
> David
>
>  
>
> *From:* julia...@googlegroups.com  [mailto:
> julia...@googlegroups.com ] *On Behalf Of *John Myles White
> *Sent:* Wednesday, June 15, 2016 3:53 PM
> *To:* julia-users 
> *Subject:* [julia-users] Re: parse.(Int64, x)
>
>  
>
> I would be careful combining element-wise function application with 
> partial function application. Why not use map instead?
>
> On Wednesday, June 15, 2016 at 3:47:05 PM UTC-7, David Anthoff wrote:
>
> I just tried to use the new dot syntax for vectorising function calls in 
> order to convert an array of strings into an array of Int64. For example, 
> if this would work, it would be very, very handy:
>
>  
>
> x = [“1”, “2”, “3”]
>
> parse.(Int64, x)
>
>  
>
> Right now I get an error, but I wonder whether this could be enabled 
> somehow in this new framework? If this would work for all sorts of parsing, 
> type conversions etc. it would just be fantastic. Especially when working 
> DataFrames and one is in the first phase of cleaning up data types of 
> columns etc. this would make for a very nice and short notation.
>
>  
>
> Thanks,
>
> David 
>
>  
>
> --
>
> David Anthoff
>
> University of California, Berkeley
>
>  
>
> http://www.david-anthoff.com
>
>  
>
>

[julia-users] Custom string escaping in docstrings

2016-06-15 Thread Marius Millea
My docstrings often contain Latex so they have $ and \ characters in them, 
so I'd like to not have to escape them manually every time. I'm trying to 
do so by defining an R_str macro, but it seems to prevent the docstring 
from attaching to its function. Is there a way to achieve this?

macro R_str(s)
s
end

R"""
My docstring $a+\alpha$
"""
function myfunc()
end

>?myfunc
  No documentation found.



Thanks. 


RE: [julia-users] Re: parse.(Int64, x)

2016-06-15 Thread David Anthoff
map of course works, but it is quite verbose. I’ve been working a group of new 
julia users lately, many of them from other languages like R, Python etc., and 
they roll their eyes when something that simple takes

 

df[:x] = map(q->parse(Int64,q), df[:x])

 

It just is quite complicated for something pretty simple… Maybe there are other 
simple constructs for this?

 

Thanks,

David

 

From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On 
Behalf Of John Myles White
Sent: Wednesday, June 15, 2016 3:53 PM
To: julia-users 
Subject: [julia-users] Re: parse.(Int64, x)

 

I would be careful combining element-wise function application with partial 
function application. Why not use map instead?

On Wednesday, June 15, 2016 at 3:47:05 PM UTC-7, David Anthoff wrote:

I just tried to use the new dot syntax for vectorising function calls in order 
to convert an array of strings into an array of Int64. For example, if this 
would work, it would be very, very handy:

 

x = [“1”, “2”, “3”]

parse.(Int64, x)

 

Right now I get an error, but I wonder whether this could be enabled somehow in 
this new framework? If this would work for all sorts of parsing, type 
conversions etc. it would just be fantastic. Especially when working DataFrames 
and one is in the first phase of cleaning up data types of columns etc. this 
would make for a very nice and short notation.

 

Thanks,

David 

 

--

David Anthoff

University of California, Berkeley

 

http://www.david-anthoff.com

 



[julia-users] Re: parse.(Int64, x)

2016-06-15 Thread John Myles White
I would be careful combining element-wise function application with partial 
function application. Why not use map instead?

On Wednesday, June 15, 2016 at 3:47:05 PM UTC-7, David Anthoff wrote:
>
> I just tried to use the new dot syntax for vectorising function calls in 
> order to convert an array of strings into an array of Int64. For example, 
> if this would work, it would be very, very handy:
>
>  
>
> x = [“1”, “2”, “3”]
>
> parse.(Int64, x)
>
>  
>
> Right now I get an error, but I wonder whether this could be enabled 
> somehow in this new framework? If this would work for all sorts of parsing, 
> type conversions etc. it would just be fantastic. Especially when working 
> DataFrames and one is in the first phase of cleaning up data types of 
> columns etc. this would make for a very nice and short notation.
>
>  
>
> Thanks,
>
> David 
>
>  
>
> --
>
> David Anthoff
>
> University of California, Berkeley
>
>  
>
> http://www.david-anthoff.com
>
>  
>


[julia-users] parse.(Int64, x)

2016-06-15 Thread David Anthoff
I just tried to use the new dot syntax for vectorising function calls in
order to convert an array of strings into an array of Int64. For example, if
this would work, it would be very, very handy:

 

x = ["1", "2", "3"]

parse.(Int64, x)

 

Right now I get an error, but I wonder whether this could be enabled somehow
in this new framework? If this would work for all sorts of parsing, type
conversions etc. it would just be fantastic. Especially when working
DataFrames and one is in the first phase of cleaning up data types of
columns etc. this would make for a very nice and short notation.

 

Thanks,

David 

 

--

David Anthoff

University of California, Berkeley

 

http://www.david-anthoff.com

 



[julia-users] Re: Performance of TCPServer

2016-06-15 Thread Andrei Zh
Thanks, Tony. Moving to Julia 0.4.5 improved speed to ~0.025 seconds per 
megabyte (~39Mb / sec). This is still far behind awesome 2.5Gb for Julia 
0.5, but I think it doesn't make sense to spend time on identifying and 
backporting changes to 0.4 given stated release date for 0.5 [1].

[1]: https://github.com/JuliaLang/julia/milestones

On Thursday, June 16, 2016 at 1:20:46 AM UTC+3, Tony Kelman wrote:
>
> Use 0.4.4 or 0.4.5. https://github.com/JuliaLang/julia/issues/14467
>
> On Wednesday, June 15, 2016 at 1:46:34 PM UTC-7, Andrei Zh wrote:
>>
>> Seems like results I posted are specific to Julia 0.4 (0.4.1 to be 
>> precise), here are results for Julia 0.3 (about 10 times faster):
>>
>> elapsed time: 0.031528334 seconds (1048640 bytes allocated)
>> elapsed time: 0.031559074 seconds (1048640 bytes allocated)
>> elapsed time: 0.031342995 seconds (1048640 bytes allocated)
>> elapsed time: 0.031462577 seconds (1048640 bytes allocated)
>> elapsed time: 0.031317323 seconds (1048640 bytes allocated)
>> elapsed time: 0.032238497 seconds (1048640 bytes allocated)
>> elapsed time: 0.031747699 seconds (1048640 bytes allocated)
>> elapsed time: 0.032849825 seconds (1048640 bytes allocated)
>> elapsed time: 0.031415585 seconds (1048640 bytes allocated)
>> elapsed time: 0.031334191 seconds (1048640 bytes allocated)
>> elapsed time: 0.033120056 seconds (1049168 bytes allocated)
>> elapsed time: 0.032014831 seconds (1048640 bytes allocated)
>> elapsed time: 0.031040683 seconds (1048640 bytes allocated)
>> elapsed time: 0.031430475 seconds (1048640 bytes allocated)
>> elapsed time: 0.031396017 seconds (1048640 bytes allocated)
>>
>> and for Julia 0.5 (about 1000 times faster, 2.5Gb/sec):
>>
>>   0.000392 seconds (114 allocations: 1.012 MB)
>>   0.000386 seconds (114 allocations: 1.012 MB)
>>   0.000412 seconds (114 allocations: 1.012 MB)
>>   0.000384 seconds (114 allocations: 1.012 MB)
>>   0.000394 seconds (114 allocations: 1.012 MB)
>>   0.000398 seconds (114 allocations: 1.012 MB)
>>   0.000409 seconds (114 allocations: 1.012 MB)
>>   0.000400 seconds (114 allocations: 1.012 MB)
>>   0.000396 seconds (114 allocations: 1.012 MB)
>>   0.000386 seconds (114 allocations: 1.012 MB)
>>   0.000390 seconds (114 allocations: 1.012 MB)
>>   0.000727 seconds (114 allocations: 1.012 MB, 46.14% gc time)
>>   0.000398 seconds (114 allocations: 1.012 MB)
>>   0.000386 seconds (114 allocations: 1.012 MB)
>>   0.000395 seconds (114 allocations: 1.012 MB)
>>   0.000400 seconds (114 allocations: 1.012 MB)
>>
>>  Any suggestions on why the results are so different and how to fix TCP 
>> sockets for Julia 0.4?
>>
>> On Wednesday, June 15, 2016 at 5:10:12 PM UTC+3, Andrei Zh wrote:
>>>
>>> I've just tested performance of TCP server/client in Julia REPL and find 
>>> results pretty disappointing. The server is as simple as: 
>>>
>>> server = listen(2000)
>>> while true
>>> sock = accept(server)
>>> begin
>>> while true
>>> @time readbytes(sock, 1024*1024)
>>> end
>>> end
>>> end
>>>
>>> It listens on 2000 port for a single connection and than starts reading 
>>> from it chunks of 1Mb. 
>>>
>>> Client is not much harder: 
>>>
>>> sock = connect(2000)
>>> Mb = rand(UInt8, 1024*1024)   # 1 Mb of data
>>> for i=1:1_000 write(sock, Mb) end
>>>
>>> Basically it simply writes 1Gb of data in chunk of 1Mb. When I run these 
>>> snippets in 2 different REPL windows, from the server one I get the 
>>> following: 
>>>
>>>   0.393481 seconds (2 allocations: 1.000 MB)
>>>   0.406101 seconds (2 allocations: 1.000 MB)
>>>   0.424946 seconds (2 allocations: 1.000 MB)
>>>   0.410651 seconds (2 allocations: 1.000 MB)
>>>   0.406987 seconds (2 allocations: 1.000 MB)
>>>   0.386872 seconds (2 allocations: 1.000 MB)
>>>   0.38 seconds (40 allocations: 1.001 MB)
>>>
>>> I.e. speed of data transfer is about 2.5 Mb/sec. I'm pretty much sure my 
>>> local network interface can do much better. Am I doing something wrong? 
>>>
>>>
>>>
>>>
>>>

[julia-users] Re: Performance of TCPServer

2016-06-15 Thread Tony Kelman
Use 0.4.4 or 0.4.5. https://github.com/JuliaLang/julia/issues/14467

On Wednesday, June 15, 2016 at 1:46:34 PM UTC-7, Andrei Zh wrote:
>
> Seems like results I posted are specific to Julia 0.4 (0.4.1 to be 
> precise), here are results for Julia 0.3 (about 10 times faster):
>
> elapsed time: 0.031528334 seconds (1048640 bytes allocated)
> elapsed time: 0.031559074 seconds (1048640 bytes allocated)
> elapsed time: 0.031342995 seconds (1048640 bytes allocated)
> elapsed time: 0.031462577 seconds (1048640 bytes allocated)
> elapsed time: 0.031317323 seconds (1048640 bytes allocated)
> elapsed time: 0.032238497 seconds (1048640 bytes allocated)
> elapsed time: 0.031747699 seconds (1048640 bytes allocated)
> elapsed time: 0.032849825 seconds (1048640 bytes allocated)
> elapsed time: 0.031415585 seconds (1048640 bytes allocated)
> elapsed time: 0.031334191 seconds (1048640 bytes allocated)
> elapsed time: 0.033120056 seconds (1049168 bytes allocated)
> elapsed time: 0.032014831 seconds (1048640 bytes allocated)
> elapsed time: 0.031040683 seconds (1048640 bytes allocated)
> elapsed time: 0.031430475 seconds (1048640 bytes allocated)
> elapsed time: 0.031396017 seconds (1048640 bytes allocated)
>
> and for Julia 0.5 (about 1000 times faster, 2.5Gb/sec):
>
>   0.000392 seconds (114 allocations: 1.012 MB)
>   0.000386 seconds (114 allocations: 1.012 MB)
>   0.000412 seconds (114 allocations: 1.012 MB)
>   0.000384 seconds (114 allocations: 1.012 MB)
>   0.000394 seconds (114 allocations: 1.012 MB)
>   0.000398 seconds (114 allocations: 1.012 MB)
>   0.000409 seconds (114 allocations: 1.012 MB)
>   0.000400 seconds (114 allocations: 1.012 MB)
>   0.000396 seconds (114 allocations: 1.012 MB)
>   0.000386 seconds (114 allocations: 1.012 MB)
>   0.000390 seconds (114 allocations: 1.012 MB)
>   0.000727 seconds (114 allocations: 1.012 MB, 46.14% gc time)
>   0.000398 seconds (114 allocations: 1.012 MB)
>   0.000386 seconds (114 allocations: 1.012 MB)
>   0.000395 seconds (114 allocations: 1.012 MB)
>   0.000400 seconds (114 allocations: 1.012 MB)
>
>  Any suggestions on why the results are so different and how to fix TCP 
> sockets for Julia 0.4?
>
> On Wednesday, June 15, 2016 at 5:10:12 PM UTC+3, Andrei Zh wrote:
>>
>> I've just tested performance of TCP server/client in Julia REPL and find 
>> results pretty disappointing. The server is as simple as: 
>>
>> server = listen(2000)
>> while true
>> sock = accept(server)
>> begin
>> while true
>> @time readbytes(sock, 1024*1024)
>> end
>> end
>> end
>>
>> It listens on 2000 port for a single connection and than starts reading 
>> from it chunks of 1Mb. 
>>
>> Client is not much harder: 
>>
>> sock = connect(2000)
>> Mb = rand(UInt8, 1024*1024)   # 1 Mb of data
>> for i=1:1_000 write(sock, Mb) end
>>
>> Basically it simply writes 1Gb of data in chunk of 1Mb. When I run these 
>> snippets in 2 different REPL windows, from the server one I get the 
>> following: 
>>
>>   0.393481 seconds (2 allocations: 1.000 MB)
>>   0.406101 seconds (2 allocations: 1.000 MB)
>>   0.424946 seconds (2 allocations: 1.000 MB)
>>   0.410651 seconds (2 allocations: 1.000 MB)
>>   0.406987 seconds (2 allocations: 1.000 MB)
>>   0.386872 seconds (2 allocations: 1.000 MB)
>>   0.38 seconds (40 allocations: 1.001 MB)
>>
>> I.e. speed of data transfer is about 2.5 Mb/sec. I'm pretty much sure my 
>> local network interface can do much better. Am I doing something wrong? 
>>
>>
>>
>>
>>

Re: [julia-users] Segfaults in SharedArrays

2016-06-15 Thread Tim Holy
Dunno, but if you can build julia from source, you can easily make the same 
change yourself and see if it fixes the problem. If not, then you know you 
should keep searching for the real answer.

Best,
--Tim

On Wednesday, June 15, 2016 11:50:47 AM CDT Nils Gudat wrote:
> That looks familiar, yes. Would this be available in 0.4.6 then? And if so,
> when is 0.4.6 expected to be released?




[julia-users] Re: Plotting lots of data

2016-06-15 Thread CrocoDuck O'Ducks





Hi, thank you very much, really appreciated. GR seems pretty much what I 
need. I like I can use Plots.jl with it. PlotlyJS.jl is very hot, I guess I 
will use it when I need interactivity. I will look into OpenGL related 
visualization tools for more advanced plots/renders.

I just have a quick question. I just did a quick test with GR plotting two 
1 second long sine waves sampled at 192 kHz, one of frequency 100 Hz and 
one of frequency 10 kHz. The 100 Hz looks fine but the 10 kHz plot has 
blank areas (see attached pictures). I guess it is due to the density of 
lines... probably solved by making the plot bigger?



[julia-users] Re: Performance of TCPServer

2016-06-15 Thread Andrei Zh
Seems like results I posted are specific to Julia 0.4 (0.4.1 to be 
precise), here are results for Julia 0.3 (about 10 times faster):

elapsed time: 0.031528334 seconds (1048640 bytes allocated)
elapsed time: 0.031559074 seconds (1048640 bytes allocated)
elapsed time: 0.031342995 seconds (1048640 bytes allocated)
elapsed time: 0.031462577 seconds (1048640 bytes allocated)
elapsed time: 0.031317323 seconds (1048640 bytes allocated)
elapsed time: 0.032238497 seconds (1048640 bytes allocated)
elapsed time: 0.031747699 seconds (1048640 bytes allocated)
elapsed time: 0.032849825 seconds (1048640 bytes allocated)
elapsed time: 0.031415585 seconds (1048640 bytes allocated)
elapsed time: 0.031334191 seconds (1048640 bytes allocated)
elapsed time: 0.033120056 seconds (1049168 bytes allocated)
elapsed time: 0.032014831 seconds (1048640 bytes allocated)
elapsed time: 0.031040683 seconds (1048640 bytes allocated)
elapsed time: 0.031430475 seconds (1048640 bytes allocated)
elapsed time: 0.031396017 seconds (1048640 bytes allocated)

and for Julia 0.5 (about 1000 times faster, 2.5Gb/sec):

  0.000392 seconds (114 allocations: 1.012 MB)
  0.000386 seconds (114 allocations: 1.012 MB)
  0.000412 seconds (114 allocations: 1.012 MB)
  0.000384 seconds (114 allocations: 1.012 MB)
  0.000394 seconds (114 allocations: 1.012 MB)
  0.000398 seconds (114 allocations: 1.012 MB)
  0.000409 seconds (114 allocations: 1.012 MB)
  0.000400 seconds (114 allocations: 1.012 MB)
  0.000396 seconds (114 allocations: 1.012 MB)
  0.000386 seconds (114 allocations: 1.012 MB)
  0.000390 seconds (114 allocations: 1.012 MB)
  0.000727 seconds (114 allocations: 1.012 MB, 46.14% gc time)
  0.000398 seconds (114 allocations: 1.012 MB)
  0.000386 seconds (114 allocations: 1.012 MB)
  0.000395 seconds (114 allocations: 1.012 MB)
  0.000400 seconds (114 allocations: 1.012 MB)

 Any suggestions on why the results are so different and how to fix TCP 
sockets for Julia 0.4?

On Wednesday, June 15, 2016 at 5:10:12 PM UTC+3, Andrei Zh wrote:
>
> I've just tested performance of TCP server/client in Julia REPL and find 
> results pretty disappointing. The server is as simple as: 
>
> server = listen(2000)
> while true
> sock = accept(server)
> begin
> while true
> @time readbytes(sock, 1024*1024)
> end
> end
> end
>
> It listens on 2000 port for a single connection and than starts reading 
> from it chunks of 1Mb. 
>
> Client is not much harder: 
>
> sock = connect(2000)
> Mb = rand(UInt8, 1024*1024)   # 1 Mb of data
> for i=1:1_000 write(sock, Mb) end
>
> Basically it simply writes 1Gb of data in chunk of 1Mb. When I run these 
> snippets in 2 different REPL windows, from the server one I get the 
> following: 
>
>   0.393481 seconds (2 allocations: 1.000 MB)
>   0.406101 seconds (2 allocations: 1.000 MB)
>   0.424946 seconds (2 allocations: 1.000 MB)
>   0.410651 seconds (2 allocations: 1.000 MB)
>   0.406987 seconds (2 allocations: 1.000 MB)
>   0.386872 seconds (2 allocations: 1.000 MB)
>   0.38 seconds (40 allocations: 1.001 MB)
>
> I.e. speed of data transfer is about 2.5 Mb/sec. I'm pretty much sure my 
> local network interface can do much better. Am I doing something wrong? 
>
>
>
>
>

[julia-users] Re: eval() uses global name scope

2016-06-15 Thread Ford O.
Thanks for clarification. 

On Wednesday, June 15, 2016 at 8:37:30 PM UTC+2, Ford O. wrote:
>
> vars() = (:x, :y, :z)
>
> foo(x, y, z) = eval(vars()[1]) + eval(vars()[2]) + eval(vars()[3])
>
> x = y = z = 1
>
> @show foo(10, 10, 10)
>
> foo(10, 10, 10) = 3
>>
>
>
> Is this intended? 
>
>
>

[julia-users] Re: Git submodules vs Julia submodules

2016-06-15 Thread Tony Kelman
Assuming you're using Julia 0.4 here? Since Julia 0.5 has transitioned to 
using libgit2 for the package manager, I don't think you'll have explicit 
support for git submodules right away.

On Wednesday, June 15, 2016 at 8:26:52 AM UTC-7, Eric Forgy wrote:
>
> I got it! :)
>
> I CAN use GIt submodules, which will make consistency across the team much 
> easier with these private packages.
>
> I just need to add `Pkg.dir("A","src")` to `LOAD_PATH` :)
>
> The world is good again :)
>
> On Wednesday, June 15, 2016 at 10:57:21 PM UTC+8, Eric Forgy wrote:
>>
>> Hi,
>>
>> I have a large private package that depends on many other private 
>> packages and each smaller package may depends on other private packages. It 
>> is a bit tangled, but working.
>>
>> For example:
>>
>> # A,B,C,D are all private packages
>> module A
>>
>> using B, C, D
>>
>> ...
>>
>> end
>>
>> with
>>
>> module D
>>
>> using B, C
>>
>> ...
>>
>> end
>>
>> However, I was having trouble ensuring that my team was using the same 
>> versions of all these private packages.
>>
>> So... I got a bright idea to use Git submodules for module A with B,C,D 
>> being Git submodules.
>>
>> Now, I changed module A to:
>>
>> module A
>>
>> modules = ["B","C","D"]
>> for mod in modules
>> include(Pkg.dir("A","src",mod,"src","$mod.jl"))
>> end
>>
>> ...
>>
>> end
>>
>> and I removed modules B,C,D from my package directory.
>>
>> HOWEVER, module D is still `using B,C`, but I obviously get errors for 
>> that because B & C are no longer in my package directory.
>>
>> The, in desperation, I started trying things like:
>>
>> modules = ["B","C"]
>> for mod in modules
>> sym = Symbol(mod)
>> isdefined(sym) || eval(Expr(:using, sym))
>> end
>>
>> and various permutations. 
>>
>> REQUIRE would seem like a good thing to try, but according to this 
>> ,
>>  
>> REQUIRE doesn't work for packages not in METADATA.
>>
>> Any ideas? Can I use Git submodules for this and somehow get `using` to 
>> work or punt and stop using `using` in the submodules and just include my 
>> files in each submodule?
>>
>> Thank you for any help.
>>
>>
>>
>>
>>

Re: [julia-users] Re: eval() uses global name scope

2016-06-15 Thread Stefan Karpinski
Or use eval to define the function foo rather than in the definition of foo:

@eval foo(x, y, z) = $(vars()[1]) + $(vars()[2]) + $(vars()[3])

On Wed, Jun 15, 2016 at 3:02 PM, Yichao Yu  wrote:

> On Wed, Jun 15, 2016 at 2:59 PM, Ford O.  wrote:
> > So how should I rewrite the foo function to output 30?
>
> foo(x, y, z) = x + y + z
>
> If you don't know the variable names, build a dict and access it from
> there, that's effectively what eval is anyway.
>


Re: [julia-users] Re: eval() uses global name scope

2016-06-15 Thread Yichao Yu
On Wed, Jun 15, 2016 at 2:59 PM, Ford O.  wrote:
> So how should I rewrite the foo function to output 30?

foo(x, y, z) = x + y + z

If you don't know the variable names, build a dict and access it from
there, that's effectively what eval is anyway.


Re: [julia-users] Re: eval() uses global name scope

2016-06-15 Thread Yichao Yu
On Wed, Jun 15, 2016 at 2:55 PM, Yichao Yu  wrote:
> On Wed, Jun 15, 2016 at 2:44 PM, Ford O.  wrote:
>> Can you explain me what exactly happens, because I am completely lost...
>
> It is the intended behavior and doing it otherwise will have a huge
> performance hit since the compiler has no way to know what you are
> doing.

Even more detail. `eval` cannot be statically optimized/analyzed
without solving the halting problem (you are basically asking the
compiler to reason about an arbitrary value (the expression to be
evaluated) at compile time).

Doing it dynamically should be possible in principle. But it's a much
harder problem and much less reliably and allowing local eval will
decrease the performance of code that doesn't even use this feature
(since the compiler has to allow it) It seems that other JIT doesn't
optimize this well either (I'm actually a little bit surprised that
PyPy's tracing JIT doesn't optimize a simple) so it must be even
harder (or doesn't worth optimizing) than I thought.


Re: [julia-users] Re: eval() uses global name scope

2016-06-15 Thread Ford O.
So how should I rewrite the foo function to output 30?


Re: [julia-users] Re: eval() uses global name scope

2016-06-15 Thread Yichao Yu
On Wed, Jun 15, 2016 at 2:44 PM, Ford O.  wrote:
> Can you explain me what exactly happens, because I am completely lost...

It is the intended behavior and doing it otherwise will have a huge
performance hit since the compiler has no way to know what you are
doing.


Re: [julia-users] Segfaults in SharedArrays

2016-06-15 Thread Nils Gudat
That looks familiar, yes. Would this be available in 0.4.6 then? And if so, 
when is 0.4.6 expected to be released?


Re: [julia-users] Segfaults in SharedArrays

2016-06-15 Thread Tim Holy
Maybe see https://github.com/JuliaLang/julia/pull/16899?

--Tim

On Wednesday, June 15, 2016 9:04:06 AM CDT Nils Gudat wrote:
> I've had a longstanding problem with random segfaults in a program I've
> written which recently re-appeared (see original discussion here:
> https://groups.google.com/forum/#!topic/julia-users/FV9AmKsZNuk)
> 
> It appears that currently these segfaults are caused by the usage of
> SharedArrays (or at least running the code in parallel); if I run the code
> on a single core it runs for days without segfaulting, while in parallel a
> segfault usually occurs within an hour or so of the program running.
> Someone in the other thread mentioned experiencing the same issue.
> 
> Has anyone else noticed this/is this a known issue? How would one go about
> de-bugging this sort of thing?




Re: [julia-users] eval() uses global name scope

2016-06-15 Thread Mauro
On Wed, 2016-06-15 at 20:37, Ford O.  wrote:
> vars() = (:x, :y, :z)
>
> foo(x, y, z) = eval(vars()[1]) + eval(vars()[2]) + eval(vars()[3])
>
> x = y = z = 1
>
> @show foo(10, 10, 10)
>
>
> foo(10, 10, 10) = 3
>
>
>
> Is this intended?

Yes


Re: [julia-users] eval() uses global name scope

2016-06-15 Thread Yichao Yu
On Wed, Jun 15, 2016 at 2:37 PM, Ford O.  wrote:
> vars() = (:x, :y, :z)
>
> foo(x, y, z) = eval(vars()[1]) + eval(vars()[2]) + eval(vars()[3])
>
> x = y = z = 1
>
> @show foo(10, 10, 10)
>
>> foo(10, 10, 10) = 3
>
>
>
> Is this intended?

Yes

>
>


[julia-users] eval() uses global name scope

2016-06-15 Thread Ford O.
vars() = (:x, :y, :z)

foo(x, y, z) = eval(vars()[1]) + eval(vars()[2]) + eval(vars()[3])

x = y = z = 1

@show foo(10, 10, 10)

foo(10, 10, 10) = 3
>


Is this intended? 




[julia-users] Writable arrays

2016-06-15 Thread Robert DJ
In a function that modifies an array argument I would like to pass at least 
(Dense)Arrays and SubArrays (from `slice`). AbstractArray is too broad a 
type -- a LinSpace does not allow changing an entry. 
What would be a suitable class? 
Union{DenseArray, SubArray}
works, but is there a better choice?


[julia-users] Re: MethodError closest candidate is same as "no matching method" method

2016-06-15 Thread michael
That would almost definitely be it. I had been using 
@everywhere using Nemo
as a hacky way of dealing with types not being defined on other processes. 
I've read the documentation where it gives the example DummyModule and 
talks about the scope but I've never really grasped the "correct" way to 
create an object of custom type on multiples processes. If I wanted to have 
an object S of type MatrixSpace on all processes it seems like it should be 
something like

for i = 1:nprocs()
  S = RemoteRef(i)
  put!(S, MatrixSpace(ZZ, 3, 3)
end

and then I could use S inside an @parallel loop? I'm sure something with my 
syntax is off but is that the correct idea or am I off-base?

On Tuesday, June 14, 2016 at 5:46:50 AM UTC-5, Toivo Henningsson wrote:
>
> Could it be that you happened to reload Nemo after using/importing it? 
> This kind of thing can happen when there are two live instances of the same 
> module and your code happens to combine types/functions from both.
>


[julia-users] Re: ANN: Delegate.jl, delegation and type re-wrapped delegation

2016-06-15 Thread Jeffrey Sarnoff
Ok, afaik examples on README.md work with v0.4.5+ and v0.5.0-dev. Here they 
are:
 

> import Base: length, last
> type MyInts elems::Vector{Int} end;
> type MyNums{T} elems::Vector{T} end;
> @delegate_1field1var( MyInts, elems, [ length, last ] );
> @delegate_1field1var( MyNums, elems, [ length, last ] );
> myInts = MyInts([5, 4, 3, 2, 1]);
> myNums = MyNums([1.0, 2.0, 3.0]);
> length(myInts), length(myNums) # 5, 3
> last(myInts), last(myNums) # 1, 3.0
>
 

> import Base: (<), (<=), isequal, isless
> type MyInt val::Int end;
> @delegate_1field2vars( MyInt, val, [ (<), (<=), isequal, isless ] );
> myFirstInt = MyInt(3)
> mySecondInt = MyInt(7)
> myFirstInt < mySecondInt # true
> mySecondInt <= myFirstInt # false
>
 

> import Base: hypot
> type RightTriangle legA::Float64; legB::Float64; end;
> @delegate_2fields1var( RightTriangle, legA, legB, [ hypot, ] );
> myRightTriangle = RightTriangle( 3.0, 4.0 )
> hypot(myRightTriangle) # 5.0
>
 

> import Base: (+), (-), (*)
> type MyInt val::Int end;
> @traject_1field2vars( MyInt, val, [ (+), (-), (*) ] );
> myFirstInt = MyInt(3)
> mySecondInt = MyInt(7)
> myIntAdds = myFirstInt + mySecondInt # MyInt(10)
> myIntSubtracts = myFirstInt - mySecondInt # MyInt(-4)
> myIntMultiplies = myFirstInt * mySecondInt # MyInt(21)
>
 

> function renormalize(a::Float64, b::Float64)
> hi = a + b
> t = hi - a
> lo = (a - (hi - t)) + (b - t)
> hi, lo
> end
> type HiLo hi::Float64; lo::Float64; end;
> @traject_2fields1var HiLo hi lo [ renormalize, ];
> myHiLo = renormalize( HiLo(12.5, 8000.3) )
> # HiLo(8012.89,4.44089e-14)
> showall(myHiLo)
> # HiLo(8012.8,4.440892098500626e-14)


On Wednesday, June 15, 2016 at 11:59:45 AM UTC-4, Jeffrey Sarnoff wrote:
>
> hmm .. cleaning up (thx)
>
> On Wednesday, June 15, 2016 at 11:38:27 AM UTC-4, g wrote:
>>
>> Looks super useful, thanks.
>>
>> It looks like you let your example get out of date, here is a corrected 
>> version
>> using Delegate
>> import Base: <, <=, +, *, - # later I get WARNING: module Main should 
>> explicitly import < from Base if I don't import Base:
>>
>> immutable AnInt
>>   val::Int
>> end
>> int1 = AnInt(1)
>> int2 = AnInt(2)
>>
>> @delegate_1field2vars AnInt val [ (<), (<=) ]; # returns <=
>> @traject_1field2vars  AnInt val [ (+), (-), (*) ]; # returns *
>>
>> int1+int2 # returns AnInt(3)
>> int1>
>> # dont use the following, wrong number of arguments
>> #@delegate_1field2vars AnInt.val [ (<), (<=) ];
>>
>>
>>
>> On Wednesday, June 15, 2016 at 4:18:50 AM UTC-6, Jeffrey Sarnoff wrote:
>>>
>>> Pkg.clone("https://github.com/Jeffrey-Sarnoff/Delegate.jl;)
>>>
>>>  
>>>
 using Delegate 
>>>
>>> import <, <=, +, *
>>>
>>> immutable AnInt
>>>
>>> val::Int 
>>>
>>> end 
>>>
>>>  
>>>
>>> int1 = AnInt(1) 
>>>
>>> int2 = AnInt(2) 
>>>
>>>  
>>>
>>> @delegate_1field2vars AnInt.val [ (<), (<=) ];   # plain results
>>>
>>> @traject_1field2vars( MyInt, val, [ (+), (-), (*) ] );   # type 
 re-wrapped results
>>>
>>>  
>>>
>>> int1 < int2
>>>
>>> true 
>>>
>>>  
>>>
>>> int1 + int2
>>>
>>> AnInt(3) 
>>>
>>>  
>>>
>>>
>>> Also exports 2field versions and 1var versions.
>>> More examples are available in the README.md and in the tests.
>>>
>>> This is built on the work of John Myles White and Toivo Hennigsson.
>>>
>>>

Re: [julia-users] Problems with MySQL sample code

2016-06-15 Thread Stefan Karpinski
Issue filed here: https://github.com/JuliaDB/MySQL.jl/issues/48. Thanks.

On Tue, Jun 14, 2016 at 4:58 PM, Jacob Quinn  wrote:

> Yep, it's just like I said above, in the "mysql_execute(con"
> command/line, you'll even notice the code highlighting in your email shows
> that "John" is highlighted as a value instead of a text. That's because the
> double quote right before John is ending the string that starts with
> "INSERT...".
>
> You need to escape the double quotes there or, as I said, use single
> quotes, so that line would be:
>
> mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
> ('John', 25000.00, '2015-12-12'), ('Sam', 35000.00, '2012-18-17), ('Tom', 
> 5.00, '2013-12-14');")
>
> Also feel free to checkout https://github.com/JuliaDB/ODBC.jl, it's a great 
> package for interacting with a variety of databases through the common ODBC 
> framework, most heavily tested against MySQL.
>
> -Jacob
>
>
> On Tue, Jun 14, 2016 at 1:53 PM, Ingemar Skarpås 
> wrote:
>
>> Well - it is this sample code- direct from Github for MySQL.jl -only
>> modification i adrress username et c in the con=mysql_connect(). And the
>> same works for the MySQL test suite. And the code works up until row 14 in
>> this case. I my code I have a few more comments I've added but teh
>> executable code is the same!
>>
>> using MySQL
>> con = mysql_connect("192.168.23.24", "username", "password", "db_name")
>> command = """CREATE TABLE Employee
>>  (
>>  ID INT NOT NULL AUTO_INCREMENT,
>>  Name VARCHAR(255),
>>  Salary FLOAT,
>>  JoinDate DATE,
>>  PRIMARY KEY (ID)
>>  );"""
>> mysql_execute(con, command)
>>
>> # Insert some values
>> mysql_execute(con, "INSERT INTO Employee (Name, Salary, JoinDate) values 
>> ("John", 25000.00, '2015-12-12'), ("Sam", 35000.00, '2012-18-17), ("Tom", 
>> 5.00, '2013-12-14');")
>>
>> # Get SELECT results
>> command = "SELECT * FROM Employee;"
>> dframe = mysql_execute(con, command)
>>
>> # Close connection
>> mysql_disconnect(con)
>>
>>
>>
>>
>> Den tisdag 14 juni 2016 kl. 19:01:49 UTC+2 skrev Stefan Karpinski:
>>>
>>> On Tue, Jun 14, 2016 at 11:50 AM, Ingemar Skarpås 
>>> wrote:
>>>
 LoadError:UdefVarError: @John_str not defined
>>>
>>>
>>> This bit indicates that you've written something like this: John"...".
>>> This is translated to a macro call to a macro named @John_str.
>>>
>>>
>


[julia-users] Segfaults in SharedArrays

2016-06-15 Thread Nils Gudat
I've had a longstanding problem with random segfaults in a program I've 
written which recently re-appeared (see original discussion here: 
https://groups.google.com/forum/#!topic/julia-users/FV9AmKsZNuk)

It appears that currently these segfaults are caused by the usage of 
SharedArrays (or at least running the code in parallel); if I run the code 
on a single core it runs for days without segfaulting, while in parallel a 
segfault usually occurs within an hour or so of the program running. 
Someone in the other thread mentioned experiencing the same issue.

Has anyone else noticed this/is this a known issue? How would one go about 
de-bugging this sort of thing?


[julia-users] printing datatables

2016-06-15 Thread Erwin Kalvelagen
In https://github.com/JuliaDB/SQLite.jl datatables are printed in a tabular 
format:




while I get something much more ugly:





I was wondering about the difference in appearance. Am I forgetting 
something here or doing something wrong?


Thanks, Erwin






[julia-users] Re: ANN: Delegate.jl, delegation and type re-wrapped delegation

2016-06-15 Thread ggggg
Looks super useful, thanks.

It looks like you let your example get out of date, here is a corrected 
version
using Delegate
import Base: <, <=, +, *, - # later I get WARNING: module Main should 
explicitly import < from Base if I don't import Base:

immutable AnInt
  val::Int
end
int1 = AnInt(1)
int2 = AnInt(2)

@delegate_1field2vars AnInt val [ (<), (<=) ]; # returns <=
@traject_1field2vars  AnInt val [ (+), (-), (*) ]; # returns *

int1+int2 # returns AnInt(3)
int1
> Pkg.clone("https://github.com/Jeffrey-Sarnoff/Delegate.jl;)
>
>  
>
>> using Delegate 
>
> import <, <=, +, *
>
> immutable AnInt
>
> val::Int 
>
> end 
>
>  
>
> int1 = AnInt(1) 
>
> int2 = AnInt(2) 
>
>  
>
> @delegate_1field2vars AnInt.val [ (<), (<=) ];   # plain results
>
> @traject_1field2vars( MyInt, val, [ (+), (-), (*) ] );   # type 
>> re-wrapped results
>
>  
>
> int1 < int2
>
> true 
>
>  
>
> int1 + int2
>
> AnInt(3) 
>
>  
>
>
> Also exports 2field versions and 1var versions.
> More examples are available in the README.md and in the tests.
>
> This is built on the work of John Myles White and Toivo Hennigsson.
>
>

[julia-users] Git submodules vs Julia submodules

2016-06-15 Thread Eric Forgy
Hi,

I have a large private package that depends on many other private packages 
and each smaller package may depends on other private packages. It is a bit 
tangled, but working.

For example:

# A,B,C,D are all private packages
module A

using B, C, D

...

end

with

module D

using B, C

...

end

However, I was having trouble ensuring that my team was using the same 
versions of all these private packages.

So... I got a bright idea to use Git submodules for module A with B,C,D 
being Git submodules.

Now, I changed module A to:

module A

modules = ["B","C","D"]
for mod in modules
include(Pkg.dir("A","src",mod,"src","$mod.jl"))
end

...

end

and I removed modules B,C,D from my package directory.

HOWEVER, module D is still `using B,C`, but I obviously get errors for that 
because B & C are no longer in my package directory.

The, in desperation, I started trying things like:

modules = ["B","C"]
for mod in modules
sym = Symbol(mod)
isdefined(sym) || eval(Expr(:using, sym))
end

and various permutations. 

REQUIRE would seem like a good thing to try, but according to this 
,
 
REQUIRE doesn't work for packages not in METADATA.

Any ideas? Can I use Git submodules for this and somehow get `using` to 
work or punt and stop using `using` in the submodules and just include my 
files in each submodule?

Thank you for any help.






Re: [julia-users] persistent in Julia

2016-06-15 Thread Tamas Papp
Depending on what that "something" is, you may

1. serialize it:
http://docs.julialang.org/en/release-0.4/stdlib/io-network/?highlight=serialize#Base.serialize
Flexible, but format may change between Julia versions.

2. save it using HDF5:
https://github.com/JuliaIO/HDF5.jl
Not as flexible as serialize, but you can read it with other programs,
too, and with future versions of Julia.

3. save it using JLD:
https://github.com/JuliaIO/JLD.jl
which is an extension of HDF5, will preserve more information.

Best,

Tamas

On Wed, Jun 15 2016, chobbes wrote:

> I need to construct something which is a bit expensive. So I want to
> construct it only once and have it stored for further use. In Matlab, this
> is done by 'persistent'. Is there a similar thing in Julia? I searched the
> previous threads and didn't see any relevant discussion. Can anyone advise?
> Thanks!


[julia-users] persistent in Julia

2016-06-15 Thread chobbes158


I need to construct something which is a bit expensive. So I want to 
construct it only once and have it stored for further use. In Matlab, this 
is done by 'persistent'. Is there a similar thing in Julia? I searched the 
previous threads and didn't see any relevant discussion. Can anyone advise? 
Thanks!


[julia-users] Performance of TCPServer

2016-06-15 Thread Andrei Zh
I've just tested performance of TCP server/client in Julia REPL and find 
results pretty disappointing. The server is as simple as: 

server = listen(2000)
while true
sock = accept(server)
begin
while true
@time readbytes(sock, 1024*1024)
end
end
end

It listens on 2000 port for a single connection and than starts reading 
from it chunks of 1Mb. 

Client is not much harder: 

sock = connect(2000)
Mb = rand(UInt8, 1024*1024)   # 1 Mb of data
for i=1:1_000 write(sock, Mb) end

Basically it simply writes 1Gb of data in chunk of 1Mb. When I run these 
snippets in 2 different REPL windows, from the server one I get the 
following: 

  0.393481 seconds (2 allocations: 1.000 MB)
  0.406101 seconds (2 allocations: 1.000 MB)
  0.424946 seconds (2 allocations: 1.000 MB)
  0.410651 seconds (2 allocations: 1.000 MB)
  0.406987 seconds (2 allocations: 1.000 MB)
  0.386872 seconds (2 allocations: 1.000 MB)
  0.38 seconds (40 allocations: 1.001 MB)

I.e. speed of data transfer is about 2.5 Mb/sec. I'm pretty much sure my 
local network interface can do much better. Am I doing something wrong? 






Re: [julia-users] Re: Defining a new numeric type with minimal effort

2016-06-15 Thread Jeffrey Sarnoff
Kevin,

I just announced https://github.com/Jeffrey-Sarnoff/Delegate.jl 

 -- 
it does what you want.

On Saturday, June 11, 2016 at 12:15:23 PM UTC-4, Kevin Squire wrote:
>
> Hi Kevin,
>
> As you're gleaming, you will need to implement a set of basic functions, 
> and that set isn't tiny.  That said, once you implement this minimal set, 
> your type should be usable everywhere else that a Real is accepted (even 
> when that doesn't always make sense).
>
> For some idea of what is needed, check out:
>
> https://github.com/JeffBezanson/FixedPointNumbers.jl
> https://github.com/JuliaDiff/DualNumbers.jl
>
> You also might check out the @delegate macro in DataStructures.jl:
>
> https://github.com/JuliaLang/DataStructures.jl/blob/master/src/delegate.jl
>
> https://github.com/JuliaLang/DataStructures.jl/blob/master/src/default_dict.jl#L52-L54
>
> As for why this isn't more straightforward, check out the section of the 
> docs on Types (especially the 4th paragraph):
>
> http://docs.julialang.org/en/release-0.4/manual/types/#types
>
> That said, I'm curious how you would define a new bitstype (Int, Float, 
> etc.) in other languages?  In Julia, this is at least possible, and when 
> you define the things you need, these are as first class and efficient as 
> Int, Float64, etc.  (Of course, using them with non-Julia libraries might 
> not work if these types don't exist in the language those libraries were 
> written in.)
>
> In fact, all of these (Int64, Float64, etc.) are defined in Julia--none 
> are actually "built-in", so to speak.  As far as I know, there are very few 
> other languages which allow you to define types at this level.  (Examples, 
> anyone?)
>
> Anyway, good luck in your explorations!
>
> Cheers,
>Kevin
>
> On Sat, Jun 11, 2016 at 8:42 AM, Jeffrey Sarnoff  > wrote:
>
>> This way of which you speak, there are whispers ... Let me become strong 
>> with milk of Yak, for I must swim with the Platypus of Insight as dawn 
>> is drawn from  glimmer to glisten.
>> ... .  . . .. ... .. . (writing becomes written) 
>>
>>
>> On Saturday, June 11, 2016 at 11:09:34 AM UTC-4, Kevin Kunzmann wrote:
>>>
>>> Taking your last example to the console, still I cannot add two 
>>> "Probabilities" despite them being instances of a subtype of "Real". What I 
>>> was looking for is the Julian way of thinking about inherited behaviour 
>>> from numeric types. Now, I slowly wrap my mind around the idea that there s 
>>> nothing to inherit...
>>> But srsly, is there no way of making all functions that accept Reals 
>>> also accept Probabilities? I can't reimplement them all, can I? Think of 
>>> *(a,b), sin(a), /(a,b)
>>>
>>> On Saturday, 11 June 2016 09:40:38 UTC+2, Jeffrey Sarnoff wrote:

 , as 'Real' is expecting it to be named 'val'? Jeez,

 No, Real is an abstract type that is closer to being a label sewn to 
 the root of a tree -- Real does not have any investment in how you name 
 the 
 fields of your type.

 There is no way of telling which fileds are accessed how by all methods 
> operating on that type x

 One scenario, you designed the type and determine the sorts of 
 information to be held as fields of the type.  You write specializations 
 of 
 generic methods that pertain to using the type.  In that situation, your 
 actively maintained documentation knows and tells or you revisit your own 
 source code for that knowledge.  In any event, Julia is happy to help, 
 providing you with easily introduced method specific notes.   Another 
 scenario, you did the same thing and I want to use the type.  Well, I'd 
 look at the README.md file and if any, other docs.  Then, knowing the care 
 you take with programming, and seeing from a few simples examples you 
 provide that values of this Probability type are floating point 
 representations of independent likelihoods ...
 I would use the type without any desire to know which field(s) are read 
 or altered in the process of determining the probability than any one of 
 my 
 five experts in origami will hand me a paper swan to drop from up here 
 before the building closes.

 the cleanest way to ensure that I pass a valid probability to my 
> function (figure between 0 and 1)

 Do you want to raise an exception if a value is neither zero nor one 
 nor between zero and one?
 Do you want to clamp negative values to zero and clamp positive values 
 above one to one?
 Or do you want to clamp values that are within, say, -1//4096 .. 
 +4097//4096, and throw an exception outside of that range?

 (in this circumstance, for 'type' use 'immutable' and your typed values 
 will live and move in memory just like Float64 values. without interposed 

Re: [julia-users] Abstract version of rng=1:end ?

2016-06-15 Thread Tim Holy
On Wednesday, June 15, 2016 2:21:01 AM CDT Matthew Pearce wrote:
> Tim, that functionality looks pretty nice, looking forward to playing with
> it.

Well, I'm not sure whether it will ever be merged unless we can come up with a 
way to solve the problem of computation with `end`.

> Yichao's suggestion solves my problem as described. However, what I was
> really interested in was multidimensional arrays, where the index produced
> by `endof` isn't as useful without complicating things with strides.

You may know that the reason that `end` works inside `[]` is because it's 
parseable with respect to the array. An alternative to my plan in that PR is 
to have `@indices A[2:end, 3:5]` return `2:size(A,1), 3:5`. The main problem 
being that the former is not shorter than the latter.

Best,
--Tim



[julia-users] Will it be possible to run julia on a remote server in Atom now?

2016-06-15 Thread AStupidbear
I have seen this post https://github.com/JunoLab/atom-julia-client/issues/8. 
Has it been implemented in atom-julia-client?


[julia-users] ANN: Delegate.jl, delegation and type re-wrapped delegation

2016-06-15 Thread Jeffrey Sarnoff

>
> Pkg.clone("https://github.com/Jeffrey-Sarnoff/Delegate.jl;)

 

> using Delegate 

import <, <=, +, *

immutable AnInt

val::Int 

end 

 

int1 = AnInt(1) 

int2 = AnInt(2) 

 

@delegate_1field2vars AnInt.val [ (<), (<=) ];   # plain results

@traject_1field2vars( MyInt, val, [ (+), (-), (*) ] );   # type re-wrapped 
> results

 

int1 < int2

true 

 

int1 + int2

AnInt(3) 

 


Also exports 2field versions and 1var versions.
More examples are available in the README.md and in the tests.

This is built on the work of John Myles White and Toivo Hennigsson.



Re: [julia-users] Abstract version of rng=1:end ?

2016-06-15 Thread Matthew Pearce
Thanks for the suggestions folks. 

Tim, that functionality looks pretty nice, looking forward to playing with 
it.

Yichao's suggestion solves my problem as described. However, what I was 
really interested in was multidimensional arrays, where the index produced 
by `endof` isn't as useful without complicating things with strides.

Matthew

On Tuesday, June 14, 2016 at 7:00:37 PM UTC+1, Tim Holy wrote:
>
> See https://github.com/JuliaLang/julia/pull/15750. What holds that up is 
> the 
> fact that people sometimes want to do math on `end`, e.g., 
>
> b = a[1:round(Int,sqrt(end))] 
>
> works just fine. 
>
> --Tim 
>
> On Monday, June 13, 2016 8:40:39 AM CDT Dan wrote: 
> > A reason such 'extended' ranges might be good, is the ability to 
> dispatch 
> > on them for efficiency. For example, `deleteat!(vec,5:end)`  could be 
> > implemented faster than just any `deleteat!` of any range. This would be 
> > applicable to other such structures with edge effects. Indeed, we can 
> learn 
> > from mathematics which often embraced infinity for ease of use and 
> > expression. 
> > Again, this complication might not be worth the benefits. 
> > 
> > So how about a half-bounded types of the form: 
> > typeof(5:end) == ExtendedUnitRange{BU}(5) # the BU stands for 
> > Bounded-Unbounded 
> > 
> > a UnboundedUnbounded Unit range could be like `:` meaning unbounded in 
> both 
> > directions. 
> > 
> > To summarize: there are algorithmic optimizations which are enabled by 
> > knowing the operated range spans to the end (or even just up close to 
> the 
> > end by  > It would be interesting to allow these optimization to be taken using 
> > dispatch for static optimization. 
> > 
> > On Monday, June 13, 2016 at 11:05:47 AM UTC-4, Yichao Yu wrote: 
> > > On Mon, Jun 13, 2016 at 10:47 AM, Matthew Pearce  > > 
> > > > wrote: 
> > > > Hello 
> > > > 
> > > > I find myself frequently wishing to define functions that accept a 
> range 
> > > > argument to operate on like: 
> > > > 
> > > > function foo{T}(M::Array{T,1}, rng::UnitRange) 
> > > > 
> > > > return sum(M[rng].^2) 
> > > > 
> > > > end 
> > > > 
> > > > It would be nice to be able to pass in `rng = 1:end`, but this isn't 
> > > 
> > > legal. 
> > > 
> > > > So I need a signature like, 
> > > 
> > > rng=1:endof(M) 
> > > 
> > > > function foo{T}(M::Array{T,1}) 
> > > > 
> > > > foo(M, 1:length(M)) 
> > > > 
> > > > end 
> > > > 
> > > > Is there a way to set `rng` to achieve my intended effect without 
> having 
> > > 
> > > to 
> > > 
> > > > resort to declaring additional functions? 
> > > > 
> > > > Cheers 
> > > > 
> > > > Matthew 
>
>
>

[julia-users] [ANN] Taro v0.3.0

2016-06-15 Thread Avik Sengupta
I'd like to announce a major new release for Taro - the Julia utility belt 
for working with document formats. 

Taro now features a new API to read and write excel files. Earlier, you 
could only dump the contents of a sheet into a dataframe. Now you can read 
and write data cell by cell. This also allows you to read in an excel 
template, and fill in certain cells from the results of a Julia 
computation. 

Since v0.2, Taro has had the ability to generate PDF files from xsl-fo. 
This allows you to dynamically create professional looking PDF reports from 
within Julia. 

Finally, the package now has some nice looking documentation, thanks to 
Documenter and mkdocs.

More here : http://aviks.github.io/Taro.jl/




[julia-users] Re: translation python/ijulia

2016-06-15 Thread Henri Girard
Thanks works fine, in fact I use sagemath(python,matplotlib)
and as I have a lot of programs to translate in ijulia I often fail.
Without your help I couldn't imagine all these modifications.
Julia list is terrific :) Quick and valid answers most the time :)
My code with your suggestions :

using PyPlot
plt=PyPlot
R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
omega=linspace(0,2w)
y=abs(1./(1+im.*omega.*R.*C-omega.*omega.*L.*C));
fig = figure("Angle")
plt.plot(omega, y);
plt.ylabel("z");
plt.xlabel("w");
ax = plt.gca() # get current axes
ax[:set_xlim]((0,2*w));
ax[:set_ylim]((0,10));
plt.grid("on")
plt.title("Pulsation");

Le mercredi 15 juin 2016 08:52:30 UTC+2, Henri Girard a écrit :
>
> Hi,
>
> I would like to transform this python working example into a ijulia 
> program ,
> Any help
> HG
>
> var("w")
> u=1/pi*360;s=1/(pi*360)
> R=100;L=10;C=10E-6
> w=1/(sqrt(L*C));var('omega')
>
> p=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),omega,0,2*w,figsize=4,frame=True,
> fontsize=8,axes=False,color="green") ;show(p)
> print"Pulsation angulaire = ",round(w)," Rad/s"
>
> I tried this but got errors :
> R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
> x=linspace(0,2pi)
> y=(abs(1/(1+im*omega*R*C-omega*omega*L*C)));
> fig = figure("Angle")
> plt.plot(x, y);
> plt.ylabel("z");
> plt.xlabel("w");
> ax = plt.gca() # get current axes
> ax[:set_xlim]((0,2*w));
> ax[:set_ylim]((0,10));
> plt.grid("on")
> plt.title("Pulsation");
>
>
> LoadError: PyError (:PyObject_Call) 
> ValueError(u'x and y must have same first dimension',)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py",
>  line 3154, in plot
> ret = ax.plot(*args, **kwargs)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py",
>  line 1812, in inner
> return func(ax, *args, **kwargs)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py",
>  line 1424, in plot
> for line in self._get_lines(*args, **kwargs):
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 386, in _grab_next_args
> for seg in self._plot_args(remaining, kwargs):
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 364, in _plot_args
> x, y = self._xy_from_xy(x, y)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 223, in _xy_from_xy
> raise ValueError("x and y must have same first dimension")
>
> while loading In[38], in expression starting on line 2
>
>  [inlined code] from /home/pi/.julia/v0.4/PyCall/src/exception.jl:81
>  in pycall at /home/pi/.julia/v0.4/PyCall/src/PyCall.jl:502
>
>
>

[julia-users] Re: translation python/ijulia

2016-06-15 Thread Gabriel Gellner
I imagine you are using something like sympy that is doing a mathematica 
like plot over omega (the var statements)
In which case you need to change the line

x = linspace(0, 2pi)

to

omega = linspace(0, 2*w) # which seems to be the true range from the python 
code, not 2pi

and then you need to change your 

y = ...

bit to use elementwise multiplication (.*) and elementwise division (./) to 
get the two arrays needed for the plot (omega, y) to be the same length.

On Tuesday, June 14, 2016 at 11:52:30 PM UTC-7, Henri Girard wrote:

> Hi,
>
> I would like to transform this python working example into a ijulia 
> program ,
> Any help
> HG
>
> var("w")
> u=1/pi*360;s=1/(pi*360)
> R=100;L=10;C=10E-6
> w=1/(sqrt(L*C));var('omega')
>
> p=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),omega,0,2*w,figsize=4,frame=True,
> fontsize=8,axes=False,color="green") ;show(p)
> print"Pulsation angulaire = ",round(w)," Rad/s"
>
> I tried this but got errors :
> R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
> x=linspace(0,2pi)
> y=(abs(1/(1+im*omega*R*C-omega*omega*L*C)));
> fig = figure("Angle")
> plt.plot(x, y);
> plt.ylabel("z");
> plt.xlabel("w");
> ax = plt.gca() # get current axes
> ax[:set_xlim]((0,2*w));
> ax[:set_ylim]((0,10));
> plt.grid("on")
> plt.title("Pulsation");
>
>
> LoadError: PyError (:PyObject_Call) 
> ValueError(u'x and y must have same first dimension',)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py",
>  line 3154, in plot
> ret = ax.plot(*args, **kwargs)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py",
>  line 1812, in inner
> return func(ax, *args, **kwargs)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py",
>  line 1424, in plot
> for line in self._get_lines(*args, **kwargs):
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 386, in _grab_next_args
> for seg in self._plot_args(remaining, kwargs):
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 364, in _plot_args
> x, y = self._xy_from_xy(x, y)
>   File 
> "/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
>  line 223, in _xy_from_xy
> raise ValueError("x and y must have same first dimension")
>
> while loading In[38], in expression starting on line 2
>
>  [inlined code] from /home/pi/.julia/v0.4/PyCall/src/exception.jl:81
>  in pycall at /home/pi/.julia/v0.4/PyCall/src/PyCall.jl:502
>
>
>

[julia-users] translation python/ijulia

2016-06-15 Thread Henri Girard
Hi,

I would like to transform this python working example into a ijulia program 
,
Any help
HG

var("w")
u=1/pi*360;s=1/(pi*360)
R=100;L=10;C=10E-6
w=1/(sqrt(L*C));var('omega')
p=plot(abs(1/(1+i*omega*R*C-omega*omega*L*C)),omega,0,2*w,figsize=4,frame=True,
fontsize=8,axes=False,color="green") ;show(p)
print"Pulsation angulaire = ",round(w)," Rad/s"

I tried this but got errors :
R=100;L=10;C=10E-6;w=1/(sqrt(L*C));omega=0;
x=linspace(0,2pi)
y=(abs(1/(1+im*omega*R*C-omega*omega*L*C)));
fig = figure("Angle")
plt.plot(x, y);
plt.ylabel("z");
plt.xlabel("w");
ax = plt.gca() # get current axes
ax[:set_xlim]((0,2*w));
ax[:set_ylim]((0,10));
plt.grid("on")
plt.title("Pulsation");


LoadError: PyError (:PyObject_Call) 
ValueError(u'x and y must have same first dimension',)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py",
 line 3154, in plot
ret = ax.plot(*args, **kwargs)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py",
 line 1812, in inner
return func(ax, *args, **kwargs)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py",
 line 1424, in plot
for line in self._get_lines(*args, **kwargs):
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 386, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 364, in _plot_args
x, y = self._xy_from_xy(x, y)
  File 
"/home/pi/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py",
 line 223, in _xy_from_xy
raise ValueError("x and y must have same first dimension")

while loading In[38], in expression starting on line 2

 [inlined code] from /home/pi/.julia/v0.4/PyCall/src/exception.jl:81
 in pycall at /home/pi/.julia/v0.4/PyCall/src/PyCall.jl:502