[julia-users] working with julia in atom - any way to pop-out the console to a new window?

2016-05-10 Thread Alix


Hello,


New user of julia and atom here: I've searched forums far and wide and 
still can't figure this out.


Any way to pop-out the console to a new window?  It seems to me whenever 
you create a new window, it creates a new process. 

While it is awesome to evaluate code inline, sometimes I want to quickly be 
able to do bits in the console and ideally in a separate window to take 
advantage of having multiple monitors.










Re: [julia-users] Re: newbie questions (was undefined reference error)

2016-05-10 Thread Tim Holy
The right way to think about it is that an immutable is like a number: you're 
used to being able to have an array of Float64 and replace those, right? 
You're not redefining the meaning of "5.2", you're overwriting the value stored 
in that slot. Arrays of immutables work exactly the same way: the container is 
not immutable, but the individual values stored in it are. That doesn't 
prevent you from replacing them.

Best,
--Tim

On Tuesday, May 10, 2016 08:43:04 PM Boylan, Ross wrote:
> But if I make an array of immutables I won't be able to change them
> afterwards.  Though I can replace them.
> 
> With the old code except for
> 
> immutable Stuff
> a::Int
> b::Int
> end
> 
> I now have
>  julia> v=Array(TT.Stuff, 2)
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(140124021836848,140124000460928)
>   TT.Stuff(140124048730192,0)
> 
>  julia> v[1].a=44  # what I'd like to do
>  ERROR: type Stuff is immutable
> 
>  julia> v[1]=TT.Stuff(3, 4)  # work-around
>  TT.Stuff(3,4)
> 
> !julia> v
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(3,4)
>   TT.Stuff(140124048730192,0)
> 
> With immutable, is everything in the array laid out contiguous in memory? 
> It seems sort of odd that the type is immutable yet I can overwrite data of
> that type.  I suppose that would only be prohibited if the array were
> immutable.
> 
> Thanks for the tip about using Type to get the zero to work.
> Ross
> 
> 
> From: julia-users@googlegroups.com [julia-users@googlegroups.com] on behalf
> of Cedric St-Jean [cedric.stj...@gmail.com] Sent: Tuesday, May 10, 2016
> 1:20 PM
> To: julia-users
> Subject: [julia-users] Re: newbie questions (was undefined reference error)
> 
> "normal" types are by definition heap-allocated, and are always manipulated
> them through pointers. What you want is
> immutables -composite-types>
> 
> immutable Stuff
> a::Int
> b::Int
> end
> 
> # Also, for zeros to work,
> 
> function zero(x::Type{Stuff})
> Stuff(0, 0)
> end
> 
> 
> On Tuesday, May 10, 2016 at 4:04:37 PM UTC-4, Boylan, Ross wrote:
> I'm puzzled that a type  consisting  only of 2 integers doesn't qualify as
> "bitstype".  Further experiment shows that the array seems to be an array
> of references, I don't know how to implement zero, and generally that I'm a
> bit lost :)  My goal is to get a densely packed array of data.  I assume
> that will use less memory and generate faster code; if not, maybe I should
> change my goal.
> 
> BTW, my real use has a type more heterogeneous than 2 Int's, so a solution
> that uses a 2D array doesn't really generalize appropriately for me.
> 
> module TT
> import Base.zero
> 
> type Stuff
> a::Int
> b::Int
> end
> 
> function zero(x::Stuff)
> Stuff(0, 0)
> end
> 
> end
> 
> julia> v=Array(TT.Stuff, 3)  #as before
>  3-element Array{TT.Stuff,1}:
>   #undef
>   #undef
>   #undef
> 
>  julia> s=TT.Stuff(3, 5)
>  TT.Stuff(3,5)
> 
>  julia> v=fill(s, 2)
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(3,5)
>   TT.Stuff(3,5)
> 
>  julia> s.a=900
>  900
> 
>  julia> v  ###OOPS: every array element points to the same instance
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(900,5)
>   TT.Stuff(900,5)
> 
>  julia> zero(TT.Stuff)  # This is probably what needs to work for zeros() to
> work ERROR: MethodError: `zero` has no method matching
> zero(::Type{TT.Stuff})
> 
> !julia> zero(TT.Stuff(1, 1))  # this at least calls the right c'tor
>  TT.Stuff(0,0)
> 
> Ross
> 
> From: julia...@googlegroups.com
> [julia...@googlegroups.com] on behalf of Lutfullah
> Tomak [tomak...@gmail.com] Sent: Tuesday, May 10,
> 2016 12:04 AM
> To: julia-users
> Subject: [julia-users] undefined reference error
> 
> You need to initialize array entries if you don't have eltype as bitstype.
> Here, undefined reference means you had not initialize the entry. And, full
> type assignment works because it initializes the entry.



Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-10 Thread Tom Breloff
Excellent.  I'll be a science fair legend.

On Tue, May 10, 2016 at 8:57 PM, Scott Jones 
wrote:

> Ok! Thanks!  When I'd used PyPlot directly, it combined two plot() calls
> into a single plot by itself, without me putting a ! anywhere.
>
> Works beautifully now!  (and I had Alex cite you in his code ;-) )
>
> On Tuesday, May 10, 2016 at 8:44:06 PM UTC-4, Tom Breloff wrote:
>>
>> Yup... You're missing a exclamation point. 'plot' creates a new figure,
>> and 'plot!' modifies a figure. If there's not a Plot object as the first
>> argument it will implicitly insert the currently active figure, so the
>> command is essentially 'plot!(current(), ...)'
>>
>> On Tuesday, May 10, 2016, Scott Jones  wrote:
>>
>>> The code and input CSV file are now on GitHub as public gists: (the code
>>> is not as fancy as yours, Alex knows how to do for loops and ifs, and has
>>> learned about creating and pushing to vectors, but not all that fancy stuff
>>> that even I didn't know ;-) )
>>>
>>> https://gist.github.com/ScottPJones/942f00a3a7b29f9504f6f868667dba29
>>> https://gist.github.com/ScottPJones/1e41969afe07ef8b51113cce53c00575
>>>
>>> Do you see anything that I messed up in calling the plotting code, that
>>> makes it make two separate plots instead of one?
>>>
>>> Thanks,
>>> Scott
>>>
>>


[julia-users] Julia text editor on iPad?

2016-05-10 Thread Sheehan Olver

Anyone know of a text editor for the iPad that supports Julia syntax 
highlighting?  I guess ideally this could link into JuliaBox (or another 
SSH server) so that code can be run in Safari/SSH.

(Just got the iPad Pro + Smart Keyboard and it seems fairly useable for 
on-the-go programming...)






Re: [julia-users] Re: newbie questions (was undefined reference error)

2016-05-10 Thread Cedric St-Jean
> It seems sort of odd that the type is immutable yet I can overwrite data 
of that type.  I suppose that would only be prohibited if the array were 
immutable.

It's not the array that's immutable, it's the values contained therein. I 
agree that it's a bit weird to have to replace the whole immutable rather 
than just the field you want. IIRC there are plans to improve on that.

On Tuesday, May 10, 2016 at 6:43:56 PM UTC-4, Kristoffer Carlsson wrote:
>
> Bitstypes are laid out contiguosly in memory. Your "workaround" way is a 
> good way of doing it and will be fast.



Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-10 Thread Scott Jones
Ok! Thanks!  When I'd used PyPlot directly, it combined two plot() calls 
into a single plot by itself, without me putting a ! anywhere.

Works beautifully now!  (and I had Alex cite you in his code ;-) )

