Re: [julia-users] Why two (qualified) macro invocation forms?

2016-07-09 Thread Isaiah Norton
(also a work-around for a symbol hygiene issue:
https://github.com/JuliaLang/julia/issues/15085)

On Sun, Jul 10, 2016 at 12:46 AM, Isaiah Norton 
wrote:

> I believe the second form may be vestigial at this point, and agree that
> it is inconsistent. The usage is non-existent in base (except for one
> test), but there is at least one issue for which the current work-around
> requires the second form: https://github.com/JuliaLang/julia/issues/14208
>
> On Fri, Jul 8, 2016 at 4:52 AM, Hans-Peter  wrote:
>
>> Acc. to the manual [1] either `Mod.@mac` or `@Mod.mac` can be used. What
>> is the reason for the second form? Is it necessary to make me (other
>> people?) think which form should be used preferably? Maybe there is a
>> reason (didn't find something in issues/maillist) but with my current
>> knowledge I'd propose to 'push' the first form and deprecate the second.
>>
>> Both forms are not used often (in Julia source and my v0.4 packages). The
>> first (Mod.@mac) form is more frequent.
>>
>> ~~~
>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " \w+\.@\w+"
>> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " @\w+\."
>> ~~~
>>
>> Sometimes both forms are being used, e.g.:
>>
>> ... v0.4/DataArrays/src/DataArrays.jl
>> 78:Base.@deprecate removeNA dropna
>> ... v0.4/DataArrays/test/reducedim.jl
>> 12:Base.Test.@test DataArrays._any(bits, i, j) == v
>>
>> vs.
>>
>> ... v0.4/Calculus/src/Calculus.jl
>> 62:@Base.deprecate integrate(f,a,b) quadgk(f,a,b)[1]
>> ... v0.4/Distributions/test/truncate.jl
>> 70:@Base.Test.test_approx_eq_eps(logpdf(d, x), lp, sqrt(eps()))
>>
>>
>> [1]
>> http://docs.julialang.org/en/latest/manual/modules/#namespace-miscellanea
>>
>
>


Re: [julia-users] I would like to display links to new Julia Questions from StackOverflow in the Gitter Sidebar

2016-07-09 Thread Lyndon White
thanks.
It is working

On Sunday, 10 July 2016 12:25:52 UTC+8, Jacob Quinn wrote:
>
> Just sent it to you.
>
> On Sat, Jul 9, 2016 at 10:11 PM, Lyndon White  > wrote:
>
>>
>> Hi all,
>> We were discussing this in the gitter chat 
>> .
>> That it would be cool if everytime someone asked a Julia question on 
>> Stack Overflow, it would appear in the Activity sidebar.
>>
>>
>> *They way, when questions are asked on stackoverflow, people hanging 
>> around on gitter would see it, and could answer it.Thus making the 
>> community more welcoming by people who are stuck getting help sooner,and so 
>> improving the adoption of the language.*
>>
>>
>> So I threw together some code to make that happen: 
>> https://github.com/oxinabox/GitterBots.jl
>> You can see it in action on my own gitter channel: 
>> https://gitter.im/oxinabox/JuliaStackOverflowWatcher
>>
>> 
>>
>>
>> Its just a script running in a loop on my computer, 
>> each minute it checks the stackover flow JuliaLang RSS feed,
>> and then posts them to a Gitter Custom Integration activity notifier.
>>
>> I would like to set it up to run in the main channel.
>> The Activity bar in the main channel is currently empty -- unused.
>>
>> I'm happy to host it, more or less forever, on the same server I use to 
>> host the bot that links the IRC to gitter 
>> 
>> But unlike that bot, I can not do this without permission form a channel 
>> admin.
>> Which by default for gitter are people with commit access to the Julia 
>> repository.
>>
>> I need a channel admin to give me a webhook URL.
>>
>> This can be gotten by clicking:
>> Room Settings -> Integrations -> *Custom*
>> Then copying the URL (It should look like 
>> *https://webhooks.gitter.im/e/adb87a00ca31a22272dc 
>> *) and clicking done.
>> and sending it to me in an private message on gitter 
>> or an email (though that is unencripted plain text, so could I guess be 
>> snooped.  Certainly not be sending to this mailing list as that would leave 
>> it open for anyone to hook to)
>>
>> Alternatively, the repo for the bot that checks stack overflow could be 
>> cloned by a channel admin, and then they could run it themselves.
>> And so I wouldn't need to be given the webhook URL.
>>
>>
>> What do people think?
>> People who were on gitter at the time I brought it up, and showed the 
>> demonstration were in favor, I think.
>>
>> Regards
>> Lyndon White
>>
>>
>>
>>
>

Re: [julia-users] Why two (qualified) macro invocation forms?

2016-07-09 Thread Isaiah Norton
I believe the second form may be vestigial at this point, and agree that it
is inconsistent. The usage is non-existent in base (except for one test),
but there is at least one issue for which the current work-around requires
the second form: https://github.com/JuliaLang/julia/issues/14208

On Fri, Jul 8, 2016 at 4:52 AM, Hans-Peter  wrote:

> Acc. to the manual [1] either `Mod.@mac` or `@Mod.mac` can be used. What
> is the reason for the second form? Is it necessary to make me (other
> people?) think which form should be used preferably? Maybe there is a
> reason (didn't find something in issues/maillist) but with my current
> knowledge I'd propose to 'push' the first form and deprecate the second.
>
> Both forms are not used often (in Julia source and my v0.4 packages). The
> first (Mod.@mac) form is more frequent.
>
> ~~~
> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " \w+\.@\w+"
> find ~/.julia/v0.4/ -name "*.jl" | xargs ack " @\w+\."
> ~~~
>
> Sometimes both forms are being used, e.g.:
>
> ... v0.4/DataArrays/src/DataArrays.jl
> 78:Base.@deprecate removeNA dropna
> ... v0.4/DataArrays/test/reducedim.jl
> 12:Base.Test.@test DataArrays._any(bits, i, j) == v
>
> vs.
>
> ... v0.4/Calculus/src/Calculus.jl
> 62:@Base.deprecate integrate(f,a,b) quadgk(f,a,b)[1]
> ... v0.4/Distributions/test/truncate.jl
> 70:@Base.Test.test_approx_eq_eps(logpdf(d, x), lp, sqrt(eps()))
>
>
> [1]
> http://docs.julialang.org/en/latest/manual/modules/#namespace-miscellanea
>


Re: [julia-users] I would like to display links to new Julia Questions from StackOverflow in the Gitter Sidebar

2016-07-09 Thread Jacob Quinn
Just sent it to you.

On Sat, Jul 9, 2016 at 10:11 PM, Lyndon White  wrote:

>
> Hi all,
> We were discussing this in the gitter chat
> .
> That it would be cool if everytime someone asked a Julia question on Stack
> Overflow, it would appear in the Activity sidebar.
>
>
> *They way, when questions are asked on stackoverflow, people hanging
> around on gitter would see it, and could answer it.Thus making the
> community more welcoming by people who are stuck getting help sooner,and so
> improving the adoption of the language.*
>
>
> So I threw together some code to make that happen:
> https://github.com/oxinabox/GitterBots.jl
> You can see it in action on my own gitter channel:
> https://gitter.im/oxinabox/JuliaStackOverflowWatcher
>
> 
>
>
> Its just a script running in a loop on my computer,
> each minute it checks the stackover flow JuliaLang RSS feed,
> and then posts them to a Gitter Custom Integration activity notifier.
>
> I would like to set it up to run in the main channel.
> The Activity bar in the main channel is currently empty -- unused.
>
> I'm happy to host it, more or less forever, on the same server I use to
> host the bot that links the IRC to gitter
> 
> But unlike that bot, I can not do this without permission form a channel
> admin.
> Which by default for gitter are people with commit access to the Julia
> repository.
>
> I need a channel admin to give me a webhook URL.
>
> This can be gotten by clicking:
> Room Settings -> Integrations -> *Custom*
> Then copying the URL (It should look like 
> *https://webhooks.gitter.im/e/adb87a00ca31a22272dc
> *) and clicking done.
> and sending it to me in an private message on gitter
> or an email (though that is unencripted plain text, so could I guess be
> snooped.  Certainly not be sending to this mailing list as that would leave
> it open for anyone to hook to)
>
> Alternatively, the repo for the bot that checks stack overflow could be
> cloned by a channel admin, and then they could run it themselves.
> And so I wouldn't need to be given the webhook URL.
>
>
> What do people think?
> People who were on gitter at the time I brought it up, and showed the
> demonstration were in favor, I think.
>
> Regards
> Lyndon White
>
>
>
>


[julia-users] I would like to display links to new Julia Questions from StackOverflow in the Gitter Sidebar

2016-07-09 Thread Lyndon White



Hi all,
We were discussing this in the gitter chat 
.
That it would be cool if everytime someone asked a Julia question on Stack 
Overflow, it would appear in the Activity sidebar.


*They way, when questions are asked on stackoverflow, people hanging around 
on gitter would see it, and could answer it.Thus making the community more 
welcoming by people who are stuck getting help sooner,and so improving the 
adoption of the language.*


So I threw together some code to make that 
happen: https://github.com/oxinabox/GitterBots.jl
You can see it in action on my own gitter 
channel: https://gitter.im/oxinabox/JuliaStackOverflowWatcher




Its just a script running in a loop on my computer, 
each minute it checks the stackover flow JuliaLang RSS feed,
and then posts them to a Gitter Custom Integration activity notifier.

I would like to set it up to run in the main channel.
The Activity bar in the main channel is currently empty -- unused.

I'm happy to host it, more or less forever, on the same server I use to host 
the bot that links the IRC to gitter 

But unlike that bot, I can not do this without permission form a channel 
admin.
Which by default for gitter are people with commit access to the Julia 
repository.

I need a channel admin to give me a webhook URL.

This can be gotten by clicking:
Room Settings -> Integrations -> *Custom*
Then copying the URL (It should look like 
*https://webhooks.gitter.im/e/adb87a00ca31a22272dc*) and clicking done.
and sending it to me in an private message on gitter 
or an email (though that is unencripted plain text, so could I guess be 
snooped.  Certainly not be sending to this mailing list as that would leave 
it open for anyone to hook to)

Alternatively, the repo for the bot that checks stack overflow could be 
cloned by a channel admin, and then they could run it themselves.
And so I wouldn't need to be given the webhook URL.


What do people think?
People who were on gitter at the time I brought it up, and showed the 
demonstration were in favor, I think.

Regards
Lyndon White





[julia-users] Re: caching the pivot ordering for a sparse cholesky factorization?

2016-07-09 Thread Dan
Hi Gabe,

SuiteSparse which comes together with Julia includes a library KLU which 
does sparse LU factorization. It has the option to return the fill-in 
reducing order it manages to find for a given sparsity pattern. With this 
returned structure it can subsequently factorize many matrices (and solve 
equations). After some tinkering, I have got it to work, so it is possible.

If this is still an issue and using KLU fits the bill, I'll provide more 
details of my tinkering.

DG 

On Friday, July 8, 2016 at 4:40:45 AM UTC-4, Gabriel Goh wrote:
>
> Hey,
>
> I have a sequence of sparse matrix factorizations I need to do, each one a 
> different matrix but with the same sparsity structure. Is there a way I can 
> save the AMD (or any other) ordering that sparsesuite returns, it does not 
> need to be recomputed each time?
>
> Thanks a lot for the help!
>
> Gabe
>


Re: [julia-users] MathProgBase Conic problem specifying dual

2016-07-09 Thread Steven Varga
Hi Kevin!

thanks letting me know; and for the quick response, I will re-post on
julia-opt;

best,
steve

On Sat, Jul 9, 2016 at 2:29 PM, Kevin Squire  wrote:

> Hi, it's probably worth asking this question on the julia-opt list.
>
> Cheers,
>Kevin
>
>
>
> On Saturday, July 9, 2016, steven Varga  wrote:
>
>>
>> Is it possible to specify the dual of an SOCP/SDP using MathProgBase
>> interface?
>>
>> It is well documented how to specify primal problem, but don't see any
>> pointers to formulate the dual. The dual formulation is motivated if A
>> matrix is non-square having more variables in primal then constraints.
>>
>> Any help, pointers appreciated
>> steve
>>
>> MathProgBase version:
>> commit 2faa7b97af385f61ea2e829512b5fa1c1c2ceab1
>> Author: Miles Lubin 
>> Date:   Thu Jun 2 15:30:42 2016 +0200
>>
>> Julia Version 0.5.0-dev+1503
>> Commit 84fb0a4* (2016-05-27 03:12 UTC)
>> Platform Info:
>>   System: Linux (x86_64-linux-gnu)
>>   CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
>>   WORD_SIZE: 64
>>   BLAS: libmkl_rt
>>   LAPACK: libmkl_rt
>>   LIBM: libimf
>>
>>


Re: [julia-users] string interpolation for memory object name

2016-07-09 Thread Min-Woong Sohn
Thank you so much! I will try a dictionary.

On Saturday, July 9, 2016 at 12:54:07 PM UTC-4, Isaiah wrote:
>
> Technically you *can* do the following:
>
>
> @eval $(Symbol("logit_", outcomes[i], "_unadjusted")) = [... fix the RHS 
> too]
>
> But IMHO programming like this is kind of discouraged. (for one thing, 
> undisciplined use can lead to big speed traps). An alternative is to hold a 
> string-addressable handle to results in a dictionary or a DataFrame.
>
>
>
>
> On Fri, Jul 8, 2016 at 3:26 PM, Min-Woong Sohn  > wrote:
>
>> I am trying to run logistic regressions on a bunch of dependent variables 
>> like so:
>>
>> using GLM
>>
>> outcomes = [:mort30d, :readmit, :reoper, :sar]
>>
>> for i in 1:length(outcomes)
>> logit_$(outcomes[i])_unadjusted = glm($(outcomes[i]) ~ race, puf, 
>> Binomial(),LogitLink())
>> dump(coef(logit_$(outcomes[i])_unadjusted))
>> end
>>
>> Here I want to run the logistic regression four times, once for each 
>> outcome, and save the return values into four different memory objects:
>>
>> logit_mort30d_unadjusted
>> logit_readmit_unadjusted
>> etc
>>
>> The glm... part works fine with the interpolation, $(outcomes[i]), but I 
>> cannot create the memory objects in this way. Is there any way I can use 
>> some method of string interpolation to this end?
>>
>>
>>  
>>
>
>

[julia-users] Re: Dear Sublime Text Users

2016-07-09 Thread Randy Lai
You need to have some unicodes highlighted and then run the reverse lookup 
command.

I am using the default font on Mac (I suppose).

[julia-users] Re: Dear Sublime Text Users

2016-07-09 Thread mmh
Thanks you! I keep trying Atom (but it's painfully slow) and on many 
occasions am forced to use it due to its better Julia support. This is a 
very welcomed package. How does reverse lookup work? I selected some text 
and then entered reverse look up but nothing happened? Also what kind of 
font are you using that you get colored emojis? Thanks  

On Saturday, July 9, 2016 at 3:42:13 AM UTC-4, Randy Lai wrote:
>
> Hi all Sublime Text uers,
>
>
> I have just created a tiny package Julia-Unicode 
>  to help inserting LaTeX and 
> Unicode in Sublime Text. It uses the Julia mappings so you don't have to 
> worry about
> the different betwwen ɛ (\varepsilon) and ϵ (\epsilon).
> You may have heard of Julia Completions 
>  or UnicodeMath 
> , I promise you that 
> Julia-Unicode works better than them :).
>
> Check it out from Package Control.
>
> Feedbacks appreciated.
>


Re: [julia-users] MathProgBase Conic problem specifying dual

2016-07-09 Thread Kevin Squire
Hi, it's probably worth asking this question on the julia-opt list.

Cheers,
   Kevin


On Saturday, July 9, 2016, steven Varga  wrote:

>
> Is it possible to specify the dual of an SOCP/SDP using MathProgBase
> interface?
>
> It is well documented how to specify primal problem, but don't see any
> pointers to formulate the dual. The dual formulation is motivated if A
> matrix is non-square having more variables in primal then constraints.
>
> Any help, pointers appreciated
> steve
>
> MathProgBase version:
> commit 2faa7b97af385f61ea2e829512b5fa1c1c2ceab1
> Author: Miles Lubin  >
> Date:   Thu Jun 2 15:30:42 2016 +0200
>
> Julia Version 0.5.0-dev+1503
> Commit 84fb0a4* (2016-05-27 03:12 UTC)
> Platform Info:
>   System: Linux (x86_64-linux-gnu)
>   CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
>   WORD_SIZE: 64
>   BLAS: libmkl_rt
>   LAPACK: libmkl_rt
>   LIBM: libimf
>
>


Re: [julia-users] Ambiguity error when dispatching on Union types

2016-07-09 Thread Darwin Darakananda
Thanks Tim!  That was really helpful, especially the trick with adding an 
extra layer of functions with a different name.

On Saturday, July 9, 2016 at 2:56:49 AM UTC-7, Tim Holy wrote:
>
> Ambiguities are often a bit tricky. Two tips I've adopted: 
>
> - Have as few methods as possible, and declare types on their arguments 
> only 
> when absolutely necessary. These measures greatly reduce your exposure to 
> the 
> risk of ambiguities. To achieve this, it sometimes takes a fair bit of 
> thought 
> to design your API. 
>
> - Use one layer of indirection per argument you want to specialize. There 
> are 
> a couple of ways to pull this off, and the best way to do it usually 
> depends 
> on the specific goal you're trying to achieve. But here one approach might 
> be 
> to decide that `f` will only be specialized on argument 2, and will 
> otherwise 
> dispatch to `f1` (which you can specialize for argument 1). 
>
> f(a, b) = f1(a, b) 
> f(a, b::A) = "from A" 
> f1(a::Int, b) = "Int" 
> f1(a, b) = "other" 
>
> Best, 
> --Tim 
>
> On Friday, July 8, 2016 8:27:30 PM CDT Darwin Darakananda wrote: 
> > Is there a recommended way to getting around that?  The example above 
> had a 
> > union of only two types, but in the actual code I'm working on there are 
> a 
> > couple more.  Would I have to copying the code over and over with just 
> > small changes to the type signature? I guess you could use a macro to 
> > splice the types in. 
> > 
> > On Friday, July 8, 2016 at 7:58:02 PM UTC-7, Yichao Yu wrote: 
> > > On Fri, Jul 8, 2016 at 10:32 PM, Darwin Darakananda 
> > > 
> > >  wrote: 
> > > > Hi everyone, 
> > > > 
> > > > I have some code where multiple types share the same implementation 
> of a 
> > > > method, for example: 
> > > > 
> > > > abstract MyType 
> > > > 
> > > > 
> > > > type A <: MyType end 
> > > > type B <: MyType end 
> > > > 
> > > > 
> > > > f(target::MyType, source::MyType) = "fallback" 
> > > > 
> > > > 
> > > > f(target::Int,source::A) = "from A" 
> > > > f(target::MyType, source::A) = "from A" 
> > > > 
> > > > a = A() 
> > > > b = B() 
> > > > 
> > > > f(b, b) # fallback 
> > > > f(b, a) # from A 
> > > > f(a, a) # from A 
> > > > 
> > > > I was hoping that I could replace the "from A" function using a 
> union 
> > > 
> > > type, 
> > > 
> > > > but I'm running into ambiguity errors: 
> > > > 
> > > > f(target::Union{Int, MyType}, source::A) = "from A" 
> > > > 
> > > > f(b, b) # fallback 
> > > > f(b, a) # Ambiguity error 
> > > > f(a, a) # Ambiguity error 
> > > > 
> > > > Is this an expected behavior? 
> > > 
> > > Yes. 
> > > 
> > > > I thought that (::Union{Int, MyType}, ::A) 
> > > > would be a more specific match to (::B, ::A) than (::MyType, 
> ::MyType). 
> > > 
> > > There's basically nothing as a "more specific match". The two methods 
> > > are ambiguous and anything in their intersection cannot be dispatched 
> > > to either of them. 
> > > 
> > > > Any ideas/suggestions? 
> > > > 
> > > > Thanks, 
> > > > 
> > > > Darwin 
>
>
>

Re: [julia-users] string interpolation for memory object name

2016-07-09 Thread Isaiah Norton
Technically you *can* do the following:


@eval $(Symbol("logit_", outcomes[i], "_unadjusted")) = [... fix the RHS
too]

But IMHO programming like this is kind of discouraged. (for one thing,
undisciplined use can lead to big speed traps). An alternative is to hold a
string-addressable handle to results in a dictionary or a DataFrame.




On Fri, Jul 8, 2016 at 3:26 PM, Min-Woong Sohn  wrote:

> I am trying to run logistic regressions on a bunch of dependent variables
> like so:
>
> using GLM
>
> outcomes = [:mort30d, :readmit, :reoper, :sar]
>
> for i in 1:length(outcomes)
> logit_$(outcomes[i])_unadjusted = glm($(outcomes[i]) ~ race, puf,
> Binomial(),LogitLink())
> dump(coef(logit_$(outcomes[i])_unadjusted))
> end
>
> Here I want to run the logistic regression four times, once for each
> outcome, and save the return values into four different memory objects:
>
> logit_mort30d_unadjusted
> logit_readmit_unadjusted
> etc
>
> The glm... part works fine with the interpolation, $(outcomes[i]), but I
> cannot create the memory objects in this way. Is there any way I can use
> some method of string interpolation to this end?
>
>
>
>


Re: [julia-users] Enter permanently on a REPL mode

2016-07-09 Thread Isaiah Norton
https://github.com/JuliaLang/julia/issues/14081

On Fri, Jul 8, 2016 at 10:07 AM, Iagoba Apellaniz <
iagoba.apella...@gmail.com> wrote:

> I would prefer to enter permanently on a REPL mode like `shell`. See
> RCall.jl packages behavior. Once you are on R you have to hit `backspace`
> to get back to `julia>` which of course should be the default RELP mode.
>
> *julia*>[;]
>
>
> *shell*> ls
>
> DesktopDocuments  Downloads
>
> JuliaProjects  Music  Pictures
>
> *shell*> cd JuliaProjects
>
> ...
>
> *shell*> [backspace]
>
>
> *julia*>
>
>
> I have seen also some of issues about REPL modes.
>
> I don't know about the implementation of this but... for accessing any
> available REPL
>
> *ju**lia*> [?]
>
>
>
> *help?*>
>
> [;] shell [0] julia [1] python [2] R [3]    <- This would be a kind
> of menu to chose from. That it disappears whenever some action is
> performed.
>
>
> Alternatively, still special characters instead of numbers could be
> displayed if that's the trendy option.
>
>
> *help?*>
> [;] shell [<-] julia [*] python [$] R [?] help  <- I invented the symbols
> used
>
>
>
> As more packages are installed more REPLs can be available tho show to the
> user when help mode is chosen.
>
>
>
>
>


[julia-users] Re: changing record separator to read text files

2016-07-09 Thread Fred
It works using "" instead of '' !

Thanks !

julia> readuntil(f, "CKV\n")
"\nTA\n>sp|P30464|1B15_HUMAN HLA class I histocompatibility antigen, B-15 
alpha chain OS=Homo sapiens GN=HLA-B PE=1 
SV=2\nMRVTAPRTVSGALALTETWAGSHSMRYFYTAMSRPGRGEPRFIAVGYVDDTQFVRF\nDSDAASPRMAPRAPWIEQEGPEYWDRETQISKTNTQTYRESLRNLRGYYNQSEAGSHTLQ\nRMYGCDVGPDGRLLRGHDQSAYDGKDYIALNEDLSSWTAADTAAQITQRKWEAAREAEQW\nRAYLEGLCVEWLRRYLENGKETLQRADPPKTHVTHHPISDHEATLRCWALGFYPAEITLT\nWQRDGEDQTQDTELVETRPAGDRTFQKWAAVVVPSGEEQRYTCHVQHEGLPKPLTLRWEP\nSSQSTIPIVGIVAGLAVLAVVVIGAVVATVMCRRKSSGGKGGSYSQAASSDSAQGSDVSL\nTA\n"







[julia-users] Re: changing record separator to read text files

2016-07-09 Thread Fred
Thank you very much Dan !

Indeed readuntil works much better. But it seems to accept only one end 
line character. Is it possible to use a more complex pattern ?

julia> readuntil(f, '>')
"sp|P31946|1433B_HUMAN 14-3-3 protein beta/alpha OS=Homo sapiens GN=YWHAB 
PE=1 
SV=3\nMTMDKSELVQKAKLAEQAERYDDMAAAMKAVTEQGHELSNEERNLLSVAYKNVVGARRSS\nWRVISSIEQKTERNEKKQQMGKEYREKIEAELQDICNDVLELLDKYLIPNATQPESKVFY\nLKMKGDYFRYLSEVASGDNKQTTVSNSQQAYQEAFEISKKEMQPTHPIRLGLALNFSVFY\nYEILNSPEKACSLAKTAFDEAIAELDTLNEESYKDSTLIMQLLRDNLTLWTSENQGDEGD\nAGEGEN\n>"

julia> readuntil(f, '\n>')
ERROR: syntax: invalid character literal




Le samedi 9 juillet 2016 18:02:39 UTC+2, Dan a écrit :
>
> `readuntil` is your friend.
>
> `readline` uses `readuntil`. In fact, it is defined as:
>
> readuntil(s,'\n')
>
>
>>

[julia-users] Re: changing record separator to read text files

2016-07-09 Thread Dan
`readuntil` is your friend.

`readline` uses `readuntil`. In fact, it is defined as:

readuntil(s,'\n')

 
On Saturday, July 9, 2016 at 7:40:37 AM UTC-4, Fred wrote:
>
> Hi !
>
> It is often very useful to read a text files by blocks of lines, using 
> another line separator than '\n'.
>
> Especially in bio-informatics, for example DNA or Protein FASTA sequences 
> are separated by '\n>' (see uniprot.txt attached).
>
> In Perl,  it is possible to change the line separator using :
>  local $/ = '\n>'
> for example.
>
> In Julia I did not found how to do that :
>
> line by line :
>
> julia> f = open("uniprot.txt")
> IOStream()
>
> julia> readline(f, '\n>' )
> ERROR: syntax: invalid character literal
>
>
>
>
> all lines in an array (I prefer line by line because some files do not fit 
> into RAM) :
>
> julia> readdlm("uniprot.txt", '\n>' )
> ERROR: syntax: invalid character literal
>
> readdlm("uniprot.txt", '>' ) # works but does not give the expected result
>
>
> So I suppose that this feature is currently not implemented in Julia ? 
>
> Thanks in advance for your comments !
>
>
>
>

Re: [julia-users] Few questions about methods and sub()

2016-07-09 Thread Tim Holy
Thanks!
--Tim

On Saturday, July 9, 2016 6:40:36 AM CDT CrocoDuck O'Ducks wrote:
> Thanks!
> 
> I filed the issue right now. I will also have a deeper look at the source
> code ...
> although I am probably too much of a coding noob to figure out what to do
> (even with your precious hint).
> 
> On Saturday, 9 July 2016 14:15:29 UTC+1, Tim Holy wrote:
> > Looks like xcorr has a type-instability. You can see this from
> > 
> > x = rand(10 * 192000); u = rand(10 * 192000, 3);
> > su = sub(u, :, 1);
> > @code_warntype xcorr(x, su)
> > 
> > Would you mind filing an issue?
> > https://github.com/JuliaLang/julia/issues/new
> > Alternatively, if you feel up to fixing it, the hint is "don't reuse
> > variable
> > names when the type might change."
> > 
> > Best,
> > --Tim
> > 
> > On Saturday, July 9, 2016 5:01:24 AM CDT CrocoDuck O'Ducks wrote:
> > > Hi there!
> > > 
> > > I am making few experiments with simple methods. This method calculates
> > 
> > the
> > 
> > > delay between two signals (mono-dimensional arrays) using xcorr():
> > > 
> > > function finddelay{T <: Real}(x::AbstractArray{T, 1},
> > 
> > u::AbstractArray{T, 1
> > 
> > > })
> > > 
> > > # Delay as lag between cross correlation from origin of time
> > > 
> > > sₓᵤ = xcorr(x, u)
> > > 
> > > ct_idx = cld(length(sₓᵤ), 2)
> > > 
> > > _, pk_idx = findmax(sₓᵤ, 1)
> > > 
> > > δ = ct_idx - pk_idx[1]
> > > 
> > > return δ
> > > 
> > > end
> > > 
> > > Now, I would like to add a method that picks up a mono-dimensional array
> > 
> > x,
> > 
> > > a bi-dimensional array u, and then calculates the delay between x and
> > 
> > each
> > 
> > > of the columns of u.  I tried this:
> > > 
> > > function finddelay{T <: Real}(x::AbstractArray{T, 1},
> > 
> > u::AbstractArray{T, 2
> > 
> > > })
> > > 
> > > nᵤ = size(u, 2)
> > > 
> > > δ = Array(Int, 1, nᵤ)
> > > 
> > > for s = 1:nᵤ
> > > 
> > > δ[s] = finddelay(x, u[:, s])
> > > 
> > > end
> > > 
> > > return δ
> > > 
> > > end
> > > 
> > > It works good enough, here the benchmarks:
> > > 
> > > x = rand(10 * 192000); u = rand(10 * 192000, 3)
> > > 
> > > @benchmark finddelay(x, u)
> > >  Benchmark Results 
> > > 
> > >  Time per evaluation: 1.78 s [1.65 s, 1.91 s]
> > > 
> > > Proportion of time in GC: 13.60% [10.52%, 16.69%]
> > > 
> > > Memory allocated: 878.94 mb
> > >
> > >Number of allocations: 718 allocations
> > >
> > >Number of samples: 4
> > >
> > >Number of evaluations: 4
> > >  
> > >  Time spent benchmarking: 9.21 s
> > >  
> > >  
> > >  However, by reading this cool book
> > > 
> > >  > > >,
> > > 
> > > I was suggested that using Array Views through sub() should reduce
> > 
> > memory
> > 
> > > usage. So I tried it:
> > > 
> > > function finddelay{T <: Real}(x::AbstractArray{T, 1},
> > 
> > u::AbstractArray{T, 2
> > 
> > > })
> > > 
> > > nᵤ = size(u, 2)
> > > 
> > > δ = Array(Int, 1, nᵤ)
> > > 
> > > xs = sub(x, :, 1) # I need all arguments of xcorr() to be Views
> > > 
> > > for s = 1:nᵤ
> > > 
> > > us = sub(u, :, s)
> > > 
> > > δ[s] = finddelay(xs, us)
> > > 
> > > end
> > > 
> > > return δ
> > > 
> > > end
> > > 
> > > Which benchmarks as follows (same input arrays):
> > > 
> > > @benchmark finddelay(x, u)
> > >  Benchmark Results 
> > > 
> > >  Time per evaluation: 2.44 s [2.41 s, 2.47 s]
> > > 
> > > Proportion of time in GC: 12.55% [12.54%, 12.57%]
> > > 
> > > Memory allocated: 1.07 gb
> > >
> > >Number of allocations: 17279216 allocations
> > >
> > >Number of samples: 3
> > >
> > >Number of evaluations: 3
> > >  
> > >  Time spent benchmarking: 9.93 s
> > > 
> > > I obtained the same benchmark by trying to copy the body of first method
> > 
> > in
> > 
> > > the loop of the second, adapting it to use with sub().
> > > 
> > > As such, I have few questions:
> > >- First of all, it is good practice to nest methods like this?
> > >- Second, why is sub associated with a huge increase in allocations?
> > 
> > Am
> > 
> > >I doing it wrong? Or maybe it is xcorr() that needs values and cannot
> > > 
> > > work with references?




Re: [julia-users] More on Macros

2016-07-09 Thread Scott Jones
Is there any hope of #6910/#10940 getting in, maybe early in the v0.6 
release cycle?
Having bruised my brain more than once with the current macro rules and 
when to use esc() or not, it would be very nice to see macro hygiene really 
cleaned up before v1.0, and doing it early in the v0.6 cycle might be the 
last chance to do so.

-Scott

On Wednesday, July 6, 2016 at 12:09:56 AM UTC-4, Isaiah wrote:
>
> Is there a clear language spec for macros, or is it still evolving? I 
>> understand that relying on implementation to learn a language feature can 
>> be risky.
>>
>
> There is no formal spec that I am aware of. However, I don't remember any 
> substantive changes except for this one in 0.5-dev:
>
> https://github.com/JuliaLang/julia/pull/14563
>
>
> (which is fairly minor: macro-methods can now dispatch on number of 
> arguments IIUC)
>
> There's one major proposal related to hygiene; no final decision on 
> whether/when it will be accepted:
>
> https://github.com/JuliaLang/julia/pull/6910 (rebased in #10940)
>
>

Re: [julia-users] Few questions about methods and sub()

2016-07-09 Thread CrocoDuck O'Ducks
Thanks!

I filed the issue right now. I will also have a deeper look at the source 
code ... 
although I am probably too much of a coding noob to figure out what to do 
(even with your precious hint).

On Saturday, 9 July 2016 14:15:29 UTC+1, Tim Holy wrote:
>
> Looks like xcorr has a type-instability. You can see this from 
>
> x = rand(10 * 192000); u = rand(10 * 192000, 3); 
> su = sub(u, :, 1); 
> @code_warntype xcorr(x, su) 
>
> Would you mind filing an issue? 
> https://github.com/JuliaLang/julia/issues/new 
> Alternatively, if you feel up to fixing it, the hint is "don't reuse 
> variable 
> names when the type might change." 
>
> Best, 
> --Tim 
>
> On Saturday, July 9, 2016 5:01:24 AM CDT CrocoDuck O'Ducks wrote: 
> > Hi there! 
> > 
> > I am making few experiments with simple methods. This method calculates 
> the 
> > delay between two signals (mono-dimensional arrays) using xcorr(): 
> > 
> > function finddelay{T <: Real}(x::AbstractArray{T, 1}, 
> u::AbstractArray{T, 1 
> > }) 
> > 
> > # Delay as lag between cross correlation from origin of time 
> > 
> > sₓᵤ = xcorr(x, u) 
> > 
> > ct_idx = cld(length(sₓᵤ), 2) 
> > 
> > _, pk_idx = findmax(sₓᵤ, 1) 
> > 
> > δ = ct_idx - pk_idx[1] 
> > 
> > return δ 
> > 
> > end 
> > 
> > Now, I would like to add a method that picks up a mono-dimensional array 
> x, 
> > a bi-dimensional array u, and then calculates the delay between x and 
> each 
> > of the columns of u.  I tried this: 
> > 
> > function finddelay{T <: Real}(x::AbstractArray{T, 1}, 
> u::AbstractArray{T, 2 
> > }) 
> > 
> > nᵤ = size(u, 2) 
> > 
> > δ = Array(Int, 1, nᵤ) 
> > 
> > for s = 1:nᵤ 
> > δ[s] = finddelay(x, u[:, s]) 
> > end 
> > 
> > return δ 
> > 
> > end 
> > 
> > It works good enough, here the benchmarks: 
> > 
> > x = rand(10 * 192000); u = rand(10 * 192000, 3) 
> > 
> > @benchmark finddelay(x, u) 
> >  Benchmark Results  
> >  Time per evaluation: 1.78 s [1.65 s, 1.91 s] 
> > Proportion of time in GC: 13.60% [10.52%, 16.69%] 
> > Memory allocated: 878.94 mb 
> >Number of allocations: 718 allocations 
> >Number of samples: 4 
> >Number of evaluations: 4 
> >  Time spent benchmarking: 9.21 s 
> > 
> > 
> >  However, by reading this cool book 
> > , 
>
> > I was suggested that using Array Views through sub() should reduce 
> memory 
> > usage. So I tried it: 
> > 
> > function finddelay{T <: Real}(x::AbstractArray{T, 1}, 
> u::AbstractArray{T, 2 
> > }) 
> > 
> > nᵤ = size(u, 2) 
> > 
> > δ = Array(Int, 1, nᵤ) 
> > 
> > xs = sub(x, :, 1) # I need all arguments of xcorr() to be Views 
> > 
> > for s = 1:nᵤ 
> > 
> > us = sub(u, :, s) 
> > 
> > δ[s] = finddelay(xs, us) 
> > 
> > end 
> > 
> > return δ 
> > 
> > end 
> > 
> > Which benchmarks as follows (same input arrays): 
> > 
> > @benchmark finddelay(x, u) 
> >  Benchmark Results  
> >  Time per evaluation: 2.44 s [2.41 s, 2.47 s] 
> > Proportion of time in GC: 12.55% [12.54%, 12.57%] 
> > Memory allocated: 1.07 gb 
> >Number of allocations: 17279216 allocations 
> >Number of samples: 3 
> >Number of evaluations: 3 
> >  Time spent benchmarking: 9.93 s 
> > 
> > 
> > 
> > I obtained the same benchmark by trying to copy the body of first method 
> in 
> > the loop of the second, adapting it to use with sub(). 
> > 
> > As such, I have few questions: 
> > 
> >- First of all, it is good practice to nest methods like this? 
> >- Second, why is sub associated with a huge increase in allocations? 
> Am 
> >I doing it wrong? Or maybe it is xcorr() that needs values and cannot 
> > work with references? 
>
>
>

Re: [julia-users] indexing over `zip(collection1, collection2)`

2016-07-09 Thread Scott Jones
I've found it very useful, even if it is O(n) complexity to get the n-th 
element, to allow indexing.

For a database, if you have a packed record (for example, like SQLite's row 
format), and you only need to access a single field, it's better to be able 
to do just that,
and *not* have to unpack the entire record just to do that (skipping fields 
can be many many times faster than unpacking them, plus the amount of time 
wasted on allocating
objects for all of the fields of records scanned and then GCing them).

I think it would be better to have a trait that you could find out if an 
indexable structure is directly indexable or not, kind of like strings used 
to have)
(or does that exist now, with all of the changes for Arraymageddon?)

On Thursday, June 23, 2016 at 3:35:06 PM UTC-4, Mauro wrote:
>
> My recollection is that part of the indexing interface in Julia (just by 
> convention) is that indexing should be of O(1) (or close to that) 
> complexity.  Iterable things, in general, have O(n) complexity to access 
> the n-th element, because you have to traverse the data to get there 
> (the classic example are linked lists).  Thus, it makes sense that 
> indexing is not supported, instead you have to call collect first if you 
> want to index. 
>
> On Thu, 2016-06-23 at 20:43, Davide Lasagna  > wrote: 
> > Hi Jacob, 
> > 
> > In my view, in principle, all "iterators" should be indexable, (at least 
> > read-only), *unless *the underlying data is not indexable by nature, 
> e.g. 
> > with data that comes from a stream...  Doing `zip([1, 2], [2, 3])[1]` 
> > should probably just work. 
> > 
> > I also think that for `Zip`s if the zipped collections are not 
> indexable, 
> > then the "outer" getindex method should fail internally with a 
> MethodError, 
> > on the "inner" getindex calls not implemented for the non-indexable 
> > collections. 
> > 
> > On Thursday, June 23, 2016 at 7:23:34 PM UTC+1, Jacob Quinn wrote: 
> >> 
> >> Sorry, to clarify a little: 
> >> 
> >> The things you're zipping are not necessarily indexable (i.e. other 
> >> iterators), so it's not safe to assume you can always index a Zip. 
> >> 
> >> On Thu, Jun 23, 2016 at 2:21 PM, Jacob Quinn  >> > wrote: 
> >> 
> >>> Most "iterator" types are not indexable, AFAIK. The typical 
> >>> recommendation/idiom is to just call `collect(itr)` if you need to 
> >>> specifically index. 
> >>> 
> >>> -Jacob 
> >>> 
> >>> On Thu, Jun 23, 2016 at 2:18 PM, Davide Lasagna  >>> > wrote: 
> >>> 
>  Is there any particular reason why `Zip` objects are iterable but not 
>  indexable? Python allows that. 
>  
>  From previous discussion on the topic (2014 topic at 
>  https://groups.google.com/forum/#!topic/julia-dev/5bgMvzJveWA) it 
> seems 
>  that it has not been implemented yet. 
>  
>  Thanks, 
>  
>  
>  
> >>> 
> >> 
>


Re: [julia-users] Few questions about methods and sub()

2016-07-09 Thread Tim Holy
Looks like xcorr has a type-instability. You can see this from

x = rand(10 * 192000); u = rand(10 * 192000, 3);
su = sub(u, :, 1);
@code_warntype xcorr(x, su)

Would you mind filing an issue? https://github.com/JuliaLang/julia/issues/new
Alternatively, if you feel up to fixing it, the hint is "don't reuse variable 
names when the type might change."

Best,
--Tim

On Saturday, July 9, 2016 5:01:24 AM CDT CrocoDuck O'Ducks wrote:
> Hi there!
> 
> I am making few experiments with simple methods. This method calculates the
> delay between two signals (mono-dimensional arrays) using xcorr():
> 
> function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 1
> })
> 
> # Delay as lag between cross correlation from origin of time
> 
> sₓᵤ = xcorr(x, u)
> 
> ct_idx = cld(length(sₓᵤ), 2)
> 
> _, pk_idx = findmax(sₓᵤ, 1)
> 
> δ = ct_idx - pk_idx[1]
> 
> return δ
> 
> end
> 
> Now, I would like to add a method that picks up a mono-dimensional array x,
> a bi-dimensional array u, and then calculates the delay between x and each
> of the columns of u.  I tried this:
> 
> function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 2
> })
> 
> nᵤ = size(u, 2)
> 
> δ = Array(Int, 1, nᵤ)
> 
> for s = 1:nᵤ
> δ[s] = finddelay(x, u[:, s])
> end
> 
> return δ
> 
> end
> 
> It works good enough, here the benchmarks:
> 
> x = rand(10 * 192000); u = rand(10 * 192000, 3)
> 
> @benchmark finddelay(x, u)
>  Benchmark Results 
>  Time per evaluation: 1.78 s [1.65 s, 1.91 s]
> Proportion of time in GC: 13.60% [10.52%, 16.69%]
> Memory allocated: 878.94 mb
>Number of allocations: 718 allocations
>Number of samples: 4
>Number of evaluations: 4
>  Time spent benchmarking: 9.21 s
> 
> 
>  However, by reading this cool book
> ,
> I was suggested that using Array Views through sub() should reduce memory
> usage. So I tried it:
> 
> function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 2
> })
> 
> nᵤ = size(u, 2)
> 
> δ = Array(Int, 1, nᵤ)
> 
> xs = sub(x, :, 1) # I need all arguments of xcorr() to be Views
> 
> for s = 1:nᵤ
> 
> us = sub(u, :, s)
> 
> δ[s] = finddelay(xs, us)
> 
> end
> 
> return δ
> 
> end
> 
> Which benchmarks as follows (same input arrays):
> 
> @benchmark finddelay(x, u)
>  Benchmark Results 
>  Time per evaluation: 2.44 s [2.41 s, 2.47 s]
> Proportion of time in GC: 12.55% [12.54%, 12.57%]
> Memory allocated: 1.07 gb
>Number of allocations: 17279216 allocations
>Number of samples: 3
>Number of evaluations: 3
>  Time spent benchmarking: 9.93 s
> 
> 
> 
> I obtained the same benchmark by trying to copy the body of first method in
> the loop of the second, adapting it to use with sub().
> 
> As such, I have few questions:
> 
>- First of all, it is good practice to nest methods like this?
>- Second, why is sub associated with a huge increase in allocations? Am
>I doing it wrong? Or maybe it is xcorr() that needs values and cannot
> work with references?




[julia-users] MathProgBase Conic problem specifying dual

2016-07-09 Thread steven Varga

Is it possible to specify the dual of an SOCP/SDP using MathProgBase 
interface?
 
It is well documented how to specify primal problem, but don't see any 
pointers to formulate the dual. The dual formulation is motivated if A 
matrix is non-square having more variables in primal then constraints.

Any help, pointers appreciated
steve

MathProgBase version:
commit 2faa7b97af385f61ea2e829512b5fa1c1c2ceab1
Author: Miles Lubin 
Date:   Thu Jun 2 15:30:42 2016 +0200

Julia Version 0.5.0-dev+1503
Commit 84fb0a4* (2016-05-27 03:12 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libmkl_rt
  LAPACK: libmkl_rt
  LIBM: libimf



Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread FANG Colin
I would suggest replace `round(result, 10)` with `round(result, 10) + 0.0`

On Saturday, July 9, 2016 at 1:34:43 PM UTC+1, Davide Lasagna wrote:
>
> Thanks, interesting point.
>
> In my specific use case -0.0 and 0.0 actually need to have the same hash, 
> as they represent conceptually the same abstract quantity. My data is the 
> result of an iterative computation which is eventually rounded to 10 
> decimal places and then hashed. I use the result's hash to check if a given 
> computation, (with tolerance a bit finer than the rounding), produces a new 
> solution.
>
> A more robust approach would be to test if abs(result - result_i) < \delta 
> for each result_i in a collection of previous results. However, this 
> operation scales linearly with the length of the collection, whereas using 
> a set, hence requiring overloading hash(::result), is a constant-time 
> operation. 
>
> Any thoughts on possible alternatives?
>
>
> On Saturday, July 9, 2016 at 12:40:58 PM UTC+1, Tom Breloff wrote:
>>
>> Yes. They are different numbers. In a way, negative zero represents "a 
>> really small negative number" that can't be represented exactly using 
>> floating point. 
>>
>> On Saturday, July 9, 2016, Davide Lasagna  wrote:
>>
>>> Hi, 
>>>
>>> I have just been bitten by a function hashing a custom type containing a 
>>> vector of floats. It turns out that hashing positive and negative floating 
>>> point zeros returns different hashes. 
>>>
>>> Demo:
>>> julia> hash(-0.0)
>>> 0x3be7d0f7780de548
>>>
>>> julia> hash(0.0)
>>> 0x77cfa1eef01bca90
>>>
>>> julia> hash(0)
>>> 0x77cfa1eef01bca90
>>>
>>> Is this expected behaviour?
>>>
>>>

Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread Scott Jones
At least Unums (1.0) and Arbs don't have that annoying asymmetry of IEEE 
floating point, you have exact zero, or inexact pos or neg "really small 
close to zero" in Unums,
or zero with a radius of 0, or a 0 with radius that can be *quite* small 
around zero (+/-), or something that can be as small as possible positive 
(but not zero), or small as possible negative (but not zero), with Arbs.
Nice and symmetric, which appeals to some of my OCD-like traits!

I've lately come to greatly appreciate Arbs compared to IEEE floats, thanks 
to Jeffrey Sarnoff's talk, and a number of people's work bringing Fredrijk 
Johansson's C Arb package https://github.com/fredrik-johansson/arb to Julia,
in WB Hart's et. al. Nemo.jl package https://github.com/wbhart/Nemo.jl, and 
Jeffrey's https://github.com/JuliaArbTypes/ArbFloats.jl.  

On Saturday, July 9, 2016 at 7:40:58 AM UTC-4, Tom Breloff wrote:
>
> Yes. They are different numbers. In a way, negative zero represents "a 
> really small negative number" that can't be represented exactly using 
> floating point.  



Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread Steven G. Johnson
Note that the DataStructures.jl package contains several sorted-container 
types, and the "searchsortedfirst" and "regress" functions will allow you 
to find the values in the container that are closest to a given key.


Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread Steven G. Johnson


On Saturday, July 9, 2016 at 8:34:43 AM UTC-4, Davide Lasagna wrote:
>
> A more robust approach would be to test if abs(result - result_i) < \delta 
> for each result_i in a collection of previous results. However, this 
> operation scales linearly with the length of the collection
>

There are lots of data structures you can use where that test would scale 
logarithmically with the length of the collection.  e.g. you could use a 
sorted container like a red-black tree.


Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread Davide Lasagna
Thanks, interesting point.

In my specific use case -0.0 and 0.0 actually need to have the same hash, 
as they represent conceptually the same abstract quantity. My data is the 
result of an iterative computation which is eventually rounded to 10 
decimal places and then hashed. I use the result's hash to check if a given 
computation, (with tolerance a bit finer than the rounding), produces a new 
solution.

A more robust approach would be to test if abs(result - result_i) < \delta 
for each result_i in a collection of previous results. However, this 
operation scales linearly with the length of the collection, whereas using 
a set, hence requiring overloading hash(::result), is a constant-time 
operation. 

Any thoughts on possible alternatives?


On Saturday, July 9, 2016 at 12:40:58 PM UTC+1, Tom Breloff wrote:
>
> Yes. They are different numbers. In a way, negative zero represents "a 
> really small negative number" that can't be represented exactly using 
> floating point. 
>
> On Saturday, July 9, 2016, Davide Lasagna  > wrote:
>
>> Hi, 
>>
>> I have just been bitten by a function hashing a custom type containing a 
>> vector of floats. It turns out that hashing positive and negative floating 
>> point zeros returns different hashes. 
>>
>> Demo:
>> julia> hash(-0.0)
>> 0x3be7d0f7780de548
>>
>> julia> hash(0.0)
>> 0x77cfa1eef01bca90
>>
>> julia> hash(0)
>> 0x77cfa1eef01bca90
>>
>> Is this expected behaviour?
>>
>>

Re: [julia-users] Could someone explain @static?

2016-07-09 Thread Isaiah Norton
This is mostly for precompilation and library use. When compiling a shared
library we can't rely on a runtime check if the compiler is not available
(and trying to compile both branches is inefficient and might be impossible
for the reason in the help section).

On Saturday, July 9, 2016, feza  wrote:

> The docs read
>
> @static()
>
> Partially evaluates an expression at parse time.
>
> For example, @static is_windows() ? foo : bar will evaluateis_windows() and
> insert either foo or bar into the expression. This is useful in cases
> where a construct would be invalid on other platforms, such as a ccall to
> a non-existent function.
>
> My understanding at a very top level is that julia code is first parsed,
> macro expanded, then compiled.
>
> Now why is it important for this to be handled at parse time? I don't
> really understand the following `This is useful in cases where a
> construct would be invalid on other platforms, such as a ccall to a
> non-existent function.`
>
> Why couldn't  a simple
>
> ` if is_windows(); foo; else; bar; end `
>
>  work and why do we need @static?
>


Re: [julia-users] ccall doesnt work in embed.c example

2016-07-09 Thread Isaiah Norton
The symbol exists but is not exported (t vs T). Try adding DLLEXPORT in
front of the function declaration. On 0.4 it appears to have had a
Windows-only export declaration.

On Saturday, July 9, 2016, Sourabh Chadha  wrote:

> I am new to Julia and have been trying to use ccall to call C functions in
> embedded mode but i am unable to even successfully run the example
> embedding.c that is in package. The example file define a
> function my_c_sqrt and then tries to call it using jl_eval_string("println(
> ccall( :my_c_sqrt, Float64, (Float64,), 2.0 ) )");. This doesnt work and if
> i trace the issue by printing errors i get ErrorException("ccall: could not
> find function my_c_sqrt").
>
> I have tried checking eveything. nm on the executble gives this.
> nm ../usr/bin/embedding | grep my
> 00601d80 t __frame_dummy_init_array_entry
> 00400f60 t frame_dummy
> 00400f90 t my_c_sqrt
>
> so the symbol is available.
>
> I am running Red Hat Enterprise Linux Workstation release 7.0 (Maipo) nd
> hve compiled julia Version 0.4.6 from scratch.
>
> any help would be really appreciated
>
>


[julia-users] Few questions about methods and sub()

2016-07-09 Thread CrocoDuck O'Ducks
Hi there!

I am making few experiments with simple methods. This method calculates the 
delay between two signals (mono-dimensional arrays) using xcorr():

function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 1
})