On Tuesday, May 10, 2016 at 8:44:06 PM UTC-4, Tom Breloff wrote:
>
> Yup... You're missing a exclamation point. 'plot' creates a new figure, 
> and 'plot!' modifies a figure. If there's not a Plot object as the first 
> argument it will implicitly insert the currently active figure, so the 
> command is essentially 'plot!(current(), ...)'
>
> On Tuesday, May 10, 2016, Scott Jones  
> wrote:
>
>> The code and input CSV file are now on GitHub as public gists: (the code 
>> is not as fancy as yours, Alex knows how to do for loops and ifs, and has 
>> learned about creating and pushing to vectors, but not all that fancy stuff 
>> that even I didn't know ;-) )
>>
>> https://gist.github.com/ScottPJones/942f00a3a7b29f9504f6f868667dba29
>> https://gist.github.com/ScottPJones/1e41969afe07ef8b51113cce53c00575
>>
>> Do you see anything that I messed up in calling the plotting code, that 
>> makes it make two separate plots instead of one?
>>
>> Thanks,
>> Scott
>>
>

Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-10 Thread Tom Breloff
Yup... You're missing a exclamation point. 'plot' creates a new figure, and
'plot!' modifies a figure. If there's not a Plot object as the first
argument it will implicitly insert the currently active figure, so the
command is essentially 'plot!(current(), ...)'

On Tuesday, May 10, 2016, Scott Jones  wrote:

> The code and input CSV file are now on GitHub as public gists: (the code
> is not as fancy as yours, Alex knows how to do for loops and ifs, and has
> learned about creating and pushing to vectors, but not all that fancy stuff
> that even I didn't know ;-) )
>
> https://gist.github.com/ScottPJones/942f00a3a7b29f9504f6f868667dba29
> https://gist.github.com/ScottPJones/1e41969afe07ef8b51113cce53c00575
>
> Do you see anything that I messed up in calling the plotting code, that
> makes it make two separate plots instead of one?
>
> Thanks,
> Scott
>


Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-10 Thread Scott Jones
The code and input CSV file are now on GitHub as public gists: (the code is 
not as fancy as yours, Alex knows how to do for loops and ifs, and has 
learned about creating and pushing to vectors, but not all that fancy stuff 
that even I didn't know ;-) )

https://gist.github.com/ScottPJones/942f00a3a7b29f9504f6f868667dba29
https://gist.github.com/ScottPJones/1e41969afe07ef8b51113cce53c00575

Do you see anything that I messed up in calling the plotting code, that 
makes it make two separate plots instead of one?

Thanks,
Scott


Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-10 Thread Scott Jones
I'm still running into a problem with this, for some reason, it shows two 
separate windows, the first one with marked "Figure 1", with the error 
bars, labels, and the mean, and another one marked "Figure 2", with just 
the median, marked with the squares.

I tried both with a checkout of master and of dev of Plots.jl.
I'm on Julia v0.4.5



Any ideas?

Thanks again!!!

Note: v0.5 is totally hosed at the moment, it seems, I get an error:

*ERROR: LoadError: InitError: type Method has no field func*

* [inlined code] from /Users/scott/.julia/v0.5/Requires/src/Requires.jl:3*

* in (::Requires.##8#9)() at 
/Users/scott/.julia/v0.5/Requires/src/init.jl:17*

* in __init__() at /Users/scott/.julia/v0.5/Requires/src/init.jl:24*

* in _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at 
./loading.jl:174*

* in _require_from_serialized(::Int64, ::Symbol, ::Bool) at 
./loading.jl:202*

* in require(::Symbol) at ./loading.jl:332*

* in stale_cachefile(::String, ::String) at ./loading.jl:562*

* in recompile_stale(::Symbol, ::String) at ./loading.jl:579*

* in _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at 
./loading.jl:173*

* in require(::Symbol) at ./loading.jl:365*

* in include_from_node1(::String) at ./loading.jl:426*

* in eval(::Module, ::Any) at ./boot.jl:230*

*during initialization of module Requires*

*.*



On Monday, May 9, 2016 at 11:09:27 AM UTC-4, Tom Breloff wrote:
>
> I haven't ever needed to plot
>
>
> Wh---whaaat?? ;)
>
> This is pretty straightforward:
>
>
> ​
> ​
> ​
> Note: you might need to checkout master or dev of Plots (I'm on dev)... I 
> can't ever remember when I implemented anything.
>
> On Mon, May 9, 2016 at 10:24 AM, Scott Jones  > wrote:
>
>> My son Alex is building on what he did last year for his science project, 
>> where he used Julia to help do the calculations on the data he'd collected 
>> (basically, he's lazy [in a good way], he'd rather work with his dad to 
>> learn how to program something rather than do all all the basic arithmetic 
>> to calculate things like the averages for his plots, and Julia made it 
>> trivial).
>> This year, in math class, he's learned about calculating also the median, 
>> mode(s), and the ranges, and he'd like to be able to plot the results 
>> directly in Julia (last year, since I didn't know how, he ended up doing 
>> the plotting by hand).
>>
>> He's written a program (with a little help from me) that inputs the data 
>> from a CSV file (thanks, Jacob Quinn, for the CSV.jl package!) that he's 
>> entered with Excel.
>> The data is simply a value, integer 0 - 7 (for the number of digits 
>> remembered correctly after seeing a card with 7 digits for 30 seconds, and 
>> reciting the alphabet).
>>
>> The program first makes of sorted vector of the unique ages in the data 
>> set, and then creates a Vector of Vector of Int, each element having all of 
>> the results for that age.
>> Then it uses that to create 4 vectors, mean_by_age, median_by_age, 
>> low_range, and high_range.
>>
>> What we want to do, is to plot the ages on the X axis, with the results 
>> on the Y axis, as a line segment from the low_range to the high_range (with 
>> the top and bottom marked off with small horizontal lines),
>> and also have plotted mean_by_age, and median_by_age with different 
>> colored lines with different markers (maybe diamonds and squares).
>> He might also want to display the mode(s) for each age (might be nice to 
>> have those done as circles of different radius depending on how many 
>> samples at that mode value)
>>
>> I haven't ever needed to plot, so I haven't been able to help him very 
>> much, so far I'll I've been able to do is just call `plot(ages, 
>> mean_by_age, linewidth=3)` and `plot(ages, median_by_age, linewidth= 3)` do 
>> display two of the things he wants.
>>
>> Any help will be greatly appreciated!
>>
>> Thanks,
>> Scott (proud father of a beginning Julia ;-) )
>>
>>
>>
>

RE: [julia-users] Re: newbie questions (was undefined reference error)

2016-05-10 Thread Kristoffer Carlsson
Bitstypes are laid out contiguosly in memory. Your "workaround" way is a good 
way of doing it and will be fast.

[julia-users] Re: Specify format in writedlm?

2016-05-10 Thread Peter Simon
One way is to round the data prior to writing it:

julia> a = rand(10,5)
10x5 Array{Float64,2}:
 0.806913  0.010713  0.469981  0.419839   0.451575
 0.584154  0.720939  0.444952  0.756981   0.0928572
 0.204909  0.36935   0.122733  0.777961   0.291004
 0.784125  0.490603  0.312298  0.0527099  0.21626
 0.953513  0.245063  0.373179  0.778251   0.127561
 0.102803  0.371336  0.52819   0.652244   0.487652
 0.384086  0.540702  0.431661  0.518019   0.964562
 0.544121  0.732757  0.270263  0.258582   0.615142
 0.517202  0.269335  0.755445  0.390461   0.266775
 0.695753  0.505792  0.508295  0.707993   0.168138


julia> writecsv("testrounded.csv", round(a,3))

shell> cat testrounded.csv
.807,.011,.47,.42,.452
.584,.721,.445,.757,.093
.205,.369,.123,.778,.291
.784,.491,.312,.053,.216
.954,.245,.373,.778,.128
.103,.371,.528,.652,.488
.384,.541,.432,.518,.965
.544,.733,.27,.259,.615
.517,.269,.755,.39,.267
.696,.506,.508,.708,.168


On Tuesday, May 10, 2016 at 11:16:50 AM UTC-7, Jorge Fernández de Cossío 
Díaz wrote:
>
> Is it possible to specify format in writedlm?
>
> Specifically, I want to write a matrix of Floats to a file, but I am only 
> interested in saving a few digits after the decimal point, anything else 
> would take too much disk space for no good reason.
> Is there a way to do this?
>


[julia-users] Re: Write immutable with variable-length array field to a stream

2016-05-10 Thread Andrei Zh
Ah, I should have been more explicit, sorry. This is a protocol for 
existing service (Apache Kafka, if it matters), so I can't actually choose 
a format. 

Anyway, the protocol turned to be quite specific, so I had to craft my own 
serialization routines. And, by the way, it turned to be quite easy: I just 
had to implement serialization for 4 types of things: 

 1. Integers - as simple as encoding number to network encoding and writing 
to stream.
 2. ASCII string - writing length + string data itself.
 3. Arrays - same as strings.
 4. Immutable types - iterate over fields and write them one by one. 

Here's a code snippet for the last point (which seems to be the only 
interesting part): 

function writeobj(io::IO, o)
for f in fieldnames(o)
writeobj(io, getfield(o, f))
end
end
function readobj{T}(io::IO, ::Type{T})
vals = Array(Any, length(T.types))
for (i, t) in enumerate(T.types)
vals[i] = readobj(io, t)
end
return T(vals...)
end


On Tuesday, May 10, 2016 at 11:42:23 PM UTC+3, Jameson wrote:
>
> I recommend going with a standard format such as ProtoBuf.jl, JSON.jl, or 
> other similar product.
>
> On Saturday, May 7, 2016 at 2:31:59 PM UTC-4, Andrei Zh wrote:
>>
>> I work on implementing a binary protocol for a service. This protocol is 
>> based on messages - structs that support integer numbers, variable-length 
>> arrays and other structs, i.e. something we could implement in Julia as:
>>
>> immutable Message1
>> version::Int16
>> length::Int32
>> payload::Array{Message2,1}
>> end
>>
>> Creating a serializer for any such message is trivial, but I have about 
>> 50 of them and would like to automate it, i.e. I'd like a generic way to 
>> write an immutable structure to a stream. So far the closest candidate is 
>> StrPack.jl , but it doesn't 
>> support variable-length array, which is the must for me. 
>>
>> Do we have something for this or I should come up with my own 
>> function/macro? 
>>
>

Re: [julia-users] How fast is appending an element to an array?

2016-05-10 Thread Tim Holy
Since it hasn't been mentioned yet, I'll point out `sizehint!` which can 
eliminate the re-allocations. But this is still slower than setting the 
elements, because it needs to update the length of the array on each `push!`.

Worth benchmarking yourself if it matters to how you design your code.

Best,
--Tim

On Tuesday, May 10, 2016 01:24:28 PM Andrei Zh wrote:
> From performance perspective, how bad it is to use `push!(array, element)`
> compared to pre-allocating array and setting elements in it?
> 
> More generally, how extending arrays works in Julia? (code in array.c
>  is quite
> readable, but some high-level description is appreciated)



Re: [julia-users] How fast is appending an element to an array?

2016-05-10 Thread Ken B
There's an open issue somewhat related for growing an array with factor 
less than 2, in case you feel like an interesting read:
https://github.com/JuliaLang/julia/issues/8269

On Tuesday, 10 May 2016 22:35:43 UTC+2, Yichao Yu wrote:
>
> On Tue, May 10, 2016 at 4:24 PM, Andrei Zh  > wrote: 
> > From performance perspective, how bad it is to use `push!(array, 
> element)` 
> > compared to pre-allocating array and setting elements in it? 
>
> If you know the size ahead of time, always pre allocate it. 
> Resizing the array reuse memory if possible and double the buffer 
> every time (until a relatively large threshold iirc) so the time 
> memory is reallocated is O(log(size of array)). 
>
> Cost of not pre-allocating comes from realloc cost (which is a small 
> constant factor more expensive than pre-allocating) and disabling some 
> optimizations (e.g. a `push!` loop can't (or very hard to) be 
> vectorized (SIMD)). Chances are if it's hard to know the size ahead of 
> time, the compiler doesn't have much room to optimize anyway and since 
> the realloc cost is not particularly high, you might as well use a 
> loop to append elements. 
>
> > 
> > More generally, how extending arrays works in Julia? (code in array.c is 
> > quite readable, but some high-level description is appreciated) 
>


Re: [julia-users] How fast is appending an element to an array?

2016-05-10 Thread Andrei Zh
Very detailed explanation, thank you!

On Tuesday, May 10, 2016 at 11:35:43 PM UTC+3, Yichao Yu wrote:
>
> On Tue, May 10, 2016 at 4:24 PM, Andrei Zh  > wrote: 
> > From performance perspective, how bad it is to use `push!(array, 
> element)` 
> > compared to pre-allocating array and setting elements in it? 
>
> If you know the size ahead of time, always pre allocate it. 
> Resizing the array reuse memory if possible and double the buffer 
> every time (until a relatively large threshold iirc) so the time 
> memory is reallocated is O(log(size of array)). 
>
> Cost of not pre-allocating comes from realloc cost (which is a small 
> constant factor more expensive than pre-allocating) and disabling some 
> optimizations (e.g. a `push!` loop can't (or very hard to) be 
> vectorized (SIMD)). Chances are if it's hard to know the size ahead of 
> time, the compiler doesn't have much room to optimize anyway and since 
> the realloc cost is not particularly high, you might as well use a 
> loop to append elements. 
>
> > 
> > More generally, how extending arrays works in Julia? (code in array.c is 
> > quite readable, but some high-level description is appreciated) 
>


RE: [julia-users] Re: newbie questions (was undefined reference error)

2016-05-10 Thread Boylan, Ross
But if I make an array of immutables I won't be able to change them afterwards. 
 Though I can replace them.

With the old code except for

immutable Stuff
a::Int
b::Int
end

I now have
 julia> v=Array(TT.Stuff, 2)
 2-element Array{TT.Stuff,1}:
  TT.Stuff(140124021836848,140124000460928)
  TT.Stuff(140124048730192,0)

 julia> v[1].a=44  # what I'd like to do
 ERROR: type Stuff is immutable

 julia> v[1]=TT.Stuff(3, 4)  # work-around
 TT.Stuff(3,4)

!julia> v
 2-element Array{TT.Stuff,1}:
  TT.Stuff(3,4)
  TT.Stuff(140124048730192,0)

With immutable, is everything in the array laid out contiguous in memory?  It 
seems sort of odd that the type is immutable yet I can overwrite data of that 
type.  I suppose that would only be prohibited if the array were immutable.

Thanks for the tip about using Type to get the zero to work.
Ross


From: julia-users@googlegroups.com [julia-users@googlegroups.com] on behalf of 
Cedric St-Jean [cedric.stj...@gmail.com]
Sent: Tuesday, May 10, 2016 1:20 PM
To: julia-users
Subject: [julia-users] Re: newbie questions (was undefined reference error)

"normal" types are by definition heap-allocated, and are always manipulated 
them through pointers. What you want is 
immutables

immutable Stuff
a::Int
b::Int
end

# Also, for zeros to work,

function zero(x::Type{Stuff})
Stuff(0, 0)
end


On Tuesday, May 10, 2016 at 4:04:37 PM UTC-4, Boylan, Ross wrote:
I'm puzzled that a type  consisting  only of 2 integers doesn't qualify as 
"bitstype".  Further experiment shows that the array seems to be an array of 
references, I don't know how to implement zero, and generally that I'm a bit 
lost :)  My goal is to get a densely packed array of data.  I assume that will 
use less memory and generate faster code; if not, maybe I should change my goal.

BTW, my real use has a type more heterogeneous than 2 Int's, so a solution that 
uses a 2D array doesn't really generalize appropriately for me.

module TT
import Base.zero

type Stuff
a::Int
b::Int
end

function zero(x::Stuff)
Stuff(0, 0)
end

end

julia> v=Array(TT.Stuff, 3)  #as before
 3-element Array{TT.Stuff,1}:
  #undef
  #undef
  #undef

 julia> s=TT.Stuff(3, 5)
 TT.Stuff(3,5)

 julia> v=fill(s, 2)
 2-element Array{TT.Stuff,1}:
  TT.Stuff(3,5)
  TT.Stuff(3,5)

 julia> s.a=900
 900

 julia> v  ###OOPS: every array element points to the same instance
 2-element Array{TT.Stuff,1}:
  TT.Stuff(900,5)
  TT.Stuff(900,5)

 julia> zero(TT.Stuff)  # This is probably what needs to work for zeros() to 
work
 ERROR: MethodError: `zero` has no method matching zero(::Type{TT.Stuff})

!julia> zero(TT.Stuff(1, 1))  # this at least calls the right c'tor
 TT.Stuff(0,0)

Ross

From: julia...@googlegroups.com 
[julia...@googlegroups.com] on behalf of Lutfullah Tomak 
[tomak...@gmail.com]
Sent: Tuesday, May 10, 2016 12:04 AM
To: julia-users
Subject: [julia-users] undefined reference error

You need to initialize array entries if you don't have eltype as bitstype. 
Here, undefined reference means you had not initialize the entry. And, full 
type assignment works because it initializes the entry.


[julia-users] Re: Write immutable with variable-length array field to a stream

2016-05-10 Thread Jameson
I recommend going with a standard format such as ProtoBuf.jl, JSON.jl, or 
other similar product.

On Saturday, May 7, 2016 at 2:31:59 PM UTC-4, Andrei Zh wrote:
>
> I work on implementing a binary protocol for a service. This protocol is 
> based on messages - structs that support integer numbers, variable-length 
> arrays and other structs, i.e. something we could implement in Julia as:
>
> immutable Message1
> version::Int16
> length::Int32
> payload::Array{Message2,1}
> end
>
> Creating a serializer for any such message is trivial, but I have about 50 
> of them and would like to automate it, i.e. I'd like a generic way to write 
> an immutable structure to a stream. So far the closest candidate is 
> StrPack.jl , but it doesn't 
> support variable-length array, which is the must for me. 
>
> Do we have something for this or I should come up with my own 
> function/macro? 
>


Re: [julia-users] How fast is appending an element to an array?

2016-05-10 Thread Yichao Yu
On Tue, May 10, 2016 at 4:24 PM, Andrei Zh  wrote:
> From performance perspective, how bad it is to use `push!(array, element)`
> compared to pre-allocating array and setting elements in it?

If you know the size ahead of time, always pre allocate it.
Resizing the array reuse memory if possible and double the buffer
every time (until a relatively large threshold iirc) so the time
memory is reallocated is O(log(size of array)).

Cost of not pre-allocating comes from realloc cost (which is a small
constant factor more expensive than pre-allocating) and disabling some
optimizations (e.g. a `push!` loop can't (or very hard to) be
vectorized (SIMD)). Chances are if it's hard to know the size ahead of
time, the compiler doesn't have much room to optimize anyway and since
the realloc cost is not particularly high, you might as well use a
loop to append elements.

>
> More generally, how extending arrays works in Julia? (code in array.c is
> quite readable, but some high-level description is appreciated)


[julia-users] Re: Calling a function when type field changes.

2016-05-10 Thread Jameson
You shouldn't call `eval` in a macro. That's not how macros work or what 
they are for and you'll quickly find out it's not doing what you thought.

On Monday, May 9, 2016 at 12:17:37 AM UTC-4, Yonghee Kim wrote:
>
> I've ended up creating this macro
>
> macro log(ex)
> local field = eval(ex.args[1].args[2]) 
> local var = ex.args[2] 
>   
>   
> if ex.head == :(+=)  
> println("Item ", field, "+", var)
> elseif  ex.head == :(-=)
> println("Item ", field, "-", var)  
> end   
>
> eval(ex)   
>
> end   
>  
>


[julia-users] How fast is appending an element to an array?

2016-05-10 Thread Andrei Zh
>From performance perspective, how bad it is to use `push!(array, element)` 
compared to pre-allocating array and setting elements in it? 

More generally, how extending arrays works in Julia? (code in array.c 
 is quite 
readable, but some high-level description is appreciated)


[julia-users] Re: Does rationalize ever round to zero?

2016-05-10 Thread Jeffrey Sarnoff
You can post it as an issue.

On Tuesday, May 10, 2016 at 4:21:18 PM UTC-4, Jeffrey Sarnoff wrote:
>
> This appears to be a bug.  The docs for rationalize 
>  say 
> rationalize([*Type=Int*, ]*x; tol=eps(x)*) Approximate floating point 
> number x as a Rational number with components of the given integer type. 
> The result will differ from x by no more than tol.
>
> meanwhile, here is a "long way around" that may do what you want 
> (signature and special cases are cribbed from rational.jl)
>
> function rationalized{T<:Integer}(::Type{T}, x::AbstractFloat; 
> tol::Real=eps(x))
> tol < 0 && throw(ArgumentError("negative tolerance'))
> isnan(x) && return zero(T)//zero(T)
> isinf(x) && return (x < 0 ? -one(T) : one(T)) // zero(T)
> rationalize(round(x, floor(Int,abs(log2(tol)
> end
>
>
> On Thursday, May 5, 2016 at 11:13:45 AM UTC-4, James Fairbanks wrote:
>>
>> Hello julia-users,
>>
>> Does rationalize ever return 0//1 for nonzero inputs?
>>
>> 0.0+eps(Float64) is much closer to 0//1 than to 1//1.
>> Why can't I get 0//1 out of rationalize(x) if x != 0.0?
>> Is this to avoid divide by 0 errors when using a/rationalize(x) where 0 < 
>> x < tol?
>>
>> For example on julia v0.4.5 
>> julia> rationalize(0.0)
>> 0//1
>>
>> julia> rationalize(0.0+eps(Float64))
>> 1//4503599627370496
>>
>> julia> rationalize(0.0+eps(Float64);tol=1e-4)
>> 1//1
>>
>> julia> rationalize(0.0+eps(Float64);tol=1e-4)
>> 1//1
>>
>> Thanks,
>> James
>>
>

[julia-users] Re: Does rationalize ever round to zero?

2016-05-10 Thread Jeffrey Sarnoff
This appears to be a bug.  The docs for rationalize 
 say 
rationalize([*Type=Int*, ]*x; tol=eps(x)*) Approximate floating point number
 x as a Rational number with components of the given integer type. The 
result will differ from x by no more than tol.

meanwhile, here is a "long way around" that may do what you want (signature 
and special cases are cribbed from rational.jl)

function rationalized{T<:Integer}(::Type{T}, x::AbstractFloat; 
tol::Real=eps(x))
tol < 0 && throw(ArgumentError("negative tolerance'))
isnan(x) && return zero(T)//zero(T)
isinf(x) && return (x < 0 ? -one(T) : one(T)) // zero(T)
rationalize(round(x, floor(Int,abs(log2(tol)
end


On Thursday, May 5, 2016 at 11:13:45 AM UTC-4, James Fairbanks wrote:
>
> Hello julia-users,
>
> Does rationalize ever return 0//1 for nonzero inputs?
>
> 0.0+eps(Float64) is much closer to 0//1 than to 1//1.
> Why can't I get 0//1 out of rationalize(x) if x != 0.0?
> Is this to avoid divide by 0 errors when using a/rationalize(x) where 0 < 
> x < tol?
>
> For example on julia v0.4.5 
> julia> rationalize(0.0)
> 0//1
>
> julia> rationalize(0.0+eps(Float64))
> 1//4503599627370496
>
> julia> rationalize(0.0+eps(Float64);tol=1e-4)
> 1//1
>
> julia> rationalize(0.0+eps(Float64);tol=1e-4)
> 1//1
>
> Thanks,
> James
>


[julia-users] Re: newbie questions (was undefined reference error)

2016-05-10 Thread Cedric St-Jean
"normal" types are by definition heap-allocated, and are always manipulated 
them through pointers. What you want is immutables 


immutable Stuff
a::Int
b::Int
end

# Also, for zeros to work,

function zero(x::Type{Stuff})
Stuff(0, 0)
end


On Tuesday, May 10, 2016 at 4:04:37 PM UTC-4, Boylan, Ross wrote:
>
> I'm puzzled that a type  consisting  only of 2 integers doesn't qualify as 
> "bitstype".  Further experiment shows that the array seems to be an array 
> of references, I don't know how to implement zero, and generally that I'm a 
> bit lost :)  My goal is to get a densely packed array of data.  I assume 
> that will use less memory and generate faster code; if not, maybe I should 
> change my goal.
>
> BTW, my real use has a type more heterogeneous than 2 Int's, so a solution 
> that uses a 2D array doesn't really generalize appropriately for me.
>
> module TT
> import Base.zero
>
> type Stuff
> a::Int
> b::Int
> end
>
> function zero(x::Stuff)
> Stuff(0, 0)
> end
>
> end
>
> julia> v=Array(TT.Stuff, 3)  #as before
>  3-element Array{TT.Stuff,1}:
>   #undef
>   #undef
>   #undef
>
>  julia> s=TT.Stuff(3, 5)
>  TT.Stuff(3,5)
>
>  julia> v=fill(s, 2)
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(3,5)
>   TT.Stuff(3,5)
>
>  julia> s.a=900
>  900
>
>  julia> v  ###OOPS: every array element points to the same instance
>  2-element Array{TT.Stuff,1}:
>   TT.Stuff(900,5)
>   TT.Stuff(900,5)
>
>  julia> zero(TT.Stuff)  # This is probably what needs to work for zeros() 
> to work
>  ERROR: MethodError: `zero` has no method matching zero(::Type{TT.Stuff})
>
> !julia> zero(TT.Stuff(1, 1))  # this at least calls the right c'tor
>  TT.Stuff(0,0)
>
>
> Ross
> 
> From: julia...@googlegroups.com  [julia...@googlegroups.com 
> ] on behalf of Lutfullah Tomak [tomak...@gmail.com 
> ]
> Sent: Tuesday, May 10, 2016 12:04 AM
> To: julia-users
> Subject: [julia-users] undefined reference error
>
> You need to initialize array entries if you don't have eltype as bitstype. 
> Here, undefined reference means you had not initialize the entry. And, full 
> type assignment works because it initializes the entry.
>
>

Re: [julia-users] Re: static compilation

2016-05-10 Thread Jameson
The compile-all flag is only partially functional on v0.4. I think it's 
best to just leave it off. I tested on master and fixed a bug with emitting 
`@ccallable`, but that's unrelated. From the command line below, it looks 
like you are not adding any code to the system image (`--eval nothing`) 
which would also means there are no `ccallable` declarations being emitted 
into the current compile.

Other than that, I don't see anything wrong with that command. You 
shouldn't see that error unless you tried to make a Task or use `@async` 
from the compile host. It's ambiguous how that would be serialized, so it's 
simply an error and any parallel workers should be created / started by an 
`__init__` method.


On Tuesday, May 10, 2016 at 2:53:22 AM UTC-4, Ján Adamčák wrote:
>
> Hello guys, 
>
> Thank you for your comments, though we were more optimistic...
>
>
> Dňa piatok, 6. mája 2016 16:27:28 UTC+2 Ján Adamčák napísal(-a):
>>
>> Sorry, my fault. 
>>
>> During last week I created build_sysimg2.jl from julia 0.4.5 
>> build_sysimg.jl and when I run it, at line 86 (build_sysimg2.jl)
>>
>> run(`$julia -C $cpu_target --output-o sysimg_all.o --sysimage 
>> $sysimg_path.$(Libdl.dlext) --startup-file=no --compile=all --eval nothing`)
>>
>> I got this error:
>>
>> fatal: error thrown and no exception handler available.
>> ErrorException("Task cannot be serialized")
>> jl_unprotect_stack at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_throw at C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll 
>> (unknown line)
>> jl_error at C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll 
>> (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_compress_ast at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_save_system_image_to_stream at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_create_system_image at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> jl_atexit_hook at 
>> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
>> unknown function (ip: 004028B5)
>> unknown function (ip: 0040140C)
>> unknown function (ip: 0040153B)
>> BaseThreadInitThunk at C:\WINDOWS\system32\KERNEL32.DLL (unknown line)
>> RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
>> ERROR: LoadError: failed process: 
>> Process(`'C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\julia' 

[julia-users] newbie questions (was undefined reference error)

2016-05-10 Thread Boylan, Ross
I'm puzzled that a type  consisting  only of 2 integers doesn't qualify as 
"bitstype".  Further experiment shows that the array seems to be an array of 
references, I don't know how to implement zero, and generally that I'm a bit 
lost :)  My goal is to get a densely packed array of data.  I assume that will 
use less memory and generate faster code; if not, maybe I should change my goal.

BTW, my real use has a type more heterogeneous than 2 Int's, so a solution that 
uses a 2D array doesn't really generalize appropriately for me.

module TT
import Base.zero

type Stuff
a::Int
b::Int
end

function zero(x::Stuff)
Stuff(0, 0)
end

end

julia> v=Array(TT.Stuff, 3)  #as before
 3-element Array{TT.Stuff,1}:
  #undef
  #undef
  #undef

 julia> s=TT.Stuff(3, 5)
 TT.Stuff(3,5)

 julia> v=fill(s, 2)
 2-element Array{TT.Stuff,1}:
  TT.Stuff(3,5)
  TT.Stuff(3,5)

 julia> s.a=900
 900

 julia> v  ###OOPS: every array element points to the same instance
 2-element Array{TT.Stuff,1}:
  TT.Stuff(900,5)
  TT.Stuff(900,5)

 julia> zero(TT.Stuff)  # This is probably what needs to work for zeros() to 
work
 ERROR: MethodError: `zero` has no method matching zero(::Type{TT.Stuff})

!julia> zero(TT.Stuff(1, 1))  # this at least calls the right c'tor
 TT.Stuff(0,0)


Ross

From: julia-users@googlegroups.com [julia-users@googlegroups.com] on behalf of 
Lutfullah Tomak [tomaklu...@gmail.com]
Sent: Tuesday, May 10, 2016 12:04 AM
To: julia-users
Subject: [julia-users] undefined reference error

You need to initialize array entries if you don't have eltype as bitstype. 
Here, undefined reference means you had not initialize the entry. And, full 
type assignment works because it initializes the entry.


Re: [julia-users] Anonymous Function Behavior

2016-05-10 Thread Yichao Yu
On Tue, May 10, 2016 at 2:22 PM,   wrote:
> Watch this.
>
> We define an array:
> a = collect(-1:0.001:1)
>
> Then map something over the aforementioned array for the first time:
> @time map(x->10^x, a)
> # 0.049258 seconds
>
> Do it again so that we don't capture JIT compilation time:

This doesn't work

> @time map(x->10^x, a)

Since this is a different anonymous function.

> # 0.048793 seconds -- didn't change much
>
> Now we assign the anonymous function to a variable:
> f = x->10^x
>
> Then we map the variable over the array:
> @time map(f, a)
> # 0.047853 seconds
>
> Again so that we avoid JIT:

It works this time

> @time map(f, a)

Since this is the same anonymous function

> # 0.000386 seconds -- wow
>
> What is happening here?
> Why does assigning an anonymous function to a variable makes the function
> execution so much faster?
>
>
> Yousef


[julia-users] Re: JuliaOpt for nonlinear constrained optimization with around 500 variables

2016-05-10 Thread Jorge Fernández de Cossío Díaz
Thanks for pointing out the julia-opt list, I will post this question there.


On Tuesday, May 10, 2016 at 2:28:13 PM UTC-4, Miles Lubin wrote:
>
> Hi Jorge,
>
> Gurobi is a state of the art solver. If your problem falls into a class 
> supported by gurobi (e.g., convex quadratic), then you can rely on the 
> results. Using Julia to specify the problem has a minimal effect on the 
> solution time, specifically only in some preprocessing and generating data 
> structures to feed to the solver. If you'd like to understand why a 
> particular piece of code is running more slowly than you expect, feel free 
> to post a standalone, executable sample to here or the julia-opt list.
>
> Miles
>
> On Tuesday, May 10, 2016 at 10:30:00 AM UTC-4, Jorge Fernández de Cossío 
> Díaz wrote:
>>
>> I want to use JuliaOpt to solve a constrained optimization problem with 
>> around 500 variables. There are around 200 constrains, most are linear, 
>> only a couple are nonlinear.
>> I have Gurobi. I am looking for benchmarks of JuliaOpt/Gurobi on systems 
>> of this size, including nonlinear constrains, to build some confidence or 
>> not on the results that I am obtaining. Has anyone performed such tests?
>>
>

[julia-users] Re: JuliaOpt for nonlinear constrained optimization with around 500 variables

2016-05-10 Thread Jorge Fernández de Cossío Díaz
Also, how much RAM or time should I expect these computations to consume?

On Tuesday, May 10, 2016 at 10:30:00 AM UTC-4, Jorge Fernández de Cossío 
Díaz wrote:
>
> I want to use JuliaOpt to solve a constrained optimization problem with 
> around 500 variables. There are around 200 constrains, most are linear, 
> only a couple are nonlinear.
> I have Gurobi. I am looking for benchmarks of JuliaOpt/Gurobi on systems 
> of this size, including nonlinear constrains, to build some confidence or 
> not on the results that I am obtaining. Has anyone performed such tests?
>


[julia-users] Re: JuliaOpt for nonlinear constrained optimization with around 500 variables

2016-05-10 Thread Miles Lubin
Hi Jorge,

Gurobi is a state of the art solver. If your problem falls into a class 
supported by gurobi (e.g., convex quadratic), then you can rely on the 
results. Using Julia to specify the problem has a minimal effect on the 
solution time, specifically only in some preprocessing and generating data 
structures to feed to the solver. If you'd like to understand why a 
particular piece of code is running more slowly than you expect, feel free 
to post a standalone, executable sample to here or the julia-opt list.

Miles

On Tuesday, May 10, 2016 at 10:30:00 AM UTC-4, Jorge Fernández de Cossío 
Díaz wrote:
>
> I want to use JuliaOpt to solve a constrained optimization problem with 
> around 500 variables. There are around 200 constrains, most are linear, 
> only a couple are nonlinear.
> I have Gurobi. I am looking for benchmarks of JuliaOpt/Gurobi on systems 
> of this size, including nonlinear constrains, to build some confidence or 
> not on the results that I am obtaining. Has anyone performed such tests?
>


[julia-users] Re: JuliaOpt for nonlinear constrained optimization with around 500 variables

2016-05-10 Thread Jorge Fernández de Cossío Díaz
Also, how much RAM or time should I expect these computations to last?


On Tuesday, May 10, 2016 at 10:30:00 AM UTC-4, Jorge Fernández de Cossío 
Díaz wrote:
>
> I want to use JuliaOpt to solve a constrained optimization problem with 
> around 500 variables. There are around 200 constrains, most are linear, 
> only a couple are nonlinear.
> I have Gurobi. I am looking for benchmarks of JuliaOpt/Gurobi on systems 
> of this size, including nonlinear constrains, to build some confidence or 
> not on the results that I am obtaining. Has anyone performed such tests?
>


[julia-users] Anonymous Function Behavior

2016-05-10 Thread yousef . k . alhammad
Watch this.

We define an array:
a = collect(-1:0.001:1)

Then map something over the aforementioned array for the first time:
@time map(x->10^x, a) 
# 0.049258 seconds

Do it again so that we don't capture JIT compilation time:
@time map(x->10^x, a) 
# *0.048793 seconds* -- didn't change much

Now we assign the anonymous function to a variable:
f = x->10^x

Then we map the variable over the array:
@time map(f, a)
# 0.047853 seconds

Again so that we avoid JIT:
@time map(f, a)
# *0.000386 seconds *-- wow

What is happening here?
Why does assigning an anonymous function to a variable makes the function 
execution so much faster?


Yousef


[julia-users] Specify format in writedlm?

2016-05-10 Thread Jorge Fernández de Cossío Díaz
Is it possible to specify format in writedlm?

Specifically, I want to write a matrix of Floats to a file, but I am only 
interested in saving a few digits after the decimal point, anything else 
would take too much disk space for no good reason.
Is there a way to do this?


[julia-users] Re: Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread Scott Jones
Mike Innes just helped us come up with a neat little hack, that let me 
capture the file and line # info in a macro (it really *shouldn't* require 
a hack though, something needs to be done to fix #9577).

_lin(a::Expr) = a.args[2].args[1].args[1]
_fil(a::Expr) = string(a.args[2].args[1].args[2])
_err(a::Expr) = a.args[2].args[2]

macro warn(a)
quote
log(Warning, $(esc(:Symbol))($(_fil(a))), $(_lin(a)), $(_err(a)))
end
end


and it is called with this way:

const ERR_STATUS_CODE = 42
...
@warn(()->ERR_STATUS_CODE)


The anonymous function is never even created, it's just parsed, and has the 
file/line info added, and then the macro code grabs the information placed 
there.


On Tuesday, May 10, 2016 at 6:16:20 AM UTC-4, FANG Colin wrote:
>
> I am debugging some code.
>
> I would like to insert some markup function/macro in my code, so that I 
> know my code at least works fine until certain line number 
>


Re: [julia-users] Unpredictable copying of data structures

2016-05-10 Thread David Dill
Stephen,

Thanks!  The "let" translation below makes it clear.

Is there an explanation of the semantics of Julia at that level of detail 
somewhere?  I wasn't able to find anything like this in the manual.

I like Julia a lot, but one of my concerns is a lack of precision in the 
documentation and apparent lack of a written language definition.  Or maybe 
I just haven't found the right sections/documents.


On Friday, May 6, 2016 at 6:40:41 PM UTC-7, Steven G. Johnson wrote:
>
>
>
> On Friday, May 6, 2016 at 2:18:42 PM UTC-4, David Dill wrote: 
>>
>> It's a bit surprising that, if d1 is mentioned for the first time in d1 = 
>> d2 = Dict() in f7 below, the inferred type of d1 is different from the 
>> inferred type of d2, especially since the inferred type is different in d8.
>>
>  
> The type of d2 isn't inferred -- you explicitly declared it as 
> Dict{Int,Int} in the line above.
>
> As for d1, the key thing to remember is that the value of an assignment 
> operation is equal to the *right-hand* side.   That is, in a=b=c, c is 
> assigned to both a and b.  More explicitly, in your example, d1 = d2 = 
> Dict() is equivalent to
>
>  let temp = Dict() # gives a Dict{Any,Any}
>  d2 = temp   # requires a conversion (hence a copy) since d2 was 
> declared as Dict{Int,Int}
>  d1 = temp   # since d1's type was not declared, it is inferred to 
> be that of temp, hence no copy is needed
>  end
>


Re: [julia-users] Re: Newbie Question: Command Line Woes

2016-05-10 Thread Rich Scissors
Worth a lot. I had forgot what REPL stood for. Thanks

On Tue, May 10, 2016 at 11:18 AM, Yichao Yu  wrote:

> On Tue, May 10, 2016 at 11:04 AM, Tom Breloff  wrote:
> > Rich: The return values from the REPL are implicitly displayed.  To do
> this
> > in a script you have to call display(five()), or show/print.  It would be
> > really bad/annoying if every value was printed to the screen during a
> > script...
>
> FWIW, this is what the `P` in `REPL` stands for...
>
> >
> > See: http://docs.julialang.org/en/release-0.4/stdlib/io-network/
> >
> > On Tue, May 10, 2016 at 11:00 AM,  wrote:
> >>
> >> Cedric,
> >>   Thanks very much. That works for the hello() function, but not exactly
> >> for the five() function. For instance, if I have
> >>
> >>  function five()
> >> return 5
> >> end
> >> five()
> >>
> >> Then I get no output when calling from the Command Line, while I do in
> the
> >> REPL. In fact, in the REPL I get the output after include("five.jl") and
> >> then again when I call five(). That make sense to me. To get output at
> the
> >> Command Line I need to replace "five()" with "println(five())" or
> change the
> >> "return 5" statement to "return println(5)". Why is there the
> difference in
> >> behaviors? It's not a big deal, but it does seem like an inconsistency
> in
> >> how functions behave in the REPL and at the command line.
> >>
> >> I seem to remember encountering a difference in behavior between the
> REPL
> >> and IJulia. Is there a document the lists the differences in Command
> Line,
> >> REPL, and IJulia environments.
> >>
> >> Thanks,
> >> Rich
> >>
> >> On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote:
> >>>
> >>> hello.jl defines the hello() function, but you need to call it to get
> >>> some output.
> >>>
> >>>
> >>> function hello()
> >>>println("Hello World")
> >>>  return
> >>> end
> >>>
> >>> hello()
> >>> hello()
> >>>
> >>> will print "Hello World" twice.
> >>>
> >>> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote:
> 
>  Newbie question: Why don't I get any output from the following
> programs
>  when I run them from the command line on my Macbook pro (OS 10.11.4)
> or two
>  different versions of Linux. Everything works as expected when the
> programs
>  are run in the REPL.
> 
>  On the Mac I use the following in my PATH.
> 
>  /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin
> 
>  Command line: julia hello.jl
>  function hello()
>  println("Hello World")
>  return
>  end
> 
>  Command line: julia five.jl
>  function five()
>  return 5
>  end
> 
>  The scripts run fine with no apparent errors or warnings. They just
>  don't produce any output.
> 
>  Thanks,
>  Rich
> >
> >
>


Re: [julia-users] Re: Newbie Question: Command Line Woes

2016-05-10 Thread Yichao Yu
On Tue, May 10, 2016 at 11:04 AM, Tom Breloff  wrote:
> Rich: The return values from the REPL are implicitly displayed.  To do this
> in a script you have to call display(five()), or show/print.  It would be
> really bad/annoying if every value was printed to the screen during a
> script...

FWIW, this is what the `P` in `REPL` stands for...

>
> See: http://docs.julialang.org/en/release-0.4/stdlib/io-network/
>
> On Tue, May 10, 2016 at 11:00 AM,  wrote:
>>
>> Cedric,
>>   Thanks very much. That works for the hello() function, but not exactly
>> for the five() function. For instance, if I have
>>
>>  function five()
>> return 5
>> end
>> five()
>>
>> Then I get no output when calling from the Command Line, while I do in the
>> REPL. In fact, in the REPL I get the output after include("five.jl") and
>> then again when I call five(). That make sense to me. To get output at the
>> Command Line I need to replace "five()" with "println(five())" or change the
>> "return 5" statement to "return println(5)". Why is there the difference in
>> behaviors? It's not a big deal, but it does seem like an inconsistency in
>> how functions behave in the REPL and at the command line.
>>
>> I seem to remember encountering a difference in behavior between the REPL
>> and IJulia. Is there a document the lists the differences in Command Line,
>> REPL, and IJulia environments.
>>
>> Thanks,
>> Rich
>>
>> On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote:
>>>
>>> hello.jl defines the hello() function, but you need to call it to get
>>> some output.
>>>
>>>
>>> function hello()
>>>println("Hello World")
>>>  return
>>> end
>>>
>>> hello()
>>> hello()
>>>
>>> will print "Hello World" twice.
>>>
>>> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote:

 Newbie question: Why don't I get any output from the following programs
 when I run them from the command line on my Macbook pro (OS 10.11.4) or two
 different versions of Linux. Everything works as expected when the programs
 are run in the REPL.

 On the Mac I use the following in my PATH.

 /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin

 Command line: julia hello.jl
 function hello()
 println("Hello World")
 return
 end

 Command line: julia five.jl
 function five()
 return 5
 end

 The scripts run fine with no apparent errors or warnings. They just
 don't produce any output.

 Thanks,
 Rich
>
>


[julia-users] Re: Newbie Question: Command Line Woes

2016-05-10 Thread rich2 . 7182
Cedric,
  Thanks very much. That works for the hello() function, but not exactly 
for the five() function. For instance, if I have

 function five()
return 5
end
five()

Then I get no output when calling from the Command Line, while I do in the 
REPL. In fact, in the REPL I get the output after include("five.jl") and 
then again when I call five(). That make sense to me. To get output at the 
Command Line I need to replace "five()" with "println(five())" or change 
the "return 5" statement to "return println(5)". Why is there the 
difference in behaviors? It's not a big deal, but it does seem like an 
inconsistency in how functions behave in the REPL and at the command line.

I seem to remember encountering a difference in behavior between the REPL 
and IJulia. Is there a document the lists the differences in Command Line, 
REPL, and IJulia environments.

Thanks,
Rich

On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote:
>
> hello.jl defines the hello() function, but you need to call it to get some 
> output. 
>

> function hello()
>println("Hello World")
>  return
> end
>
> hello()
> hello()
>
> will print "Hello World" twice.
>
> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote:
>>
>> Newbie question: Why don't I get any output from the following programs 
>> when I run them from the command line on my Macbook pro (OS 10.11.4) or two 
>> different versions of Linux. Everything works as expected when the programs 
>> are run in the REPL. 
>>
>> On the Mac I use the following in my PATH. 
>>
>> /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin
>>
>> Command line: julia hello.jl
>> function hello()
>> println("Hello World")
>> return
>> end
>>
>> Command line: julia five.jl
>> function five()
>> return 5
>> end
>>
>> The scripts run fine with no apparent errors or warnings. They just don't 
>> produce any output. 
>>
>> Thanks,
>> Rich
>>
>

Re: [julia-users] Re: Newbie Question: Command Line Woes

2016-05-10 Thread rich2 . 7182
Tom,
  That makes sense. Thanks.
Rich

On Tuesday, May 10, 2016 at 11:04:13 AM UTC-4, Tom Breloff wrote:
>
> Rich: The return values from the REPL are implicitly displayed.  To do 
> this in a script you have to call display(five()), or show/print.  It would 
> be really bad/annoying if every value was printed to the screen during a 
> script...
>
> See: http://docs.julialang.org/en/release-0.4/stdlib/io-network/
>
> On Tue, May 10, 2016 at 11:00 AM,  
> wrote:
>
>> Cedric,
>>   Thanks very much. That works for the hello() function, but not exactly 
>> for the five() function. For instance, if I have
>>
>>  function five()
>> return 5
>> end
>> five()
>>
>> Then I get no output when calling from the Command Line, while I do in 
>> the REPL. In fact, in the REPL I get the output after include("five.jl") 
>> and then again when I call five(). That make sense to me. To get output at 
>> the Command Line I need to replace "five()" with "println(five())" or 
>> change the "return 5" statement to "return println(5)". Why is there the 
>> difference in behaviors? It's not a big deal, but it does seem like an 
>> inconsistency in how functions behave in the REPL and at the command line.
>>
>> I seem to remember encountering a difference in behavior between the REPL 
>> and IJulia. Is there a document the lists the differences in Command Line, 
>> REPL, and IJulia environments.
>>
>> Thanks,
>> Rich
>>
>> On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote:
>>>
>>> hello.jl defines the hello() function, but you need to call it to get 
>>> some output. 
>>>
>>
>>> function hello()
>>>println("Hello World")
>>>  return
>>> end
>>>
>>> hello()
>>> hello()
>>>
>>> will print "Hello World" twice.
>>>
>>> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote:

 Newbie question: Why don't I get any output from the following programs 
 when I run them from the command line on my Macbook pro (OS 10.11.4) or 
 two 
 different versions of Linux. Everything works as expected when the 
 programs 
 are run in the REPL. 

 On the Mac I use the following in my PATH. 

 /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin

 Command line: julia hello.jl
 function hello()
 println("Hello World")
 return
 end

 Command line: julia five.jl
 function five()
 return 5
 end

 The scripts run fine with no apparent errors or warnings. They just 
 don't produce any output. 

 Thanks,
 Rich

>>>
>

[julia-users] Re: using subscripts \_1, \_2, ... as field names

2016-05-10 Thread Tim Wheeler
I would love to see a₁ automatically call getindex(a, 1). It would make 
math easier.

I'd love to be able to write:

b = μ₂ + Σ₁₂*(a₁ - μ₁)/Σ₁₁
Λ = Σ₂₂ - Σ₁₂*Σ₁₂/Σ₁₁

for μ::Vector{F<:Real}
and Σ::Matrix{F<:Real}

Σ could be accessed via Σ₁₁ to get Σ[1,1]. Of course this breaks down with 
digits larger than 9, but you probably don't want to be using this feature 
for such large values.




On Tuesday, May 10, 2016 at 1:56:16 AM UTC-7, Davide Lasagna wrote:
>
> Hi, 
>
> I have a custom type representing a bordered matrix (a big square matrix, 
> bordered by two vectors and a scalar in the bottom right corner), where the 
> four blocks are stored in separated chunks of memory. I would like to call 
> the fields of my type using subscripts \_1\_1, \_1\_2, ... so that I can 
> nicely access them as A.11, A.12, ... However, it seems that subscripts 
> (and superscripts) with digits can't be used for variable names, resulting 
> in a syntax error.  Subscripts with letters work fine. 
>
> Any thoughts on this? 
>


Re: [julia-users] Re: Newbie Question: Command Line Woes

2016-05-10 Thread Tom Breloff
Rich: The return values from the REPL are implicitly displayed.  To do this
in a script you have to call display(five()), or show/print.  It would be
really bad/annoying if every value was printed to the screen during a
script...

See: http://docs.julialang.org/en/release-0.4/stdlib/io-network/

On Tue, May 10, 2016 at 11:00 AM,  wrote:

> Cedric,
>   Thanks very much. That works for the hello() function, but not exactly
> for the five() function. For instance, if I have
>
>  function five()
> return 5
> end
> five()
>
> Then I get no output when calling from the Command Line, while I do in the
> REPL. In fact, in the REPL I get the output after include("five.jl") and
> then again when I call five(). That make sense to me. To get output at the
> Command Line I need to replace "five()" with "println(five())" or change
> the "return 5" statement to "return println(5)". Why is there the
> difference in behaviors? It's not a big deal, but it does seem like an
> inconsistency in how functions behave in the REPL and at the command line.
>
> I seem to remember encountering a difference in behavior between the REPL
> and IJulia. Is there a document the lists the differences in Command Line,
> REPL, and IJulia environments.
>
> Thanks,
> Rich
>
> On Monday, May 9, 2016 at 11:02:43 PM UTC-4, Cedric St-Jean wrote:
>>
>> hello.jl defines the hello() function, but you need to call it to get
>> some output.
>>
>
>> function hello()
>>println("Hello World")
>>  return
>> end
>>
>> hello()
>> hello()
>>
>> will print "Hello World" twice.
>>
>> On Monday, May 9, 2016 at 10:59:05 PM UTC-4, rich2...@gmail.com wrote:
>>>
>>> Newbie question: Why don't I get any output from the following programs
>>> when I run them from the command line on my Macbook pro (OS 10.11.4) or two
>>> different versions of Linux. Everything works as expected when the programs
>>> are run in the REPL.
>>>
>>> On the Mac I use the following in my PATH.
>>>
>>> /Applications/Julia-0.4.5.app/Contents/Resources/julia/bin
>>>
>>> Command line: julia hello.jl
>>> function hello()
>>> println("Hello World")
>>> return
>>> end
>>>
>>> Command line: julia five.jl
>>> function five()
>>> return 5
>>> end
>>>
>>> The scripts run fine with no apparent errors or warnings. They just
>>> don't produce any output.
>>>
>>> Thanks,
>>> Rich
>>>
>>


[julia-users] JuliaOpt for nonlinear constrained optimization with around 500 variables

2016-05-10 Thread Jorge Fernández de Cossío Díaz
I want to use JuliaOpt to solve a constrained optimization problem with 
around 500 variables. There are around 200 constrains, most are linear, 
only a couple are nonlinear.
I have Gurobi. I am looking for benchmarks of JuliaOpt/Gurobi on systems of 
this size, including nonlinear constrains, to build some confidence or not 
on the results that I am obtaining. Has anyone performed such tests?


Re: [julia-users] Re: Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread FANG Colin
Thank you!

On Tuesday, May 10, 2016 at 3:20:48 PM UTC+1, Isaiah wrote:
>
> Use `@__LINE__` and `@__FILE__`.
>
> (note, however, `@__LINE__` does not work when used within another macro, 
> see https://github.com/JuliaLang/julia/issues/9577)
>
> On Tue, May 10, 2016 at 6:25 AM, FANG Colin  > wrote:
>
>> Currently I am using
>>
>> macro markup(line_number)
>> println("compile time OK: #$(line_number)")
>> quote
>> x = $(esc(line_number))
>> println("run time OK: #$x")
>> end
>> end
>>
>> For example
>>
>> I want to debug a function "to_debug".
>>
>> function to_debug()
>> @markup(1)
>> end
>>
>> compile time OK: #1
>>
>>
>> to_debug()
>>
>>
>> run time OK: #1
>>
>>
>>
>>
>>
>>
>>
>>
>> On Tuesday, May 10, 2016 at 11:16:20 AM UTC+1, FANG Colin wrote:
>>>
>>> I am debugging some code.
>>>
>>> I would like to insert some markup function/macro in my code, so that I 
>>> know my code at least works fine until certain line number 
>>>
>>
>

Re: [julia-users] using subscripts \_1, \_2, ... as field names

2016-05-10 Thread Eric Forgy
Maybe you could override getindex so that A[1,1] is the interior nxn matrix, 
A[1,2] and A[2,1] are the bounding vectors and A[2,2] is the scalar?

Re: [julia-users] Re: Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread Isaiah Norton
Use `@__LINE__` and `@__FILE__`.

(note, however, `@__LINE__` does not work when used within another macro,
see https://github.com/JuliaLang/julia/issues/9577)

On Tue, May 10, 2016 at 6:25 AM, FANG Colin  wrote:

> Currently I am using
>
> macro markup(line_number)
> println("compile time OK: #$(line_number)")
> quote
> x = $(esc(line_number))
> println("run time OK: #$x")
> end
> end
>
> For example
>
> I want to debug a function "to_debug".
>
> function to_debug()
> @markup(1)
> end
>
> compile time OK: #1
>
>
> to_debug()
>
>
> run time OK: #1
>
>
>
>
>
>
>
>
> On Tuesday, May 10, 2016 at 11:16:20 AM UTC+1, FANG Colin wrote:
>>
>> I am debugging some code.
>>
>> I would like to insert some markup function/macro in my code, so that I
>> know my code at least works fine until certain line number 
>>
>


Re: [julia-users] Cannot pull with rebase...?

2016-05-10 Thread Andres Joaquin Calderon Vergara
Hey Alex, 

I dont have much experience with this, could you please point out the steps 
to add that patch to the METADATA git repo?

Many thanks,

Andres J.

El jueves, 17 de marzo de 2016, 13:17:28 (UTC), Alex Cooper escribió:
>
> I got the same issue on julia-0.4.3-win64. It's a problem with windows git 
> not dealing with files that have unix file permissions set to 755.
>
> First, you might need to switch to ~/.julia/v0.4/METADATA and abort the 
> rebase (git rebase --abort). 
>
> Then, the following patch applied to the METADATA git repo will do the 
> trick.
>
> diff --git a/FixedEffectModels/versions/0.1.0/requires 
> b/FixedEffectModels/versions/0.1.0/requires
> old mode 100755
> new mode 100644
> diff --git a/FixedEffectModels/versions/0.1.1/requires 
> b/FixedEffectModels/versions/0.1.1/requires
> old mode 100755
> new mode 100644
> diff --git a/FixedEffectModels/versions/0.2.0/requires 
> b/FixedEffectModels/versions/0.2.0/requires
> old mode 100755
> new mode 100644
> diff --git a/FixedEffectModels/versions/0.2.1/requires 
> b/FixedEffectModels/versions/0.2.1/requires
> old mode 100755
> new mode 100644
> diff --git a/FixedEffectModels/versions/0.2.2/requires 
> b/FixedEffectModels/versions/0.2.2/requires
> old mode 100755
> new mode 100644
>
> Cheers,
> Alex
>
> On Saturday, February 20, 2016 at 4:56:29 AM UTC+11, Hua Chai wrote:
>>
>> You're right. 'git diff' does show old mode and new mode. But 'chmod' 
>> still didn't work with the old mode number. 
>> Looks like the problem is rooted in the fact that Juno currently doesn't 
>> support Julia 0.4 (I noticed that from Junolab.org). I downloaded the 
>> bundle from Junolab.org instead of Julialang.org and also installed the 
>> command line version of Julia. The Pkg.update() problem didn't appear after 
>> installation. But now my Julia is only v0.3.
>> Hope the next Juno update will support Julia 0.4.
>>
>> On Fri, Feb 19, 2016 at 10:42 AM, Tony Kelman  wrote:
>>
>>> When you do "git diff" it should be showing something to the effect of 
>>> "old mode," that's what you should try to use for chmod. Check git diff 
>>> before and after, and aim to make git diff not say anything.
>>>
>>> I don't know what's responsible for this but it seems like it may be 
>>> specific to Juno somehow?
>>
>>
>>

[julia-users] Re: for loop with multiple variables

2016-05-10 Thread Vishnu Raj
Thanks :)

On Tuesday, May 10, 2016 at 4:44:18 PM UTC+5:30, Lutfullah Tomak wrote:
>
> for (i,j)=zip(0:5,6:10)
> println(i+j)
> end
> On Tuesday, May 10, 2016 at 2:02:41 PM UTC+3, Vishnu Raj wrote:
>>
>> What  if the equivalent of the C code below
>> for( i=0, j=6; i<=5, j <=10; i++, j++ ) print( "%d", i+j );
>> in julia?
>>
>

[julia-users] Re: IJulia- Failed to precompile IJulia to C:\Users\....\.julia\lib\v0.4\IJulia.ji in error at error.jl:21

2016-05-10 Thread ÜÖ
Dear Steven,
I did - a "git reset --hard"  and IJulia worked. Appreciate your kind help. 
You are right, when IJulia crashed first for some reason, I had done the 
following and most probably I did something wrong. 

> ``

" If IJulia is crashing (e.g. it gives you a "kernel appears to have died" 
message), you can modify it to print more descriptive error messages to the 
terminal: edit your IJulia/src/IJulia.jl 
 file (in 
your .julia package directory) to change the lineverbose = false at the top 
to verbose = true and const capture_stderr = true to const capture_stderr = 
false. Then restart the kernel or open a new notebook and look for the 
error message when IJulia dies
`

> ``

On Tuesday, May 10, 2016 at 2:54:03 PM UTC+3, Steven G. Johnson wrote:
>
>
>
> On Tuesday, May 10, 2016 at 3:21:25 AM UTC-4, ÜÖ wrote:
>>
>> Dear Steven, Thank you very much for your help . The respective part of 
>> output of Pkg.status()
>>
>> - IJulia1.1.9  a675ac5c 
>> (dirty)
>>
>
> "dirty" means you have edited a file there, and you must have introduced 
> an error.   Do a "git reset --hard" in the IJulia directory to return it to 
> a pristine state. 
>


[julia-users] Re: IJulia- Failed to precompile IJulia to C:\Users\....\.julia\lib\v0.4\IJulia.ji in error at error.jl:21

2016-05-10 Thread Steven G. Johnson


On Tuesday, May 10, 2016 at 3:21:25 AM UTC-4, ÜÖ wrote:
>
> Dear Steven, Thank you very much for your help . The respective part of 
> output of Pkg.status()
>
> - IJulia1.1.9  a675ac5c (dirty)
>

"dirty" means you have edited a file there, and you must have introduced an 
error.   Do a "git reset --hard" in the IJulia directory to return it to a 
pristine state. 


[julia-users] Re: Changing the version of Julia when needed

2016-05-10 Thread kleinsplash

I just removed that ppa and went back to juliareleases

On Tuesday, 10 May 2016 13:42:19 UTC+2, kleinsplash wrote:
>
> I am stuck between a bit of a rock and a hard place. 
>
> I would like to use PCL: https://github.com/JuliaPCL/PCL.jl but this does 
> not install on 0.4
>
> But I may be able to use the FunctionDataUtils package in its place. 
> Juno/Atom doesnt seem to play nice with 0.5 either so best is to just 
> revert at the moment. 
>
> I updated (upgraded) by adding nightly builds ppa. 
>
> On Tuesday, 10 May 2016 13:16:01 UTC+2, Tony Kelman wrote:
>>
>> How did you install 0.5? If you're new to thr language things will be 
>> more stable on 0.4, but you can install both in parallel.
>
>

[julia-users] Re: Changing the version of Julia when needed

2016-05-10 Thread kleinsplash
I am stuck between a bit of a rock and a hard place. 

I would like to use PCL: https://github.com/JuliaPCL/PCL.jl but this does 
not install on 0.4

But I may be able to use the FunctionDataUtils package in its place. 
Juno/Atom doesnt seem to play nice with 0.5 either so best is to just 
revert at the moment. 

I updated (upgraded) by adding nightly builds ppa. 

On Tuesday, 10 May 2016 13:16:01 UTC+2, Tony Kelman wrote:
>
> How did you install 0.5? If you're new to thr language things will be more 
> stable on 0.4, but you can install both in parallel.



Re: [julia-users] using subscripts \_1, \_2, ... as field names

2016-05-10 Thread Davide Lasagna
Thanks. 

Using a letter prefix was the first thing I did. Code looked like A.A11, 
and so on; so not really good looking. 

The only reasons to use subscripts rather than standard digits would be 
that for the former you do not need prefixes, so it is a bit cleaner. 
However, using subscripts like \_1, etc,  for field/variables is not 
currently allowed. Worth opening an issue?


On Tuesday, May 10, 2016 at 10:29:27 AM UTC+1, Milan Bouchet-Valat wrote:
>
> Le mardi 10 mai 2016 à 01:56 -0700, Davide Lasagna a écrit : 
> > Hi,  
> > 
> > I have a custom type representing a bordered matrix (a big square 
> > matrix, bordered by two vectors and a scalar in the bottom right 
> > corner), where the four blocks are stored in separated chunks of 
> > memory. I would like to call the fields of my type using subscripts 
> > \_1\_1, \_1\_2, ... so that I can nicely access them as A.11, A.12, 
> > ... However, it seems that subscripts (and superscripts) with digits 
> > can't be used for variable names, resulting in a syntax error. 
> >  Subscripts with letters work fine.  
> > 
> > Any thoughts on this? 
> All identifiers must start with a letter. So you could call them A.c₁₁ 
> or A.c11, etc. 
>
> Maybe this rule could be loosened a bit, since subscripts are never 
> parsed as actual numbers. OTOH, I'm not sure using subscripts is really 
> better than using standard digits with a letter prefix. 
>
>
> Regards 
>


[julia-users] Changing the version of Julia when needed

2016-05-10 Thread Tony Kelman
How did you install 0.5? If you're new to thr language things will be more 
stable on 0.4, but you can install both in parallel.

[julia-users] Re: for loop with multiple variables

2016-05-10 Thread Lutfullah Tomak
for (i,j)=zip(0:5,6:10)
println(i+j)
end
On Tuesday, May 10, 2016 at 2:02:41 PM UTC+3, Vishnu Raj wrote:
>
> What  if the equivalent of the C code below
> for( i=0, j=6; i<=5, j <=10; i++, j++ ) print( "%d", i+j );
> in julia?
>


[julia-users] for loop with multiple variables

2016-05-10 Thread Vishnu Raj
What  if the equivalent of the C code below
for( i=0, j=6; i<=5, j <=10; i++, j++ ) print( "%d", i+j );
in julia?


[julia-users] Changing the version of Julia when needed

2016-05-10 Thread kleinsplash
Hi,

How do I point to the version of Julia I would like to use? 

For example: I would like to use this package: FunctionalDataUtils 
 but its only available on 
0.4. How do I revert without having to uninstall 0.5 or use Compat.jl which 
looks rough for a newbie. 

Thx 


[julia-users] Re: Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread FANG Colin
Currently I am using

macro markup(line_number)
println("compile time OK: #$(line_number)")
quote
x = $(esc(line_number))
println("run time OK: #$x")
end
end

For example

I want to debug a function "to_debug".

function to_debug()
@markup(1)
end

compile time OK: #1


to_debug()


run time OK: #1








On Tuesday, May 10, 2016 at 11:16:20 AM UTC+1, FANG Colin wrote:
>
> I am debugging some code.
>
> I would like to insert some markup function/macro in my code, so that I 
> know my code at least works fine until certain line number 
>


[julia-users] Is there a function/macro that shows the line number where it is called?

2016-05-10 Thread FANG Colin
I am debugging some code.

I would like to insert some markup function/macro in my code, so that I 
know my code at least works fine until certain line number 


Re: [julia-users] using subscripts \_1, \_2, ... as field names

2016-05-10 Thread Milan Bouchet-Valat
Le mardi 10 mai 2016 à 01:56 -0700, Davide Lasagna a écrit :
> Hi, 
> 
> I have a custom type representing a bordered matrix (a big square
> matrix, bordered by two vectors and a scalar in the bottom right
> corner), where the four blocks are stored in separated chunks of
> memory. I would like to call the fields of my type using subscripts
> \_1\_1, \_1\_2, ... so that I can nicely access them as A.11, A.12,
> ... However, it seems that subscripts (and superscripts) with digits
> can't be used for variable names, resulting in a syntax error.
>  Subscripts with letters work fine. 
> 
> Any thoughts on this?
All identifiers must start with a letter. So you could call them A.c₁₁
or A.c11, etc.

Maybe this rule could be loosened a bit, since subscripts are never
parsed as actual numbers. OTOH, I'm not sure using subscripts is really
better than using standard digits with a letter prefix.


Regards


[julia-users] using subscripts \_1, \_2, ... as field names

2016-05-10 Thread Davide Lasagna
Hi, 

I have a custom type representing a bordered matrix (a big square matrix, 
bordered by two vectors and a scalar in the bottom right corner), where the 
four blocks are stored in separated chunks of memory. I would like to call 
the fields of my type using subscripts \_1\_1, \_1\_2, ... so that I can 
nicely access them as A.11, A.12, ... However, it seems that subscripts 
(and superscripts) with digits can't be used for variable names, resulting 
in a syntax error.  Subscripts with letters work fine. 

Any thoughts on this? 


[julia-users] Re: IJulia- Failed to precompile IJulia to C:\Users\....\.julia\lib\v0.4\IJulia.ji in error at error.jl:21

2016-05-10 Thread ÜÖ


Dear Steven, Thank you very much for your help . The respective part of 
output of Pkg.status()

> `` 

GLVisualize   0.0.8

- Gadfly 0.4.2

- GaussianProcesses  0.1.4

- GraphViz 0.0.4

- HPAT   0.0.4

- IJulia1.1.9  a675ac5c (dirty)

- ImageMagick0.1.5

- ImageView   0.1.19

- Images0.5.4

>  

And

 

*Output of Pkg.build(“IJulia”): *

>  

julia> Pkg.build("IJulia")

INFO: Building WinRPM

INFO: Downloading 
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml

INFO: Downloading 
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/repomd.xml

INFO: Building Nettle

INFO: Updating WinRPM package list

INFO: Downloading 
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml

INFO: Downloading 
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/repomd.xml

INFO: Building ZMQ

INFO: Building IJulia

INFO: Installing Jupyter via the Conda package.

Get-Process : Cannot find a process with the name "Outlook". Verify the 
process name and call the cmdlet again.

At line:1 char:1

+ Get-Process Outlook

+ ~~~

+ CategoryInfo  : ObjectNotFound: (Outlook:String) 
[Get-Process], ProcessCommandException

+ FullyQualifiedErrorId : 
NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

 

Fetching package metadata: 

Solving package specifications: .

 

# All requested packages already installed.

# packages in environment at C:\Users\`….\.julia\v0.4\Conda\deps\usr:

#

jupyter   1.0.0py27_2

INFO: Found Jupyter version 4.0.6: 
C:\Users\.\.julia\v0.4\Conda\deps\usr\Scripts\jupyter

Writing IJulia kernelspec to 
C:\Users\..\.julia\v0.4\IJulia\deps\julia-0.4\kernel.json ...

Installing julia kernelspec julia-0.4

jupyter: 'kernelspec' is not a Jupyter command

[InstallKernelSpec] Removing existing kernelspec in 
C:\Users\.\AppData\Roaming\jupyter\kernels\julia-0.4

[InstallKernelSpec] Installed kernelspec julia-0.4 in 
C:\Users\--\AppData\Roaming\jupyter\kernels\julia-0.4

 

julia> Pkg.add("IJulia")

INFO: Nothing to be done

 

julia> Pkg.update("IJulia")

ERROR: MethodError: `update` has no method matching update(::ASCIIString)

 

julia> Pkg.checkout("IJulia")

INFO: Checking out IJulia master...

ERROR: IJulia is dirty, bailing

 in error at error.jl:21

 

julia> using IJulia

INFO: Precompiling module IJulia...

ERROR: LoadError: syntax: extra token "set_verbose" after end of expression

 in include at boot.jl:261

 in include_from_node1 at loading.jl:304

 [inlined code] from none:2

 in anonymous at no file:0

 in process_options at client.jl:257

 in _start at client.jl:378

while loading C:\Users\\.julia\v0.4\IJulia\src\IJulia.jl, in expression 
starting on line 7

ERROR: Failed to precompile IJulia to 
C:\Users\\.julia\lib\v0.4\IJulia.ji

 in error at error.jl:21

>  

julia>

On Tuesday, May 10, 2016 at 3:27:56 AM UTC+3, Steven G. Johnson wrote:
>
> Were you editing the src/IJulia.jl file for debugging purposes or 
> something?  What does `Pkg.status()` say?
>


[julia-users] undefined reference error

2016-05-10 Thread Lutfullah Tomak
You need to initialize array entries if you don't have eltype as bitstype. 
Here, undefined reference means you had not initialize the entry. And, full 
type assignment works because it initializes the entry.

[julia-users] undefined reference error

2016-05-10 Thread Boylan, Ross
julia 0.4:

module TT
type Stuff
a::Int
b::Int
end
v = Array(Stuff, 3)
end

Produces
 julia> TT.v[1].a = 5
 ERROR: UndefRefError: access to undefined reference  problem
  in getindex at array.jl:282

!julia> TT.v
 3-element Array{TT.Stuff,1}:
  #undef
  #undef
  #undef

Could anyone help me to understand what's going on, and what I can do about it? 
 I know Array() produces uninitialized elements, but I don't understand why I 
can't write values into them.

In contrast, replacing the entire object works:
julia> TT.v[1] = TT.Stuff(4, 78)
 TT.Stuff(4,78)

!julia> TT.v[1]
 TT.Stuff(4,78)

Thanks.
Ross Boylan


Re: [julia-users] Re: static compilation

2016-05-10 Thread Ján Adamčák
Hello guys, 

Thank you for your comments, though we were more optimistic...


Dňa piatok, 6. mája 2016 16:27:28 UTC+2 Ján Adamčák napísal(-a):
>
> Sorry, my fault. 
>
> During last week I created build_sysimg2.jl from julia 0.4.5 
> build_sysimg.jl and when I run it, at line 86 (build_sysimg2.jl)
>
> run(`$julia -C $cpu_target --output-o sysimg_all.o --sysimage 
> $sysimg_path.$(Libdl.dlext) --startup-file=no --compile=all --eval nothing`)
>
> I got this error:
>
> fatal: error thrown and no exception handler available.
> ErrorException("Task cannot be serialized")
> jl_unprotect_stack at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_throw at C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll 
> (unknown line)
> jl_error at C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll 
> (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_compress_ast at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_save_system_image_to_stream at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_create_system_image at 
> C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll (unknown line)
> jl_atexit_hook at C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\libjulia.dll 
> (unknown line)
> unknown function (ip: 004028B5)
> unknown function (ip: 0040140C)
> unknown function (ip: 0040153B)
> BaseThreadInitThunk at C:\WINDOWS\system32\KERNEL32.DLL (unknown line)
> RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
> ERROR: LoadError: failed process: 
> Process(`'C:\Users\Adam\AppData\Local\Julia-0.4.5\bin\julia' -C native 
> --output-o sysimg_all.o --sysimage my_img.dll --startup-file=no 
> --compile=all --eval nothing`, ProcessExited(1)) [1]
>  in run at process.jl:531
> while loading 
> c:\Users\Adam\AppData\Local\Julia-0.4.5\share\julia\build_sysimg2.jl, in 
> expression starting on line 191
>
>  Before this error, julia wrote some warnings:
>
> WARNING: could not attach metadata for @simd loop.
>
> Same error I got on Ubuntu 16.04...
>  
>
>
> Dňa piatok, 6. mája 2016 15:48:19 UTC+2 Jeff Bezanson napísal(-a):
>>
>> That command line in build_sysimg.jl:77 looks strange. Actually I 
>> can't find that line anywhere; our build_sysimg and BuildExecutable.jl 
>> now have something slightly different. 
>>
>> On Fri, May 6, 2016 at 9:25 AM, Tom Breloff  wrote: 
>> > Also, I think there's even fewer people that are experts on the Windows 
>> > build process.  I