# Delay as lag between cross correlation from origin of time 

sₓᵤ = xcorr(x, u)

ct_idx = cld(length(sₓᵤ), 2)

_, pk_idx = findmax(sₓᵤ, 1)

δ = ct_idx - pk_idx[1]

return δ

end

Now, I would like to add a method that picks up a mono-dimensional array x, 
a bi-dimensional array u, and then calculates the delay between x and each 
of the columns of u.  I tried this:

function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 2
})

nᵤ = size(u, 2)

δ = Array(Int, 1, nᵤ)

for s = 1:nᵤ
δ[s] = finddelay(x, u[:, s])
end

return δ

end

It works good enough, here the benchmarks:

x = rand(10 * 192000); u = rand(10 * 192000, 3)

@benchmark finddelay(x, u)
 Benchmark Results 
 Time per evaluation: 1.78 s [1.65 s, 1.91 s]
Proportion of time in GC: 13.60% [10.52%, 16.69%]
Memory allocated: 878.94 mb
   Number of allocations: 718 allocations
   Number of samples: 4
   Number of evaluations: 4
 Time spent benchmarking: 9.21 s


 However, by reading this cool book 
, 
I was suggested that using Array Views through sub() should reduce memory 
usage. So I tried it:

function finddelay{T <: Real}(x::AbstractArray{T, 1}, u::AbstractArray{T, 2
})

nᵤ = size(u, 2)

δ = Array(Int, 1, nᵤ)

xs = sub(x, :, 1) # I need all arguments of xcorr() to be Views

for s = 1:nᵤ

us = sub(u, :, s)

δ[s] = finddelay(xs, us)

end

return δ

end

Which benchmarks as follows (same input arrays):

@benchmark finddelay(x, u)
 Benchmark Results 
 Time per evaluation: 2.44 s [2.41 s, 2.47 s]
Proportion of time in GC: 12.55% [12.54%, 12.57%]
Memory allocated: 1.07 gb
   Number of allocations: 17279216 allocations
   Number of samples: 3
   Number of evaluations: 3
 Time spent benchmarking: 9.93 s



I obtained the same benchmark by trying to copy the body of first method in 
the loop of the second, adapting it to use with sub().

As such, I have few questions:

   - First of all, it is good practice to nest methods like this?
   - Second, why is sub associated with a huge increase in allocations? Am 
   I doing it wrong? Or maybe it is xcorr() that needs values and cannot work 
   with references?
   


[julia-users] changing record separator to read text files

2016-07-09 Thread Fred
Hi !

It is often very useful to read a text files by blocks of lines, using 
another line separator than '\n'.

Especially in bio-informatics, for example DNA or Protein FASTA sequences 
are separated by '\n>' (see uniprot.txt attached).

In Perl,  it is possible to change the line separator using :
 local $/ = '\n>'
for example.

In Julia I did not found how to do that :

line by line :

julia> f = open("uniprot.txt")
IOStream()

julia> readline(f, '\n>' )
ERROR: syntax: invalid character literal




all lines in an array (I prefer line by line because some files do not fit 
into RAM) :

julia> readdlm("uniprot.txt", '\n>' )
ERROR: syntax: invalid character literal

readdlm("uniprot.txt", '>' ) # works but does not give the expected result


So I suppose that this feature is currently not implemented in Julia ? 

Thanks in advance for your comments !



>sp|P31946|1433B_HUMAN 14-3-3 protein beta/alpha OS=Homo sapiens GN=YWHAB PE=1 
>SV=3
MTMDKSELVQKAKLAEQAERYDDMAAAMKAVTEQGHELSNEERNLLSVAYKNVVGARRSS
WRVISSIEQKTERNEKKQQMGKEYREKIEAELQDICNDVLELLDKYLIPNATQPESKVFY
LKMKGDYFRYLSEVASGDNKQTTVSNSQQAYQEAFEISKKEMQPTHPIRLGLALNFSVFY
YEILNSPEKACSLAKTAFDEAIAELDTLNEESYKDSTLIMQLLRDNLTLWTSENQGDEGD
AGEGEN
>sp|P04439|1A03_HUMAN HLA class I histocompatibility antigen, A-3 alpha chain 
>OS=Homo sapiens GN=HLA-A PE=1 SV=2
MAVMAPRTLSGALALTQTWAGSHSMRYFFTSVSRPGRGEPRFIAVGYVDDTQFVRF
DSDAASQRMEPRAPWIEQEGPEYWDQETRNVKAQSQTDRVDLGTLRGYYNQSEAGSHTIQ
IMYGCDVGSDGRFLRGYRQDAYDGKDYIALNEDLRSWTAADMAAQITKRKWEAAHEAEQL
RAYLDGTCVEWLRRYLENGKETLQRTDPPKTHMTHHPISDHEATLRCWALGFYPAEITLT
WQRDGEDQTQDTELVETRPAGDGTFQKWAAVVVPSGEEQRYTCHVQHEGLPKPLTLRWEL
SSQPTIPIVGIIAGLVLLGAVITGAVVAAVMWRRKSSDRKGGSYTQAASSDSAQGSDVSL
TACKV
>sp|P01889|1B07_HUMAN HLA class I histocompatibility antigen, B-7 alpha chain 
>OS=Homo sapiens GN=HLA-B PE=1 SV=3
MLVMAPRTVSAALALTETWAGSHSMRYFYTSVSRPGRGEPRFISVGYVDDTQFVRF
DSDAASPREEPRAPWIEQEGPEYWDRNTQIYKAQAQTDRESLRNLRGYYNQSEAGSHTLQ
SMYGCDVGPDGRLLRGHDQYAYDGKDYIALNEDLRSWTAADTAAQITQRKWEAAREAEQR
RAYLEGECVEWLRRYLENGKDKLERADPPKTHVTHHPISDHEATLRCWALGFYPAEITLT
WQRDGEDQTQDTELVETRPAGDRTFQKWAAVVVPSGEEQRYTCHVQHEGLPKPLTLRWEP
SSQSTVPIVGIVAGLAVLAVVVIGAVVAAVMCRRKSSGGKGGSYSQAACSDSAQGSDVSL
TA
>sp|P30464|1B15_HUMAN HLA class I histocompatibility antigen, B-15 alpha chain 
>OS=Homo sapiens GN=HLA-B PE=1 SV=2
MRVTAPRTVSGALALTETWAGSHSMRYFYTAMSRPGRGEPRFIAVGYVDDTQFVRF
DSDAASPRMAPRAPWIEQEGPEYWDRETQISKTNTQTYRESLRNLRGYYNQSEAGSHTLQ
RMYGCDVGPDGRLLRGHDQSAYDGKDYIALNEDLSSWTAADTAAQITQRKWEAAREAEQW
RAYLEGLCVEWLRRYLENGKETLQRADPPKTHVTHHPISDHEATLRCWALGFYPAEITLT
WQRDGEDQTQDTELVETRPAGDRTFQKWAAVVVPSGEEQRYTCHVQHEGLPKPLTLRWEP
SSQSTIPIVGIVAGLAVLAVVVIGAVVATVMCRRKSSGGKGGSYSQAASSDSAQGSDVSL
TA


Re: [julia-users] hashing floating point zeroes

2016-07-09 Thread Tom Breloff
Yes. They are different numbers. In a way, negative zero represents "a
really small negative number" that can't be represented exactly using
floating point.

On Saturday, July 9, 2016, Davide Lasagna  wrote:

> Hi,
>
> I have just been bitten by a function hashing a custom type containing a
> vector of floats. It turns out that hashing positive and negative floating
> point zeros returns different hashes.
>
> Demo:
> julia> hash(-0.0)
> 0x3be7d0f7780de548
>
> julia> hash(0.0)
> 0x77cfa1eef01bca90
>
> julia> hash(0)
> 0x77cfa1eef01bca90
>
> Is this expected behaviour?
>
>


[julia-users] hashing floating point zeroes

2016-07-09 Thread Davide Lasagna
Hi, 

I have just been bitten by a function hashing a custom type containing a 
vector of floats. It turns out that hashing positive and negative floating 
point zeros returns different hashes. 

Demo:
julia> hash(-0.0)
0x3be7d0f7780de548

julia> hash(0.0)
0x77cfa1eef01bca90

julia> hash(0)
0x77cfa1eef01bca90

Is this expected behaviour?



Re: [julia-users] Dear Sublime Text Users

2016-07-09 Thread Tom Breloff
You has me at LaTeX. :)   Looking forward to checking this out.

On Saturday, July 9, 2016, Randy Lai  wrote:

> Hi all Sublime Text uers,
>
>
> I have just created a tiny package Julia-Unicode
>  to help inserting LaTeX and
> Unicode in Sublime Text. It uses the Julia mappings so you don't have to
> worry about
> the different betwwen ɛ (\varepsilon) and ϵ (\epsilon).
> You may have heard of Julia Completions
>  or UnicodeMath
> , I promise you that
> Julia-Unicode works better than them :).
>
> Check it out from Package Control.
>
> Feedbacks appreciated.
>


Re: [julia-users] JuliaCon schedule announced

2016-07-09 Thread feza
Patiently waiting on stefan's talk

On Sunday, July 3, 2016 at 1:58:48 PM UTC-4, Viral Shah wrote:
>
> They will keep trickling in. We will announce widely when everything is 
> up. 
>
> -viral 
>
>
> > On 03-Jul-2016, at 9:25 AM, dnm  
> wrote: 
> > 
> > Will Stefan's talk and the other keynote be up? 
> > 
> > On Friday, July 1, 2016 at 12:36:19 AM UTC-4, Christian Peel wrote: 
> > A link: https://www.youtube.com/user/JuliaLanguage/videos 
> > 
> > On Thu, Jun 30, 2016 at 3:43 AM, Viral Shah  wrote: 
> > They have already started appearing. Hopefully by next week they will 
> all be up and we will announce then. 
> > 
> > -viral 
> > 
> > On Jun 28, 2016 11:44 AM, "mmh"  wrote: 
> > Hi Viral, we have an eta on when the talks will be up on youtube? 
> > 
> > On Wednesday, June 22, 2016 at 11:13:25 AM UTC-4, Viral Shah wrote: 
> > Live streaming was too expensive and we did not do it this year, but we 
> certainly want to next year. 
> > 
> > -viral 
> > 
> > On Jun 22, 2016 10:33 AM, "Gabriel Gellner"  
> wrote: 
> > For future conferences I would be super stoked to pay some fee to have 
> early access if that would help at all. Super stoked to see so many of 
> these sweet talks! 
> > 
> > On Wednesday, June 22, 2016 at 6:49:43 AM UTC-7, Viral Shah wrote: 
> > Yes they will be and hopefully much sooner than last year. 
> > 
> > -viral 
> > 
> > On Jun 22, 2016 7:31 AM, "nuffe"  wrote: 
> > Will all the talks be posted on youtube, like last year? If so, do you 
> know when? Thank you (overseas enthusiast) 
> > 
> > On Thursday, June 9, 2016 at 11:34:18 PM UTC+2, Viral Shah wrote: 
> > The JuliaCon talks and workshop schedule has now been announced. 
> > 
> > http://juliacon.org/schedule.html 
> > 
> > Please buy your tickets if you have been procrastinating. We have seen 
> tickets going much faster this year, and waiting until the day before is 
> unlikely to work this year. Please also spread the message to your friends 
> and colleagues and relevant mailing lists. Here's the conference poster for 
> emailing and printing: 
> > 
> > http://juliacon.org/pdf/juliacon2016poster3.pdf 
> > 
> > -viral 
> > 
> > 
> > 
> > -- 
> > chris...@ieee.org 
>
>

[julia-users] Could someone explain @static?

2016-07-09 Thread feza
The docs read

@static()

Partially evaluates an expression at parse time.

For example, @static is_windows() ? foo : bar will evaluateis_windows() and 
insert either foo or bar into the expression. This is useful in cases where 
a construct would be invalid on other platforms, such as a ccall to a 
non-existent function.

My understanding at a very top level is that julia code is first parsed, 
macro expanded, then compiled.

Now why is it important for this to be handled at parse time? I don't 
really understand the following `This is useful in cases where a construct 
would be invalid on other platforms, such as a ccall to a non-existent 
function.`

Why couldn't  a simple

` if is_windows(); foo; else; bar; end ` 

 work and why do we need @static?


[julia-users] Re: Symbolic differentiation similar to TensorFlow / Theano

2016-07-09 Thread Andrei Zh
Thanks for all your answers! Just to make it clear, at the moment I'm not 
really interested in TensorFlow itself, but specifically in its automatic 
differentiation capabilities. 

ReverseDiffSource.jl looks very promising and is indeed quite fast for `R^n 
-> R` in a few experiments I've made. Thanks again!

On Saturday, July 9, 2016 at 3:02:55 AM UTC+3, Andrei Zh wrote:
>
> In Python, libraries like TensorFlow or Theano provide possibility to 
> perform automatic differentiation over their computational graphs. E.g. in 
> TensorFlow (example from SO 
> 
> ): 
>
> data = tf.placeholder(tf.float32)
> var = tf.Variable(...)  
> loss = some_function_of(var, data)
>
> var_grad = tf.gradients(loss, [var])[0]
>
> What is the closest thing in Julia at the moment? 
>
> Here's what I've checked so far: 
>
>  * ForwardDiff.jl  - it 
> computes derivatives using forward mode automatic differentiation (AD). 
> Although AD has particular advantages, I found this package quite slow. 
> E.g. for a vector of 1000 elements gradient takes ~100x times longer then 
> the function itself. Another potential issues is that ForwardDiff.jl 
> doesn't output symbolic version of gradient and thus is hardly usable for 
> computation on GPU, for example. 
>  * *Calculus.jl*  - among 
> other things, this package provided symbolic differentiation. However, it 
> seems to consider all symbols to be numbers and doesn't support matrices or 
> vectors. 
>
> I have pretty shallow knowledge of both these packages, so please correct 
> me if I'm wrong somewhere in my conclusions. And if not, is there any other 
> package or project that I should consider? 
>


Re: [julia-users] Ambiguity error when dispatching on Union types

2016-07-09 Thread Tim Holy
Ambiguities are often a bit tricky. Two tips I've adopted:

- Have as few methods as possible, and declare types on their arguments only 
when absolutely necessary. These measures greatly reduce your exposure to the 
risk of ambiguities. To achieve this, it sometimes takes a fair bit of thought 
to design your API.

- Use one layer of indirection per argument you want to specialize. There are 
a couple of ways to pull this off, and the best way to do it usually depends 
on the specific goal you're trying to achieve. But here one approach might be 
to decide that `f` will only be specialized on argument 2, and will otherwise 
dispatch to `f1` (which you can specialize for argument 1).

f(a, b) = f1(a, b)
f(a, b::A) = "from A"
f1(a::Int, b) = "Int"
f1(a, b) = "other"

Best,
--Tim

On Friday, July 8, 2016 8:27:30 PM CDT Darwin Darakananda wrote:
> Is there a recommended way to getting around that?  The example above had a
> union of only two types, but in the actual code I'm working on there are a
> couple more.  Would I have to copying the code over and over with just
> small changes to the type signature? I guess you could use a macro to
> splice the types in.
> 
> On Friday, July 8, 2016 at 7:58:02 PM UTC-7, Yichao Yu wrote:
> > On Fri, Jul 8, 2016 at 10:32 PM, Darwin Darakananda
> > 
> >  wrote:
> > > Hi everyone,
> > > 
> > > I have some code where multiple types share the same implementation of a
> > > method, for example:
> > > 
> > > abstract MyType
> > > 
> > > 
> > > type A <: MyType end
> > > type B <: MyType end
> > > 
> > > 
> > > f(target::MyType, source::MyType) = "fallback"
> > > 
> > > 
> > > f(target::Int,source::A) = "from A"
> > > f(target::MyType, source::A) = "from A"
> > > 
> > > a = A()
> > > b = B()
> > > 
> > > f(b, b) # fallback
> > > f(b, a) # from A
> > > f(a, a) # from A
> > > 
> > > I was hoping that I could replace the "from A" function using a union
> > 
> > type,
> > 
> > > but I'm running into ambiguity errors:
> > > 
> > > f(target::Union{Int, MyType}, source::A) = "from A"
> > > 
> > > f(b, b) # fallback
> > > f(b, a) # Ambiguity error
> > > f(a, a) # Ambiguity error
> > > 
> > > Is this an expected behavior?
> > 
> > Yes.
> > 
> > > I thought that (::Union{Int, MyType}, ::A)
> > > would be a more specific match to (::B, ::A) than (::MyType, ::MyType).
> > 
> > There's basically nothing as a "more specific match". The two methods
> > are ambiguous and anything in their intersection cannot be dispatched
> > to either of them.
> > 
> > > Any ideas/suggestions?
> > > 
> > > Thanks,
> > > 
> > > Darwin




Re: [julia-users] Julia ccall windows

2016-07-09 Thread Bart Janssens
Hi Karli,

With CxxWrap.jl you can write a small C++ wrapper in VisualStudio that can
then easily be used from Julia to access your C++ functions. See
https://github.com/barche/CxxWrap.jl

It does require at least Visual Studio 2015 update 2 (I tested with the
community edition).

Cheers,

Bart

On Sat, Jul 9, 2016 at 1:16 AM Karli Kund  wrote:

>
>
> I'm new with Julia one(many) problem(s). I'm using c++ libraries
> (.dll/.lib) to connect my c++ program to company's program (it connects to
> home 127.0.0.1 through 5111 port by calling function "connect(port,in, out)
> and it works). Now I have Julia code that has to the same thing. My
> question is, how can I use this libraries? I try to use ccall function, but
> it doesn't find those libraries. I haven't found any info on windows how to
> set different libraries for ccall.
>
> Other option is I translate everything to c++, but...no. Maybe second
> option is that I open the libraries and re-write them to Julia.
>
> I'm using windows 7 and visual studio for c++. For Julia I use Atom with
> Juno package.
>


[julia-users] missing sparse Cholesky functionality?

2016-07-09 Thread vavasis
According to the Julia manual, the :L factor obtained from sparse Cholesky 
is not useful because the permutation is not applied.  The manual says that 
the :PtL factor should be used instead.  However, there does not seem to be 
a documented method to bring the :PtL factor back into Julia:

Here is the trace from Julia 0.4.6:

julia> A = speye(7);
julia> F = cholfact(A);
julia> L = sparse(F[:L]);
julia> PtL = sparse(F[:PtL])
ERROR: MethodError: `size` has no method matching 
size(::Base.SparseMatrix.CHOLMOD.Factor{Float64})
Closest candidates are:
  size(::Base.SparseMatrix.CHOLMOD.Factor{Tv}, ::Integer)
  size(::Any, ::Integer, ::Integer, ::Integer...)
 in convert at sparse/sparsematrix.jl:214
 in sparse at sparse/sparsematrix.jl:320

I wrote a function to accomplish this task, but it uses 
undocumented/unexported functions and is also probably wasteful in its 
array creation.  (See below.)  Does anyone know of a better way?  

-- Steve Vavasis

# Compute the permuted cholesky factor of a sparse, symmetric 
# positive definite matrix A.
function cholfactPtL(A)
n = size(A,1)
F = cholfact(A)
L0 = sparse(F[:L])
is,js,es = findnz(L0)
p = Base.SparseMatrix.CHOLMOD.get_perm(F)
sparse(p[is], p[js], es, n, n)
end



Re: [julia-users] Error using inner constructors and type parameters

2016-07-09 Thread Milan Bouchet-Valat
Le vendredi 08 juillet 2016 à 18:20 -0700, James Noeckel a écrit :
> type LinkedMesh{RT<:Real}
>   faces::LinkedList{LinkedFace}
>   vertices::Array{Point{3, RT}, 1}
>   LinkedMesh(points::Array{Point{3, RT}, 1}) = new(nil(LinkedFace),
> points)
> end
> 
> 
> When I pass the below value to the above constructor, I get an error:
> points::AbstractArray{Point{3, FT}, 1} #the value isn't relevant
> 
> mesh = LinkedMesh(points)
> 
> 
> ERROR: MethodError: `convert` has no method matching
> convert(::Type{Meshing.LinkedMesh{RT<:Real}},
> ::Array{FixedSizeArrays.Point{3,Float64},1})
> This may have arisen from a call to the constructor
> Meshing.LinkedMesh{RT<:Real}(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   call{T}(::Type{T}, ::Any)
>   convert{T}(::Type{T}, ::T)
> 
> 
> This suggests that it isn't using my constructor at all, possibly
> because of the type parameter. But Float64 is a subtype of Real, so I
> don't see why this isn't working.
That's because you defined an inner constructor. In that case, the
default one-argument outer constructor isn't created automatically. 

The inner constructor needs to be passed the type parameter, like this:
LinkedMesh{FT}(points)

You can create the outer constructor with:
LinkedMesh{RT}(points::Array{Point{3, RT}, 1}) = LinkedMesh{RT}(points)

But if your example corresponds to what you actually need, you can just
transform the inner constructor into an outer constructor. Inner
constructors should be used only when really needed, i.e. when you have
to check the passed arguments to prevent creating invalid objects. See
the manual for more details.


Regards


[julia-users] Re: Julia version of Matplotlib griddata?

2016-07-09 Thread Josef Heinen
You can use the GR framework, e.g.

srand(0)
xd = -2 + 4 * rand(100)
yd = -2 + 4 * rand(100)
zd = [Float64(xd[i] * exp(-xd[i]^2 - yd[i]^2)) for i = 1:100]

using GR
contour(xd, yd, zd, colormap=44)



If you only need the gridded data, use the GR gridit function, e.g. (to 
obtain a 200 x 200 grid):

x, y, z = GR.gridit(xd, yd, zd, 200, 200)


On Saturday, July 9, 2016 at 12:57:51 AM UTC+2, Kaj Wiik wrote:
>
> Is there a Julia version of irregularly spaced data gridding that does
> zi = griddata(x,y,z,xi,yi), i.e. all arguments are 1d vectors? It seems 
> that Julia interp and contour packages require x, y, z[x,y].
>
>
> https://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/Gridding_irregularly_spaced_data.html
>
> Thanks,
> Kaj
>
>

[julia-users] Dear Sublime Text Users

2016-07-09 Thread Randy Lai
Hi all Sublime Text uers,


I have just created a tiny package Julia-Unicode 
 to help inserting LaTeX and 
Unicode in Sublime Text. It uses the Julia mappings so you don't have to 
worry about
the different betwwen ɛ (\varepsilon) and ϵ (\epsilon).
You may have heard of Julia Completions 
 or UnicodeMath 
, I promise you that Julia-Unicode 
works better than them :).

Check it out from Package Control.

Feedbacks appreciated.


[julia-users] Re: Symbolic differentiation similar to TensorFlow / Theano

2016-07-09 Thread Gabriel Goh
 

There is also


https://github.com/mlubin/ReverseDiffSparse.jl


I've never used it myself, but I thought i'd throw it out there.

On Saturday, July 9, 2016 at 12:27:33 AM UTC-7, Gabriel Goh wrote:
>
> Forward differentiation has a bad complexity for functions of the form R^n 
> -> R. try using ReverseDiffSource.jl instead
>
> This blog posts describes positive results using ReverseDiffSource.jl on 
> an autoencoder
>
>
> http://int8.io/automatic-differentiation-machine-learning-julia/#Training_autoencoder_8211_results
>
> since back-propagation is reverse differentiation, this should in theory 
> be equivalent to tensor flow's automatic differentiation.
>
> On Friday, July 8, 2016 at 5:02:55 PM UTC-7, Andrei Zh wrote:
>>
>> In Python, libraries like TensorFlow or Theano provide possibility to 
>> perform automatic differentiation over their computational graphs. E.g. in 
>> TensorFlow (example from SO 
>> 
>> ): 
>>
>> data = tf.placeholder(tf.float32)
>> var = tf.Variable(...)  
>> loss = some_function_of(var, data)
>>
>> var_grad = tf.gradients(loss, [var])[0]
>>
>> What is the closest thing in Julia at the moment? 
>>
>> Here's what I've checked so far: 
>>
>>  * ForwardDiff.jl  - it 
>> computes derivatives using forward mode automatic differentiation (AD). 
>> Although AD has particular advantages, I found this package quite slow. 
>> E.g. for a vector of 1000 elements gradient takes ~100x times longer then 
>> the function itself. Another potential issues is that ForwardDiff.jl 
>> doesn't output symbolic version of gradient and thus is hardly usable for 
>> computation on GPU, for example. 
>>  * *Calculus.jl*  - among 
>> other things, this package provided symbolic differentiation. However, it 
>> seems to consider all symbols to be numbers and doesn't support matrices or 
>> vectors. 
>>
>> I have pretty shallow knowledge of both these packages, so please correct 
>> me if I'm wrong somewhere in my conclusions. And if not, is there any other 
>> package or project that I should consider? 
>>
>

[julia-users] Re: Symbolic differentiation similar to TensorFlow / Theano

2016-07-09 Thread Gabriel Goh
Forward differentiation has a bad complexity for functions of the form R^n 
-> R. try using ReverseDiffSource.jl instead

This blog posts describes positive results using ReverseDiffSource.jl on an 
autoencoder

http://int8.io/automatic-differentiation-machine-learning-julia/#Training_autoencoder_8211_results

since back-propagation is reverse differentiation, this should in theory be 
equivalent to tensor flow's automatic differentiation.

On Friday, July 8, 2016 at 5:02:55 PM UTC-7, Andrei Zh wrote:
>
> In Python, libraries like TensorFlow or Theano provide possibility to 
> perform automatic differentiation over their computational graphs. E.g. in 
> TensorFlow (example from SO 
> 
> ): 
>
> data = tf.placeholder(tf.float32)
> var = tf.Variable(...)  
> loss = some_function_of(var, data)
>
> var_grad = tf.gradients(loss, [var])[0]
>
> What is the closest thing in Julia at the moment? 
>
> Here's what I've checked so far: 
>
>  * ForwardDiff.jl  - it 
> computes derivatives using forward mode automatic differentiation (AD). 
> Although AD has particular advantages, I found this package quite slow. 
> E.g. for a vector of 1000 elements gradient takes ~100x times longer then 
> the function itself. Another potential issues is that ForwardDiff.jl 
> doesn't output symbolic version of gradient and thus is hardly usable for 
> computation on GPU, for example. 
>  * *Calculus.jl*  - among 
> other things, this package provided symbolic differentiation. However, it 
> seems to consider all symbols to be numbers and doesn't support matrices or 
> vectors. 
>
> I have pretty shallow knowledge of both these packages, so please correct 
> me if I'm wrong somewhere in my conclusions. And if not, is there any other 
> package or project that I should consider? 
>


[julia-users] Re: Julia version of Matplotlib griddata?

2016-07-09 Thread Josef Heinen
You can use the GR framework, e.g.

srand(0)

xd = -2 + 4 * rand(100)

yd = -2 + 4 * rand(100)

zd = [Float64(xd[i] * exp(-xd[i]^2 - yd[i]^2)) for i = 1:100]


using GR

contour(xd, yd, zd)




If you only need the mesh data, use the gridit function, e.g. (for a 200 x 
200 grid):


x, y, z = GR.gridit(xd, yd, zd, 200, 200)



On Saturday, July 9, 2016 at 12:57:51 AM UTC+2, Kaj Wiik wrote:
>
> Is there a Julia version of irregularly spaced data gridding that does
> zi = griddata(x,y,z,xi,yi), i.e. all arguments are 1d vectors? It seems 
> that Julia interp and contour packages require x, y, z[x,y].
>
>
> https://scipy.github.io/old-wiki/pages/Cookbook/Matplotlib/Gridding_irregularly_spaced_data.html
>
> Thanks,
> Kaj
>
>

[julia-users] IBM Power port

2016-07-09 Thread Viral Shah
The current master now seems to be in good shape for Power, for those 
interested in trying it out. OpenBLAS is still working out a few bugs, but 
in the meanwhile, I was able to successfully link against Atlas using the 
following Make.user:

override USE_SYSTEM_BLAS = 1
override LIBBLAS = -L/usr/lib64/atlas -lsatlas
override LIBBLASNAME = libsatlas
override USE_BLAS64 = 0

Apart from multi-threading, all the other tests passed.

-viral



[julia-users] ccall doesnt work in embed.c example

2016-07-09 Thread Sourabh Chadha
I am new to Julia and have been trying to use ccall to call C functions in 
embedded mode but i am unable to even successfully run the example 
embedding.c that is in package. The example file define a 
function my_c_sqrt and then tries to call it using jl_eval_string("println( 
ccall( :my_c_sqrt, Float64, (Float64,), 2.0 ) )");. This doesnt work and if 
i trace the issue by printing errors i get ErrorException("ccall: could not 
find function my_c_sqrt").

I have tried checking eveything. nm on the executble gives this.
nm ../usr/bin/embedding | grep my
00601d80 t __frame_dummy_init_array_entry
00400f60 t frame_dummy
00400f90 t my_c_sqrt

so the symbol is available.

I am running Red Hat Enterprise Linux Workstation release 7.0 (Maipo) nd 
hve compiled julia Version 0.4.6 from scratch.

any help would be really appreciated



[julia-users] Error using inner constructors and type parameters

2016-07-09 Thread James Noeckel
type LinkedMesh{RT<:Real}
  faces::LinkedList{LinkedFace}
  vertices::Array{Point{3, RT}, 1}
  LinkedMesh(points::Array{Point{3, RT}, 1}) = new(nil(LinkedFace), points)
end


When I pass the below value to the above constructor, I get an error:
points::AbstractArray{Point{3, FT}, 1} #the value isn't relevant

mesh = LinkedMesh(points)


ERROR: MethodError: `convert` has no method matching 
convert(::Type{Meshing.LinkedMesh{RT<:Real}}, 
::Array{FixedSizeArrays.Point{3,Float64},1})
This may have arisen from a call to the constructor 
Meshing.LinkedMesh{RT<:Real}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)


This suggests that it isn't using my constructor at all, possibly because 
of the type parameter. But Float64 is a subtype of Real, so I don't see why 
this isn't working.