[julia-users] Re: When does colon indexing get evaluated / converted?

2015-09-21 Thread 'Greg Plowman' via julia-users
Hi All,
Thanks all for your replies.

OK I can see this will be much easier in v0.4.
I will revisit when v0.4 released.

I'm still curious about colon and end

> Colon lowering changed in 0.4, 


Matt, could you expand on this? How/when is this done in v0.3 vs v0.4?

Does this mean v0.3 code attempting to dispatch on Colon type cannot work? 
(for example the code from subarray.jl quoted below) 

sub(A::AbstractArray, I::Union(RangeIndex, Colon)...) = sub(A, ntuple(length
(I), i-> isa(I[i], Colon) ? (1:size(A,i)) : I[i])...)

I noticed that  OffsetArrays (https://github.com/alsam/OffsetArrays.jl 

 
jA 
)
 
defines const (..) = Colon(), presumably to use .. in place of :

Will it work in v0.4?
How and when is end converted?

Thanks again,
Greg





Re: [julia-users] Re: Pkg.publish() woes

2015-09-21 Thread Amit Murthy
Thanks!

On Tue, Sep 22, 2015 at 9:56 AM, Seth  wrote:

> I got it to work and wrote my process up here:
> https://github.com/JuliaLang/julia/issues/10766
>
>
> On Monday, September 21, 2015 at 9:05:38 PM UTC-7, Amit Murthy wrote:
>>
>> julia> Pkg.publish()
>>
>> INFO: Validating METADATA
>> INFO: Pushing LibCURL permanent tags: v0.1.6
>> INFO: Submitting METADATA changes
>> INFO: Forking JuliaLang/METADATA.jl to amitmurthy
>> INFO: Recompiling stale cache file /home/amitm/.julia/lib/v0.4/JSON.ji
>> for module JSON.
>> Enter host password for user 'amitmurthy':
>> INFO: Two-factor authentication in use.  Enter auth code.  (You may have
>> to re-enter your password.)
>> Authentication code: xx
>> Enter host password for user 'amitmurthy':
>> INFO: Retrieving existing GitHub token. (You may have to re-enter your
>> password twice more.)
>> Enter host password for user 'amitmurthy':
>> New authentication code: xx
>> Enter host password for user 'amitmurthy':
>> INFO: Could not authenticate with existing token. Deleting token and
>> trying again.
>> Enter host password for user 'amitmurthy':
>> INFO: Two-factor authentication in use.  Enter auth code.  (You may have
>> to re-enter your password.)
>> Authentication code: xx
>> Enter host password for user 'amitmurthy':
>> INFO: Retrieving existing GitHub token. (You may have to re-enter your
>> password twice more.)
>> Enter host password for user 'amitmurthy':
>> New authentication code: xx
>> Enter host password for user 'amitmurthy':
>> ERROR: forking JuliaLang/METADATA.jl failed: Bad credentials
>>  in error at ./error.jl:21
>>  in fork at pkg/github.jl:144
>>  in pull_request at pkg/entry.jl:327
>>  in publish at pkg/entry.jl:394
>>  in anonymous at pkg/dir.jl:31
>>  in cd at file.jl:22
>>  in cd at pkg/dir.jl:31
>>  in publish at pkg.jl:61
>>
>>
>>
>> After entering credentials umpteen number of times, it just barfs out.
>> Any pointers?
>>
>>
>>
>>
>>


[julia-users] Re: Pkg.publish() woes

2015-09-21 Thread Seth
I got it to work and wrote my process up 
here: https://github.com/JuliaLang/julia/issues/10766

On Monday, September 21, 2015 at 9:05:38 PM UTC-7, Amit Murthy wrote:
>
> julia> Pkg.publish()
>
> INFO: Validating METADATA
> INFO: Pushing LibCURL permanent tags: v0.1.6
> INFO: Submitting METADATA changes
> INFO: Forking JuliaLang/METADATA.jl to amitmurthy
> INFO: Recompiling stale cache file /home/amitm/.julia/lib/v0.4/JSON.ji for 
> module JSON.
> Enter host password for user 'amitmurthy':
> INFO: Two-factor authentication in use.  Enter auth code.  (You may have 
> to re-enter your password.)
> Authentication code: xx
> Enter host password for user 'amitmurthy':
> INFO: Retrieving existing GitHub token. (You may have to re-enter your 
> password twice more.)
> Enter host password for user 'amitmurthy':
> New authentication code: xx
> Enter host password for user 'amitmurthy':
> INFO: Could not authenticate with existing token. Deleting token and 
> trying again.
> Enter host password for user 'amitmurthy':
> INFO: Two-factor authentication in use.  Enter auth code.  (You may have 
> to re-enter your password.)
> Authentication code: xx
> Enter host password for user 'amitmurthy':
> INFO: Retrieving existing GitHub token. (You may have to re-enter your 
> password twice more.)
> Enter host password for user 'amitmurthy':
> New authentication code: xx
> Enter host password for user 'amitmurthy':
> ERROR: forking JuliaLang/METADATA.jl failed: Bad credentials
>  in error at ./error.jl:21
>  in fork at pkg/github.jl:144
>  in pull_request at pkg/entry.jl:327
>  in publish at pkg/entry.jl:394
>  in anonymous at pkg/dir.jl:31
>  in cd at file.jl:22
>  in cd at pkg/dir.jl:31
>  in publish at pkg.jl:61
>
>
>
> After entering credentials umpteen number of times, it just barfs out. Any 
> pointers?
>
>
>
>
>

[julia-users] Pkg.publish() woes

2015-09-21 Thread Amit Murthy
julia> Pkg.publish()

INFO: Validating METADATA
INFO: Pushing LibCURL permanent tags: v0.1.6
INFO: Submitting METADATA changes
INFO: Forking JuliaLang/METADATA.jl to amitmurthy
INFO: Recompiling stale cache file /home/amitm/.julia/lib/v0.4/JSON.ji for 
module JSON.
Enter host password for user 'amitmurthy':
INFO: Two-factor authentication in use.  Enter auth code.  (You may have to 
re-enter your password.)
Authentication code: xx
Enter host password for user 'amitmurthy':
INFO: Retrieving existing GitHub token. (You may have to re-enter your 
password twice more.)
Enter host password for user 'amitmurthy':
New authentication code: xx
Enter host password for user 'amitmurthy':
INFO: Could not authenticate with existing token. Deleting token and trying 
again.
Enter host password for user 'amitmurthy':
INFO: Two-factor authentication in use.  Enter auth code.  (You may have to 
re-enter your password.)
Authentication code: xx
Enter host password for user 'amitmurthy':
INFO: Retrieving existing GitHub token. (You may have to re-enter your 
password twice more.)
Enter host password for user 'amitmurthy':
New authentication code: xx
Enter host password for user 'amitmurthy':
ERROR: forking JuliaLang/METADATA.jl failed: Bad credentials
 in error at ./error.jl:21
 in fork at pkg/github.jl:144
 in pull_request at pkg/entry.jl:327
 in publish at pkg/entry.jl:394
 in anonymous at pkg/dir.jl:31
 in cd at file.jl:22
 in cd at pkg/dir.jl:31
 in publish at pkg.jl:61



After entering credentials umpteen number of times, it just barfs out. Any 
pointers?






Re: [julia-users] Re: Can Julia function be serialized and sent by network?

2015-09-21 Thread edward zhang

hmm, I'm already very interested in the project like Julia-on-(Spark/c++?), 
and the ser/des issue is a big obstacle.
在 2015年9月21日星期一 UTC+8下午9:30:05,Andrei Zh写道:
>
> Hi, 
>
> not yet. I made some initial research regarding serialization of ASTs and 
> reconstructing functions from them, but it seems quite a tricky procedure 
> and I have very little time for this project now. I plan to come back to 
> this issue around the beginning of the next month. 
>
> On Mon, Sep 21, 2015 at 11:25 AM, edward zhang  > wrote:
>
>> hi, dear, 
>>  have you already fixed this problem?
>>
>>
>> 在 2015年8月14日星期五 UTC+8下午11:06:30,Andrei Zh写道:
>>
>>>
>>> Hi Jake, 
>>>
>>> your example works because you don't leave Julia session. `foo` is 
>>> defined in this session, so the the pair of module name and function name 
>>> is enough to get function object. If you save serialized function (or just 
>>> retype it byte by byte) , it won't work. Here's an example: 
>>>
>>> Session #1: 
>>>
>>> julia> io = IOBuffer()
>>> IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, 
>>> append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
>>>
>>>
>>> julia> foo(x) =  x + 1
>>> foo (generic function with 1 method)
>>>
>>>
>>> julia> serialize(io, foo)
>>>
>>>
>>> julia> takebuf_array(io)
>>> 9-element Array{Uint8,1}:
>>>  0x13
>>>  0x02
>>>  0x23
>>>  0x2f
>>>  0x02
>>>  0x03
>>>  0x66
>>>  0x6f
>>>  0x6f
>>>
>>>
>>> julia>
>>>
>>>
>>>
>>> Session #2: 
>>>
>>> julia> data = Uint8[0x13, 0x02, 0x23, 0x2f, 0x02, 0x03, 0x66, 0x6f, 0x6f
>>> ]
>>> 9-element Array{Uint8,1}:
>>>  0x13
>>>  0x02
>>>  0x23
>>>  0x2f
>>>  0x02
>>>  0x03
>>>  0x66
>>>  0x6f
>>>  0x6f
>>>
>>>
>>> julia> io = IOBuffer(data)
>>> IOBuffer(data=Uint8[...], readable=true, writable=false, seekable=true, 
>>> append=false, size=9, maxsize=Inf, ptr=1, mark=-1)
>>>
>>>
>>> julia> bar = deserialize(io)
>>> (anonymous function)
>>>
>>>
>>> julia> bar(1)
>>> ERROR: function foo not defined on process 1
>>>  in error at error.jl:21
>>>  in anonymous at serialize.jl:398
>>>
>>>
>>> julia>
>>>
>>>  
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Friday, August 14, 2015 at 5:49:55 PM UTC+3, Jake Bolewski wrote:

 Andrei Zh

 I'm confused.  Have you actually tried?  

 julia> io = IOBuffer()
 IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, 
 append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

 julia> foo(x) =  x + 1
 foo (generic function with 1 method)

 julia> serialize(io, foo)

 julia> seekstart(io)
 IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, 
 append=false, size=9, maxsize=Inf, ptr=1, mark=-1)

 julia> baz = deserialize(io)
 foo (generic function with 1 method)

 julia> baz(1)
 2

 The serialization code won't recursively serialize all the of the 
 functions dependencies so you will have to send/serialize the code that 
 defines the environment (types, constants, Packages, etc).

>>>
>

[julia-users] Re: Default Ipython profile in Ijulia

2015-09-21 Thread Steven G. Johnson
You can still have as many profiles as you want. (Google "ipython profile"). It 
is just that, with IPython 3 or later (or Jupyter 4+), you no are no longer 
forced to have a separate profile just to use Julia. Consequently, IJulia no 
longer sets up a profile by default. 

Re: [julia-users] Re: What's your favourite editor?

2015-09-21 Thread El suisse
Vim
☺
​

2015-09-21 17:54 GMT-03:00 Christoph Ortner :

> I'd be grateful to hear from other emacs users regarding your workflows
> for Julia development, e.g. if you want to write a Julia package what emacs
> packages, setup and workflow help you to be the most productive?
>
> I find a combination of emacs for modules; iJulia for experimenting,
> testing, debugging, examples; and REPL for help works very well.
>
> Typically, I sketch something in IJulia, then convert it to a module,
> which is further edited in emacs, but keep test codes in Julia, and
> eventually I also move the test codes to a module.
>
> Christoph
>
>
>
>


[julia-users] Why does type inference not work for cat? (0.4-rc1)

2015-09-21 Thread Sheehan Olver
The code below can't infer the return type of cat.  Should I file an issue 
or is this expected?


v=rand(5)
@code_warntype cat(1,0.0,v,0.0)
...
end::ANY


[julia-users] Re: What's your favourite editor?

2015-09-21 Thread Jason Castiglione

Same here, I really like ironing out stuff using IJulia and ipython 
notebook. Once everything works , it turns into a module.
Once in a module I like notepad++ or emacs.

On Monday, September 21, 2015 at 10:54:34 AM UTC-10, Christoph Ortner wrote:

> I'd be grateful to hear from other emacs users regarding your workflows 
> for Julia development, e.g. if you want to write a Julia package what emacs 
> packages, setup and workflow help you to be the most productive?
>
> I find a combination of emacs for modules; iJulia for experimenting, 
> testing, debugging, examples; and REPL for help works very well.
>
> Typically, I sketch something in IJulia, then convert it to a module, 
> which is further edited in emacs, but keep test codes in Julia, and 
> eventually I also move the test codes to a module.
>
> Christoph
>
>
>
>

[julia-users] Re: Default Ipython profile in Ijulia

2015-09-21 Thread Jason Castiglione


On Saturday, September 19, 2015 at 6:22:29 PM UTC-10, David P. Sanders 
wrote:
>
> Hi, 
>
> Which version if the (ipython / jupyter)  notebook do you have? It sounds 
> like it's at least 3. (The one that lets you choose between different 
> kernels.) 
>
> In that case, you should no longer put the --profile, i.e. Just run 
> ipython notebook
>
> David 
>


I had wanted the ability to have several profiles. It had worked prior to 
the update. Right now I think it just chooses the default profile, i.e., 
profile_default instead of using profile_julia.

I can still type run(`"ipython" notebook --profile=julia`) in the Julia 
prompt. I just wasn't sure if there was a configuration file somewhere that 
specifies the profile.


 


[julia-users] Re: What's your favourite editor?

2015-09-21 Thread Christoph Ortner
I'd be grateful to hear from other emacs users regarding your workflows for 
Julia development, e.g. if you want to write a Julia package what emacs 
packages, setup and workflow help you to be the most productive?

I find a combination of emacs for modules; iJulia for experimenting, 
testing, debugging, examples; and REPL for help works very well.

Typically, I sketch something in IJulia, then convert it to a module, which 
is further edited in emacs, but keep test codes in Julia, and eventually I 
also move the test codes to a module.

Christoph





Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Milan Bouchet-Valat
Le lundi 21 septembre 2015 à 06:05 -0700, Uwe Fechner a écrit :
> Did anyone ask Forio if they would change the license (as they are 
> obviously not longer interested in the project)?
What's the problem with the license of Julia Studio? AFAICT that's a
vanilla GPL3. Since Forio isn't interested in developing it anymore,
there's no point in pushing your changes upstream, and hence no need to
sign the contributor license agreement.


Regards

> 
> Uwe
> 
> Am Montag, 21. September 2015 13:52:57 UTC+2 schrieb Christof
> Stocker:
> > I did consider looking into that but as soon as I saw the license I
> > ran for my life. Its a similar issue with Julietta. Although what
> > is an issue to me doesn't have to be an issue to others
> > 
> > On 2015-09-21 13:48, Steven Sagaert wrote:
> > > +1 
> > > & to add to Uwe's post: AFAIK JuliaStudio is based on Qt (&
> > > QtCreator I believe). I thought that JuliaStudio was a nice start
> > > (also based on QtCreator). I wish a group would fork it and
> > > develop it further in the direction of RStudio.
> > > 
> > > On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof
> > > Stocker wrote:
> > > > I would be a huge fan of an RStudio like Julia IDE
> > > > 
> > > > On 2015-09-18 10:05, Uwe Fechner wrote:
> > > > > I like QT a lot. There is more then one open source, QT based
> > > > > IDE out there, e.g. QT Creator.
> > > > > QT has a GUI builder, that is much better then the GUI
> > > > > builders for GTK (in my opinion).
> > > > > And you can use the java-script like QML language for
> > > > > building the user interface, if you want to.
> > > > > 
> > > > > Tutorial for PyQT:
> > > > > https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/
> > > > > 
> > > > > As soon as the Julia/C++ integration is available by default
> > > > > (hopefully in Julia 0.5), QT integration
> > > > > should be easy. For those, that want to play with Julia and
> > > > > QT now already, have a look at:
> > > > > 
> > > > > https://github.com/jverzani/PySide.jl
> > > > > 
> > > > > (very experimental)
> > > > > 
> > > > > Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel
> > > > > Carrera:
> > > > > > There are no Qt bindings for Julia yet. I also don't know
> > > > > > what text editing component is provided by Qt or what its
> > > > > > features are. I began working with Gtk in part because the
> > > > > > Julia Gtk bindings seem to be the most developed.
> > > > > > 
> > > > > > Is there a reason you like Qt besides it being cross
> > > > > > -platform?
> > > > > > 
> > > > > > 
> > > > > > On 17 September 2015 at 23:50, SrAceves <
> > > > > > mauri.c...@gmail.com> wrote:
> > > > > > > What about Qt? RStudio is fantastic: Qt based, multi
> > > > > > > -platoform. Everything anyone ever wanted of an IDE.
> > > > > > > 
> > > > > > > El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5),
> > > > > > > Daniel Carrera escribió:
> > > > > > > > 
> > > > > > > > Last night I started experimenting with Gtk, and
> > > > > > > > started making a sketch of what a Julia IDE might look
> > > > > > > > like. In the process I am writing down a list of things
> > > > > > > > that are probably needed before a Julia IDE
> > > > > > > > 
> > > > > > > > 
> > > > > > > >  getting a list of things that probably need to exist
> > > > > > > > before a Julia IDE can be completed. This is what I
> > > > > > > > have so far:
> > > > > > > > 1) A Julia package for the GNOME Docking Library
> > > > > > > > 
> > > > > > > > I think most people expect that an IDE has docking 
> > > > > > > > 
> > > > > > > > Despite the name, it does not depend on any GNOME
> > > > > > > > libraries, only Gtk. This is what Anjuta and
> > > > > > > > MonoDevelop use to get docking windows. I think most
> > > > > > > > people expect to be able to move things around in an
> > > > > > > > IDE.
> > > > > > > > 
> > > > > > > > https://developer.gnome.org/gdl/
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 2)
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > On 14 September 2015 at 17:10, <
> > > > > > > > jonatha...@alumni.epfl.ch> wrote:
> > > > > > > > > Gtk, the code isn't published but it's very similar
> > > > > > > > > to Julietta:
> > > > > > > > > 
> > > > > > > > > https://github.com/tknopp/Julietta.jl
> > > > > > > > > 
> > > > > > > > 
> > > > > > 
> > > > 
> > 


[julia-users] [ANN] Nettle.jl API breakage

2015-09-21 Thread Elliot Saba
Nettle.jl  has just broken its
API significantly, in order to be much more precompile-friendly.  The big
takeaway is that methods such as `md5_hash(data)` should be mapped to
`digest("md5", data)`, there are no more auto-generated types for hashes,
and internally the code is a little easier to grok.  This new version of
`Nettle.jl` has not been released yet, I will make every effort to ensure
that dependent packages have a chance to adapt before releasing the new
version.
-E


[julia-users] Q-less QR?

2015-09-21 Thread Dominique Orban
Is it possible to compute the Q-less QR factorization of a sparse matrix in 
Julia? In Matlab, you can write R = qr(A), but I don't see it in the Julia 
documentation. Sorry if I missed it.

Thanks.


[julia-users] Julia users in Minnesota?

2015-09-21 Thread Sean Garborg
I'm moving back to Minneapolis (where my family is from). 

Any Julia users up there?


Re: [julia-users] linspace and HDF5

2015-09-21 Thread Jan Strube
@pyimport, nifty.
Thanks!

On Monday, September 21, 2015 at 11:03:35 AM UTC-7, Tom Breloff wrote:
>
> This seemed to match:
>  
>
>> using PyPlot, PyCall
>> @pyimport matplotlib.colors as COL
>> @pyimport numpy as np
>> xaxis = linspace(1, 20, 101)
>> yaxis = linspace(2, 5, 101)
>> data = Float64[x+y for x in xaxis, y in yaxis];
>> X, Y = np.meshgrid(xaxis, yaxis)
>> plt = pcolormesh(X, Y, data', norm = COL.LogNorm(vmin=minimum(data), 
>> vmax=maximum(data)))
>> colorbar()
>> savefig("test.png")
>
>
>  
>
> On Mon, Sep 21, 2015 at 1:34 PM, Jan Strube  > wrote:
>
>> A small python snippet that does roughly what I want is below.
>> I'm using asymmetric data to remind myself whether to transpose the 
>> matrix or not.
>> Thanks for your help.
>>
>>
>> from matplotlib import pyplot as plt
>> from matplotlib.colors import LogNorm 
>> import numpy as np 
>> import sys 
>> xaxis = np.linspace(1, 20, 101) 
>> yaxis = np.linspace(2, 5, 101) 
>> data = np.zeros((100, 100)) 
>>
>> for x in range(100): 
>> for y in range(100): 
>> data[x,y] = xaxis[x] + yaxis[y] 
>> X, Y = np.meshgrid(xaxis, yaxis) 
>> # I can figure out how to make this figure in Julia
>> #p = plt.pcolormesh(X, Y, data.T) 
>>
>> # This is what I would like instead
>> p = plt.pcolormesh(X, Y, data.T, norm=LogNorm(vmin=np.min(data), vmax=np.
>> max(data))) 
>> plt.colorbar(p) 
>> plt.savefig("test.png")
>>
>>
>>
>>
>>
>> On Sunday, September 20, 2015 at 8:54:26 PM UTC-7, Tom Breloff wrote:
>>>
>>> Yes you should probably use `collect`.
>>>
>>> With regards to plotting... can you post the pyplot code that generates 
>>> the graph that you want?  We may be able to either show you how to do it in 
>>> julia, or it will help in future development by pinpointing a deficiency.  
>>> Thanks.
>>>
>>> On Sun, Sep 20, 2015 at 11:11 PM, Jan Strube  wrote:
>>>
 I'm trying to write some data and axis definitions to HDF5 for later 
 plotting in pyplot. (Because I haven't figured out how to do lognorm on 
 pcolormesh in PyPlot.jl)
 Writing the data - a 2D array - is no problem.
 Writing the axes - linspace(min, max, 100) - doesn't work, because I 
 just found out that linspace creates a LinSpace object, not an array, and 
 HDF5 doesn't know how to write that.
 My question is: What is an idiomatic way to turn LinSpace into an 
 Array? Is collect the recommended way to do this?


>>>
>

Re: [julia-users] Re: What's your favourite editor?

2015-09-21 Thread Mauro
> Thanks for all the replies. Having previously tried Sublime, Atom and 
> LightTable I've spent the year learning Vim and have now switched to Emacs 
> (evil-mode). 
>
> I'd be grateful to hear from other emacs users regarding your workflows for 
> Julia development, e.g. if you want to write a Julia package what emacs 
> packages, setup and workflow help you to be the most productive?

After a long odyssey, you've seen the light ;-)


Re: [julia-users] linspace and HDF5

2015-09-21 Thread Tom Breloff
This seemed to match:


> using PyPlot, PyCall
> @pyimport matplotlib.colors as COL
> @pyimport numpy as np
> xaxis = linspace(1, 20, 101)
> yaxis = linspace(2, 5, 101)
> data = Float64[x+y for x in xaxis, y in yaxis];
> X, Y = np.meshgrid(xaxis, yaxis)
> plt = pcolormesh(X, Y, data', norm = COL.LogNorm(vmin=minimum(data),
> vmax=maximum(data)))
> colorbar()
> savefig("test.png")




On Mon, Sep 21, 2015 at 1:34 PM, Jan Strube  wrote:

> A small python snippet that does roughly what I want is below.
> I'm using asymmetric data to remind myself whether to transpose the matrix
> or not.
> Thanks for your help.
>
>
> from matplotlib import pyplot as plt
> from matplotlib.colors import LogNorm
> import numpy as np
> import sys
> xaxis = np.linspace(1, 20, 101)
> yaxis = np.linspace(2, 5, 101)
> data = np.zeros((100, 100))
>
> for x in range(100):
> for y in range(100):
> data[x,y] = xaxis[x] + yaxis[y]
> X, Y = np.meshgrid(xaxis, yaxis)
> # I can figure out how to make this figure in Julia
> #p = plt.pcolormesh(X, Y, data.T)
>
> # This is what I would like instead
> p = plt.pcolormesh(X, Y, data.T, norm=LogNorm(vmin=np.min(data), vmax=np.
> max(data)))
> plt.colorbar(p)
> plt.savefig("test.png")
>
>
>
>
>
> On Sunday, September 20, 2015 at 8:54:26 PM UTC-7, Tom Breloff wrote:
>>
>> Yes you should probably use `collect`.
>>
>> With regards to plotting... can you post the pyplot code that generates
>> the graph that you want?  We may be able to either show you how to do it in
>> julia, or it will help in future development by pinpointing a deficiency.
>> Thanks.
>>
>> On Sun, Sep 20, 2015 at 11:11 PM, Jan Strube  wrote:
>>
>>> I'm trying to write some data and axis definitions to HDF5 for later
>>> plotting in pyplot. (Because I haven't figured out how to do lognorm on
>>> pcolormesh in PyPlot.jl)
>>> Writing the data - a 2D array - is no problem.
>>> Writing the axes - linspace(min, max, 100) - doesn't work, because I
>>> just found out that linspace creates a LinSpace object, not an array, and
>>> HDF5 doesn't know how to write that.
>>> My question is: What is an idiomatic way to turn LinSpace into an Array?
>>> Is collect the recommended way to do this?
>>>
>>>
>>


[julia-users] Re: What's your favourite editor?

2015-09-21 Thread Terry Seaward
Thanks for all the replies. Having previously tried Sublime, Atom and 
LightTable I've spent the year learning Vim and have now switched to Emacs 
(evil-mode). 

I'd be grateful to hear from other emacs users regarding your workflows for 
Julia development, e.g. if you want to write a Julia package what emacs 
packages, setup and workflow help you to be the most productive?



Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Uwe Fechner
On their homepage they say:
"As a desktop replacement for Julia Studio, Forio recommends Juno 
"

Uwe

Am Montag, 21. September 2015 18:49:13 UTC+2 schrieb Daniel Carrera:
>
> How do you know they are not interested?
>
> On 21 September 2015 at 15:05, Uwe Fechner  > wrote:
>
>> Did anyone ask Forio if they would change the license (as they are 
>> obviously not longer
>> interested in the project)?
>>
>> Uwe
>>
>> Am Montag, 21. September 2015 13:52:57 UTC+2 schrieb Christof Stocker:
>>>
>>> I did consider looking into that but as soon as I saw the license I ran 
>>> for my life. Its a similar issue with Julietta. Although what is an issue 
>>> to me doesn't have to be an issue to others
>>>
>>> On 2015-09-21 13:48, Steven Sagaert wrote:
>>>
>>> +1  
>>> & to add to Uwe's post: AFAIK JuliaStudio is based on Qt (& QtCreator I 
>>> believe). I thought that JuliaStudio was a nice start (also based on 
>>> QtCreator). I wish a group would fork it and develop it further in the 
>>> direction of RStudio.
>>>
>>> On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof Stocker 
>>> wrote: 

 I would be a huge fan of an RStudio like Julia IDE

 On 2015-09-18 10:05, Uwe Fechner wrote:

 I like QT a lot. There is more then one open source, QT based IDE out 
 there, e.g. QT Creator.
 QT has a GUI builder, that is much better then the GUI builders for GTK 
 (in my opinion).
 And you can use the java-script like QML language for building the user 
 interface, if you want to.

 Tutorial for PyQT:
 https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/

 As soon as the Julia/C++ integration is available by default (hopefully 
 in Julia 0.5), QT integration
 should be easy. For those, that want to play with Julia and QT now 
 already, have a look at:

 https://github.com/jverzani/PySide.jl

 (very experimental)

 Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel Carrera: 
>
> There are no Qt bindings for Julia yet. I also don't know what text 
> editing component is provided by Qt or what its features are. I began 
> working with Gtk in part because the Julia Gtk bindings seem to be the 
> most 
> developed. 
>
> Is there a reason you like Qt besides it being cross-platform?
>
>
> On 17 September 2015 at 23:50, SrAceves  wrote:
>
>> What about Qt? RStudio is fantastic: Qt based, multi-platoform. 
>> Everything anyone ever wanted of an IDE.
>>
>> El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5), Daniel Carrera 
>> escribió: 
>>>
>>>
>>> Last night I started experimenting with Gtk, and started making a 
>>> sketch of what a Julia IDE might look like. In the process I am writing 
>>> down a list of things that are probably needed before a Julia IDE
>>>
>>>
>>>  getting a list of things that probably need to exist before a Julia 
>>> IDE can be completed. This is what I have so far:
>>> 1) A Julia package for the GNOME Docking Library
>>>
>>> I think most people expect that an IDE has docking 
>>>
>>> Despite the name, it does not depend on any GNOME libraries, only 
>>> Gtk. This is what Anjuta and MonoDevelop use to get docking windows. I 
>>> think most people expect to be able to move things around in an IDE.
>>>
>>> https://developer.gnome.org/gdl/
>>>
>>>
>>> 2)
>>>
>>>
>>>
>>> On 14 September 2015 at 17:10,  wrote:
>>>
 Gtk, the code isn't published but it's very similar to Julietta: 

 https://github.com/tknopp/
 Julietta.jl

>>>
>>>
>

>>>
>

Re: [julia-users] linspace and HDF5

2015-09-21 Thread Jan Strube
A small python snippet that does roughly what I want is below.
I'm using asymmetric data to remind myself whether to transpose the matrix 
or not.
Thanks for your help.


from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm 
import numpy as np 
import sys 
xaxis = np.linspace(1, 20, 101) 
yaxis = np.linspace(2, 5, 101) 
data = np.zeros((100, 100)) 

for x in range(100): 
for y in range(100): 
data[x,y] = xaxis[x] + yaxis[y] 
X, Y = np.meshgrid(xaxis, yaxis) 
# I can figure out how to make this figure in Julia
#p = plt.pcolormesh(X, Y, data.T) 

# This is what I would like instead
p = plt.pcolormesh(X, Y, data.T, norm=LogNorm(vmin=np.min(data), vmax=np.max
(data))) 
plt.colorbar(p) 
plt.savefig("test.png")





On Sunday, September 20, 2015 at 8:54:26 PM UTC-7, Tom Breloff wrote:
>
> Yes you should probably use `collect`.
>
> With regards to plotting... can you post the pyplot code that generates 
> the graph that you want?  We may be able to either show you how to do it in 
> julia, or it will help in future development by pinpointing a deficiency.  
> Thanks.
>
> On Sun, Sep 20, 2015 at 11:11 PM, Jan Strube  > wrote:
>
>> I'm trying to write some data and axis definitions to HDF5 for later 
>> plotting in pyplot. (Because I haven't figured out how to do lognorm on 
>> pcolormesh in PyPlot.jl)
>> Writing the data - a 2D array - is no problem.
>> Writing the axes - linspace(min, max, 100) - doesn't work, because I just 
>> found out that linspace creates a LinSpace object, not an array, and HDF5 
>> doesn't know how to write that.
>> My question is: What is an idiomatic way to turn LinSpace into an Array? 
>> Is collect the recommended way to do this?
>>
>>
>

Re: [julia-users] Boolean operations on arrays?

2015-09-21 Thread Daniel Carrera
Oh Thanks!

On 21 September 2015 at 19:21, Matt Bauman  wrote:

> More concretely, && and || are control flow operators.  They short
> circuit.  Therefore, they require Boolean arguments and aren't real
> functions.  They're syntax.
>
> & and | are bitwise operations and real, extendable functions.  They can
> operate on booleans *and* integers, performing bitwise arithmetic (often
> used for bit flags):
>
> julia> 0x2345 & 0x0F0F
> 0x0305
>
> julia> ans | 0x6070
> 0x6375
>
> On Monday, September 21, 2015 at 1:09:31 PM UTC-4, Sisyphuss wrote:
>>
>> & works for array
>> && works for scale
>>
>>
>> On Monday, September 21, 2015 at 6:50:48 PM UTC+2, Daniel Carrera wrote:
>>>
>>>
>>> On Monday, 21 September 2015 14:39:13 UTC+2, Yichao Yu wrote:


 julia> [true, true, false] & [false, true, true]
 3-element Array{Bool,1}:
 false
  true
 false

>>>
>>> Thanks! What is the difference between & and && ?
>>>
>>


Re: [julia-users] Boolean operations on arrays?

2015-09-21 Thread Matt Bauman
More concretely, && and || are control flow operators.  They short circuit. 
 Therefore, they require Boolean arguments and aren't real functions. 
 They're syntax.

& and | are bitwise operations and real, extendable functions.  They can 
operate on booleans *and* integers, performing bitwise arithmetic (often 
used for bit flags):

julia> 0x2345 & 0x0F0F
0x0305

julia> ans | 0x6070
0x6375

On Monday, September 21, 2015 at 1:09:31 PM UTC-4, Sisyphuss wrote:
>
> & works for array
> && works for scale
>
>
> On Monday, September 21, 2015 at 6:50:48 PM UTC+2, Daniel Carrera wrote:
>>
>>
>> On Monday, 21 September 2015 14:39:13 UTC+2, Yichao Yu wrote:
>>>
>>>
>>> julia> [true, true, false] & [false, true, true] 
>>> 3-element Array{Bool,1}: 
>>> false 
>>>  true 
>>> false 
>>>
>>
>> Thanks! What is the difference between & and && ? 
>>
>

Re: [julia-users] Boolean operations on arrays?

2015-09-21 Thread Sisyphuss
& works for array
&& works for scale


On Monday, September 21, 2015 at 6:50:48 PM UTC+2, Daniel Carrera wrote:
>
>
> On Monday, 21 September 2015 14:39:13 UTC+2, Yichao Yu wrote:
>>
>>
>> julia> [true, true, false] & [false, true, true] 
>> 3-element Array{Bool,1}: 
>> false 
>>  true 
>> false 
>>
>
> Thanks! What is the difference between & and && ? 
>


Re: [julia-users] Boolean operations on arrays?

2015-09-21 Thread Daniel Carrera

On Monday, 21 September 2015 14:39:13 UTC+2, Yichao Yu wrote:
>
>
> julia> [true, true, false] & [false, true, true] 
> 3-element Array{Bool,1}: 
> false 
>  true 
> false 
>

Thanks! What is the difference between & and && ? 


[julia-users] Re: Help using Requests.jl

2015-09-21 Thread Jonathan Malmaud
Can you file this as an issue on the requests.jl github page? I'll be able to 
help you then. 

Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Daniel Carrera
How do you know they are not interested?

On 21 September 2015 at 15:05, Uwe Fechner 
wrote:

> Did anyone ask Forio if they would change the license (as they are
> obviously not longer
> interested in the project)?
>
> Uwe
>
> Am Montag, 21. September 2015 13:52:57 UTC+2 schrieb Christof Stocker:
>>
>> I did consider looking into that but as soon as I saw the license I ran
>> for my life. Its a similar issue with Julietta. Although what is an issue
>> to me doesn't have to be an issue to others
>>
>> On 2015-09-21 13:48, Steven Sagaert wrote:
>>
>> +1
>> & to add to Uwe's post: AFAIK JuliaStudio is based on Qt (& QtCreator I
>> believe). I thought that JuliaStudio was a nice start (also based on
>> QtCreator). I wish a group would fork it and develop it further in the
>> direction of RStudio.
>>
>> On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof Stocker
>> wrote:
>>>
>>> I would be a huge fan of an RStudio like Julia IDE
>>>
>>> On 2015-09-18 10:05, Uwe Fechner wrote:
>>>
>>> I like QT a lot. There is more then one open source, QT based IDE out
>>> there, e.g. QT Creator.
>>> QT has a GUI builder, that is much better then the GUI builders for GTK
>>> (in my opinion).
>>> And you can use the java-script like QML language for building the user
>>> interface, if you want to.
>>>
>>> Tutorial for PyQT:
>>> https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/
>>>
>>> As soon as the Julia/C++ integration is available by default (hopefully
>>> in Julia 0.5), QT integration
>>> should be easy. For those, that want to play with Julia and QT now
>>> already, have a look at:
>>>
>>> https://github.com/jverzani/PySide.jl
>>>
>>> (very experimental)
>>>
>>> Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel Carrera:

 There are no Qt bindings for Julia yet. I also don't know what text
 editing component is provided by Qt or what its features are. I began
 working with Gtk in part because the Julia Gtk bindings seem to be the most
 developed.

 Is there a reason you like Qt besides it being cross-platform?


 On 17 September 2015 at 23:50, SrAceves  wrote:

> What about Qt? RStudio is fantastic: Qt based, multi-platoform.
> Everything anyone ever wanted of an IDE.
>
> El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5), Daniel Carrera
> escribió:
>>
>>
>> Last night I started experimenting with Gtk, and started making a
>> sketch of what a Julia IDE might look like. In the process I am writing
>> down a list of things that are probably needed before a Julia IDE
>>
>>
>>  getting a list of things that probably need to exist before a Julia
>> IDE can be completed. This is what I have so far:
>> 1) A Julia package for the GNOME Docking Library
>>
>> I think most people expect that an IDE has docking
>>
>> Despite the name, it does not depend on any GNOME libraries, only
>> Gtk. This is what Anjuta and MonoDevelop use to get docking windows. I
>> think most people expect to be able to move things around in an IDE.
>>
>> https://developer.gnome.org/gdl/
>>
>>
>> 2)
>>
>>
>>
>> On 14 September 2015 at 17:10,  wrote:
>>
>>> Gtk, the code isn't published but it's very similar to Julietta:
>>>
>>> https://github.com/tknopp/
>>> Julietta.jl
>>>
>>
>>

>>>
>>


[julia-users] Re: PyCall crash after running Pkg.update()

2015-09-21 Thread Steven G. Johnson
I haven't seen that before.  The latest PyCall works fine (its tests are 
passing) on the Travis Ubuntu machines and on my Debian box, both with 
Python 2.7 and Python 3.x.

On Monday, September 21, 2015 at 12:10:23 PM UTC-4, james...@gmail.com 
wrote:
>
> Hi All:
>
> I run Pkg.update() in Julia v0.3.11 (under Xubuntu 14.04/x64).  
>
> When the update got to PyCall, the return was
>
>
> INFO: PyCall is using python (Python 2.7.10) at 
> /home/jim_nason/anaconda/bin/python, libpython = 
> /home/jim_nason/anaconda/lib/libpython2.7.so
>
>
> Yes, I recently updated conda and anaconda.
>
> Next, at the Julia command line, the command
>
> using PyCall
>
> returned 
>
> signal (11): Segmentation fault
> unknown function (ip: 877497914)
> unknown function (ip: 877498019)
> jl_get_binding at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> jl_get_global at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> jl_module_run_initializer at 
> /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
> unknown function (ip: 877387427)
> unknown function (ip: 877386277)
> unknown function (ip: 877388029)
> jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown 
> line)
> include at ./boot.jl:245
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> include_from_node1 at ./loading.jl:128
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877321624)
> unknown function (ip: 877317760)
> unknown function (ip: 877385322)
> jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> reload_path at loading.jl:152
> _require at loading.jl:67
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> require at loading.jl:54
> jlcall_require_20813 at  (unknown line)
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877381117)
> unknown function (ip: 877386083)
> unknown function (ip: 877323877)
> unknown function (ip: 877386366)
> unknown function (ip: 877388029)
> jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown 
> line)
> include at ./boot.jl:245
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> include_from_node1 at ./loading.jl:128
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877321624)
> unknown function (ip: 877317760)
> unknown function (ip: 877385322)
> unknown function (ip: 877388029)
> jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown 
> line)
> include at ./boot.jl:245
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> include_from_node1 at ./loading.jl:128
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877321624)
> unknown function (ip: 877317760)
> unknown function (ip: 877385322)
> unknown function (ip: 877387086)
> unknown function (ip: 877386277)
> unknown function (ip: 877388029)
> jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown 
> line)
> include at ./boot.jl:245
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> include_from_node1 at ./loading.jl:128
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877321624)
> unknown function (ip: 877317760)
> unknown function (ip: 877385322)
> jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> reload_path at loading.jl:152
> _require at loading.jl:67
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> require at loading.jl:51
> jlcall_require_20813 at  (unknown line)
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 877381117)
> unknown function (ip: 877385955)
> jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> eval_user_input at REPL.jl:53
> jlcall_eval_user_input_20210 at  (unknown line)
> jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> anonymous at task.jl:95
> jl_handle_stack_switch at 
> /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
> julia_trampoline at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
> (unknown line)
> unknown function (ip: 4199613)
> __libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
> unknown function (ip: 4199667)
> unknown function (ip: 0)
> Segmentation fault (core dumped)
>
> My guess is I did something wrong, but have no idea what I did or how to 
> fix the problem.
>
> Advice/help is appreciated.
>
> Best,
>
> Jim
>
>

[julia-users] PyCall crash after running Pkg.update()

2015-09-21 Thread jamesmnason
Hi All:

I run Pkg.update() in Julia v0.3.11 (under Xubuntu 14.04/x64).  

When the update got to PyCall, the return was


INFO: PyCall is using python (Python 2.7.10) at 
/home/jim_nason/anaconda/bin/python, libpython = 
/home/jim_nason/anaconda/lib/libpython2.7.so


Yes, I recently updated conda and anaconda.

Next, at the Julia command line, the command

using PyCall

returned 

signal (11): Segmentation fault
unknown function (ip: 877497914)
unknown function (ip: 877498019)
jl_get_binding at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
jl_get_global at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
jl_module_run_initializer at 
/usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
unknown function (ip: 877387427)
unknown function (ip: 877386277)
unknown function (ip: 877388029)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include at ./boot.jl:245
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
include_from_node1 at ./loading.jl:128
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877321624)
unknown function (ip: 877317760)
unknown function (ip: 877385322)
jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
reload_path at loading.jl:152
_require at loading.jl:67
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
require at loading.jl:54
jlcall_require_20813 at  (unknown line)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877381117)
unknown function (ip: 877386083)
unknown function (ip: 877323877)
unknown function (ip: 877386366)
unknown function (ip: 877388029)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include at ./boot.jl:245
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
include_from_node1 at ./loading.jl:128
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877321624)
unknown function (ip: 877317760)
unknown function (ip: 877385322)
unknown function (ip: 877388029)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include at ./boot.jl:245
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
include_from_node1 at ./loading.jl:128
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877321624)
unknown function (ip: 877317760)
unknown function (ip: 877385322)
unknown function (ip: 877387086)
unknown function (ip: 877386277)
unknown function (ip: 877388029)
jl_load at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
include at ./boot.jl:245
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
include_from_node1 at ./loading.jl:128
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877321624)
unknown function (ip: 877317760)
unknown function (ip: 877385322)
jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
reload_path at loading.jl:152
_require at loading.jl:67
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
require at loading.jl:51
jlcall_require_20813 at  (unknown line)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 877381117)
unknown function (ip: 877385955)
jl_f_top_eval at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
eval_user_input at REPL.jl:53
jlcall_eval_user_input_20210 at  (unknown line)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
anonymous at task.jl:95
jl_handle_stack_switch at 
/usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown line)
julia_trampoline at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so 
(unknown line)
unknown function (ip: 4199613)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 4199667)
unknown function (ip: 0)
Segmentation fault (core dumped)

My guess is I did something wrong, but have no idea what I did or how to 
fix the problem.

Advice/help is appreciated.

Best,

Jim



[julia-users] Re: Boolean operations on arrays?

2015-09-21 Thread Seth
Note that the broadcasting works for sparse matrices only on recent builds.

On Monday, September 21, 2015 at 6:28:46 AM UTC-7, Matt Bauman wrote:
>
> The bitwise operations (&, |) broadcast over arrays and work just fine for 
> this.  Watch out for their precedence, though: you need to wrap them in 
> parentheses if you want to combine them with the result of comparisons `(A 
> == 1) | (A == 2)`.
>
> On Monday, September 21, 2015 at 8:41:29 AM UTC-4, Daniel Carrera wrote:
>>
>> It looks like I can get the right effect using component-wise 
>> multiplication:
>>
>> julia> ![true, true, false] .* [false, true, true]
>> 3-element Array{Bool,1}:
>>  false
>>  false
>>   true
>>
>>
>> Is this the correct solution or is this an ugly hack?
>>
>> Cheers,
>> Daniel.
>>
>>
>>
>> On 21 September 2015 at 14:35, Daniel Carrera  wrote:
>>
>>> Hello,
>>>
>>> I have two boolean arrays and I am trying to obtain the boolean array 
>>> resulting from a component-wise `AND`:
>>>
>>> julia> [true, true, false] .&& [false, true, true]
>>> ERROR: syntax: invalid identifier name "&&"
>>>
>>> julia> [true, true, false] .& [false, true, true]
>>> ERROR: type Array has no field &
>>>
>>>
>>> Can anyone figure out what I'm doing wrong? I was hoping that `.&` and 
>>> `.&&` would apply the operation on a per-component basis. Help?
>>>
>>> Cheers,
>>> Daniel.
>>>
>>
>>

Re: [julia-users] Is UInt for storing binary strings or unsigned integers?

2015-09-21 Thread Stefan Karpinski
Suppose you have a situation where any UInt value is valid. Since only
valid values can be represented, this implies that you cannot validate
inputs at all – it's impossible to represent any invalid values. So you're
definitely not doing anything useful to catch or report errors.

Suppose that non-negativity isn't the only criterion for validity. E.g.
array indices: only integral values from 1 to length(v) are valid. That
means you need to check bounds anyway, which means the UInt type doesn't
help at all since you still need to check that the UInt value is ≥ 1 and ≤
length(v). In fact, using UInt mostly means that you can't easily tell if
you tried to use a value that is too large or too small – arithmetic
wrap-around means you'll almost always get values that are too large.

Using unsigned integers for error checking is a bogus argument. They hide
errors rather than helping surface or debug them. If you index into an
array and you give an invalid index, you'll get a bounds error. Any type
you build on top of arrays will inherit this checking. If there are
additional constraints that your APIs have on valid inputs, they should
check them.

On Mon, Sep 21, 2015 at 8:05 AM, Milan Bouchet-Valat 
wrote:

> Le dimanche 20 septembre 2015 à 17:07 -0400, Jesse Johnson a écrit :
> > In a thread about printing UInt variables, Milan Bouchet-Valat said:
> > > The point is, in Julia using unsigned ints to store values that
> > > should
> > > always be positive is *not* recommended.
> > If that is true, then shouldn't the type be called Byte? It seems the
> > type has been misnamed if it was never intended to store unsigned
> > integers.
> >
> > Further, calling the type UInt is misleading to devs from C lang
> > family
> > who frequently depend on compile-time type checking (ex. int vs.
> > uint)
> > to help ensure no unexpected signs show up. I am not suggesting
> > type-checking is a perfect defense against sign errors, and thorough
> > runtime testing is definitely necessary. In my larger projects
> > combining
> > type checking and runtime tests is almost a practical necessity and
> > can
> > seriously cut down on time spent bug hunting sign errors.
> >
> > That said, I am guessing the suggested solution in Julia is to rely
> > solely on runtime sign checking? I can't see how I could make that
> > practical for my use cases, but it would be good to know if that is
> > what the Julia devs intend.
> I think so. One of the references I could find is this:
> https://groups.google.com/d/msg/julia-users/RX8sFQHvEV4/ttxfYufL7WUJ
>
>
> Regards
>


Re: [julia-users] Re: printing UInt displays hex instead of decimal

2015-09-21 Thread Stefan Karpinski
Not really, since the argument seems to be that unsigned integer types
should be used widely for indexes and offsets into arrays, rather than just
for bit patterns.

The argument against using unsigned integers for anything arithmetic,
including indexes and sizes is the following. If all your code is perfect,
sure, you will always get a valid positive index, so unsigned integers
should be fine. It's not uncommon, however, to make arithmetic errors, such
as computing `a - b` when you meant to computing `b - a`. With signed
integers, when you make such an error, you can tell if you erred on the
side of computing something too small or too large. It's a small but useful
bit of information. Moreover, there are cases where unsigned integers don't
allow you to catch such errors at all, while mistakes are obvious with
signed integers: e.g. negative timeouts vs very large positive timeouts;
similarly for stream offsets or indexes into sufficiently large arrays.

So Julia's philosophy for whether to use signed or unsigned integers is
this:

   - For arithmetic, including indexes and sizes, you should use signed
   integer types of sufficient size – usually your system's Int type. For
   arithmetic, numeric value is what's important, so all signed integers are
   printed in decimal and storage size is not indicated. When you enter a
   decimal integer literal, you get a signed value of sufficiently large
   signed integer type.
   - If you are working with bit patterns rather than arithmetic values,
   use unsigned integers. Since the number of bits is important here, unsigned
   integers are printed in hex. Likewise, when you enter a hex integer
   literal, you get an unsigned integer value of size indicated by the number
   of digits used.


On Sun, Sep 20, 2015 at 5:04 PM, Jesse Johnson 
wrote:

>
>
> On 09/20/2015 04:11 PM, Milan Bouchet-Valat wrote:
> >
> > The point is, in Julia using unsigned ints to store values that should
> > always be positive is *not* recommended.
>
> This is starting to get off my main topic of consistently printing
> numerical types and allowing the user to change the default print
> formats, but you bring up an interesting point I'd like to discuss in a
> separate thread.
>


Re: [julia-users] Re: Check if type "contains" Any

2015-09-21 Thread Tomas Lycken


I use this to check wether the functions in my module have a bad return 
type causing type inference problems.

That’s precisely what I suspected - for that, it is definitely isleaftype 
you want, rather than rolling your own. (The performance problems that 
Any-typed 
instances have, are intrinsic with anything that’s inferred to a 
non-leaftype, as Yichao mentioned.)

Do note that on 0.4 you can use @code_warntype to find that type of 
problems easily, i.e. if you are already running 0.4 (or if you can switch 
to the RC, or wait up to a couple of weeks), there’s no reason at all to 
roll your own tool for this.

// T

On Monday, September 21, 2015 at 2:38:01 PM UTC+2, Yichao Yu wrote:

On Mon, Sep 21, 2015 at 8:09 AM, Tommy Hofmann  > wrote: 
> > @Tomas: I also want contains_any(Array{Any, 2}) == 
> > contains_any(Union{Integer, Any}) == true. I tried isleaftype before but 
> > isleaftype(Integer) == isleaftype(Any) == false, i.e. I cannot 
> distinguish 
> > between abstract types and Any. 
> > 
> > @Mauro: Thanks for the T.parameters hint. This looks like the right 
> tool. 
> > 
> > I use this to check wether the functions in my module have a bad return 
> type 
> > causing type inference problems. Thus it does not have to be the fastest 
> > solution (of course I appreciate faster and more elegant solutions). 
>
> Any non-leaf type can be a type inference problem. 
>
> > 
> > Thanks for your help, 
> > Tommy 
>
​


[julia-users] Re: Help using Requests.jl

2015-09-21 Thread Chris
An update: 

I realize now that I need to use the ajaxauth/login address for logging in, 
and I can't get this to work:

post("https://www.space-track.org/ajaxauth/login 

",data="identity=username&password=password")
Response(401 Unauthorized, 11 Headers, 69 Bytes in Body)

I tried this with the Python requests package, and it worked as expected:

cred = {'identity':'username' , 'password':'password'}
r = requests.post("https://www.space-track.org/ajaxauth/login",data = cred)
(Response 200)

the body of the request is the same (except that password comes before 
username). 

Is it likely that this is a Requests.jl bug, or is it more likely this is a 
server-side issue?


On Saturday, September 19, 2015 at 7:53:05 PM UTC-4, Chris wrote:
>
> I have not been able to find much in the way of examples for Requests.jl 
> beyond what's in the README. My issue is with this site: 
> https://www.space-track.org/documentation#/howto. I can use post("
> https://www.space-track.org/auth/login",data="identity=username&password=password";),
>  
> and this seemingly works (I get "Response(200 OK, 10 headers, 10676 bytes 
> in body)").
>
> When I try to run a query with get(...), however, I get "Response(401 
> Unauthorized, 10 headers, 94 bytes in body)". I've tried different things, 
> including get("") and get(""; cookies = 
> resp.cookies), where resp is the output of the previous post() command. 
> What do I need to do here?
>
> Thanks,
> Chris
>


Re: [julia-users] Re: When does colon indexing get evaluated / converted?

2015-09-21 Thread Tim Holy
In julia 0.5 I plan to add eachindex(A, d) which can return the appropriate 
range for your object along axis d.

--Tim

On Monday, September 21, 2015 06:20:02 AM Matt Bauman wrote:
> Here's a quick rundown on the status quo:
> 
> * Colon lowering changed in 0.4, as did the AbstractArray's interface.
>  It's *much* easier to make your own arrays in 0.4.  I suggest updating to
> the latest RC.
> 
> * There is still a very strong assumption in base Julia that the valid
> indices in an AbstractArray `A` for dimension `d` are in `1:size(A, d)`.
> * This means that once a base method has ensured that all the indices it
> visits are within `1:size(A,d)`, it might wrap its algorithm with
> `@inbounds`.
> * This means that if you break that assumption, using a base function could
> result in the wrong answer and/or memory corruption and/or segfaults.
> * It also means that the `end` keyword won't lower correctly for your array
> 
> Now, it is possible to break this assumption and still have things work,
> but for right now, it's undocumented magic.  There's several of us very
> interested in doing this, so it'll get better.  Also new in 0.4 is the
> eachindex method, which helps here, too.  The key is to aggressively check
> bounds and explicitly error on any indexing method that you know might be
> ambiguous in its meaning (e.g., does the caller know that your array has
> funny indexing semantics or not?).
> 
> Related
> discussion:
> https://groups.google.com/forum/#!searchin/julia-users/offsetarray%7Csort:d
> ate/julia-users/fNisYpMdZ6o/tahp5AXaAwAJ
> On Sunday, September 20, 2015 at 9:34:24 PM UTC-4, Greg Plowman wrote:
> > Hi,
> > 
> > I'm trying to define a custom Array type that can be indexed using
> > arbitrary ranges.
> > 
> > e.g. A = MyArray(Int, 3:8) would define a 6-element vector with indexes
> > ranging from 3 to 8, rather than the default 1 to 6.
> > 
> > I've made some progress, but am now stuck on how to handle colon indexing.
> > 
> > A[4:6] works by defining appropriate getindex and setindex!
> > 
> > e.g.  setindex!{T,S<:Real}(A::MyArray{T,1}, value, I::AbstractVector{S})
> > = ...
> > 
> > but A[:] = 0 seems to get translated to A[1:6] before dispatch on
> > setindex!, so I can't hijack the call.
> > 
> > From subarray.jl, the code below suggests I can specialise on the Colon
> > type, but this doesn't seem to work for me. Colon appears to be converted
> > to UnitRange *before* calling setindex!
> > 
> > sub(A::AbstractArray, I::Union(RangeIndex, Colon)...) = sub(A, ntuple(
> > length(I), i-> isa(I[i], Colon) ? (1:size(A,i)) : I[i])...)
> > 
> > 
> > Is there a way around this?
> > Should I be able to specialise on the colon argument?
> > 
> > -- Greg



Re: [julia-users] Re: Can Julia function be serialized and sent by network?

2015-09-21 Thread Andrei
Hi,

not yet. I made some initial research regarding serialization of ASTs and
reconstructing functions from them, but it seems quite a tricky procedure
and I have very little time for this project now. I plan to come back to
this issue around the beginning of the next month.

On Mon, Sep 21, 2015 at 11:25 AM, edward zhang  wrote:

> hi, dear,
>  have you already fixed this problem?
>
>
> 在 2015年8月14日星期五 UTC+8下午11:06:30,Andrei Zh写道:
>
>>
>> Hi Jake,
>>
>> your example works because you don't leave Julia session. `foo` is
>> defined in this session, so the the pair of module name and function name
>> is enough to get function object. If you save serialized function (or just
>> retype it byte by byte) , it won't work. Here's an example:
>>
>> Session #1:
>>
>> julia> io = IOBuffer()
>> IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true,
>> append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
>>
>>
>> julia> foo(x) =  x + 1
>> foo (generic function with 1 method)
>>
>>
>> julia> serialize(io, foo)
>>
>>
>> julia> takebuf_array(io)
>> 9-element Array{Uint8,1}:
>>  0x13
>>  0x02
>>  0x23
>>  0x2f
>>  0x02
>>  0x03
>>  0x66
>>  0x6f
>>  0x6f
>>
>>
>> julia>
>>
>>
>>
>> Session #2:
>>
>> julia> data = Uint8[0x13, 0x02, 0x23, 0x2f, 0x02, 0x03, 0x66, 0x6f, 0x6f]
>> 9-element Array{Uint8,1}:
>>  0x13
>>  0x02
>>  0x23
>>  0x2f
>>  0x02
>>  0x03
>>  0x66
>>  0x6f
>>  0x6f
>>
>>
>> julia> io = IOBuffer(data)
>> IOBuffer(data=Uint8[...], readable=true, writable=false, seekable=true,
>> append=false, size=9, maxsize=Inf, ptr=1, mark=-1)
>>
>>
>> julia> bar = deserialize(io)
>> (anonymous function)
>>
>>
>> julia> bar(1)
>> ERROR: function foo not defined on process 1
>>  in error at error.jl:21
>>  in anonymous at serialize.jl:398
>>
>>
>> julia>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Friday, August 14, 2015 at 5:49:55 PM UTC+3, Jake Bolewski wrote:
>>>
>>> Andrei Zh
>>>
>>> I'm confused.  Have you actually tried?
>>>
>>> julia> io = IOBuffer()
>>> IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true,
>>> append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
>>>
>>> julia> foo(x) =  x + 1
>>> foo (generic function with 1 method)
>>>
>>> julia> serialize(io, foo)
>>>
>>> julia> seekstart(io)
>>> IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true,
>>> append=false, size=9, maxsize=Inf, ptr=1, mark=-1)
>>>
>>> julia> baz = deserialize(io)
>>> foo (generic function with 1 method)
>>>
>>> julia> baz(1)
>>> 2
>>>
>>> The serialization code won't recursively serialize all the of the
>>> functions dependencies so you will have to send/serialize the code that
>>> defines the environment (types, constants, Packages, etc).
>>>
>>


[julia-users] Re: Boolean operations on arrays?

2015-09-21 Thread Matt Bauman
The bitwise operations (&, |) broadcast over arrays and work just fine for 
this.  Watch out for their precedence, though: you need to wrap them in 
parentheses if you want to combine them with the result of comparisons `(A 
== 1) | (A == 2)`.

On Monday, September 21, 2015 at 8:41:29 AM UTC-4, Daniel Carrera wrote:
>
> It looks like I can get the right effect using component-wise 
> multiplication:
>
> julia> ![true, true, false] .* [false, true, true]
> 3-element Array{Bool,1}:
>  false
>  false
>   true
>
>
> Is this the correct solution or is this an ugly hack?
>
> Cheers,
> Daniel.
>
>
>
> On 21 September 2015 at 14:35, Daniel Carrera  > wrote:
>
>> Hello,
>>
>> I have two boolean arrays and I am trying to obtain the boolean array 
>> resulting from a component-wise `AND`:
>>
>> julia> [true, true, false] .&& [false, true, true]
>> ERROR: syntax: invalid identifier name "&&"
>>
>> julia> [true, true, false] .& [false, true, true]
>> ERROR: type Array has no field &
>>
>>
>> Can anyone figure out what I'm doing wrong? I was hoping that `.&` and 
>> `.&&` would apply the operation on a per-component basis. Help?
>>
>> Cheers,
>> Daniel.
>>
>
>

[julia-users] Re: When does colon indexing get evaluated / converted?

2015-09-21 Thread Matt Bauman
Here's a quick rundown on the status quo:

* Colon lowering changed in 0.4, as did the AbstractArray's interface. 
 It's *much* easier to make your own arrays in 0.4.  I suggest updating to 
the latest RC.

* There is still a very strong assumption in base Julia that the valid 
indices in an AbstractArray `A` for dimension `d` are in `1:size(A, d)`.
* This means that once a base method has ensured that all the indices it 
visits are within `1:size(A,d)`, it might wrap its algorithm with 
`@inbounds`.
* This means that if you break that assumption, using a base function could 
result in the wrong answer and/or memory corruption and/or segfaults.
* It also means that the `end` keyword won't lower correctly for your array

Now, it is possible to break this assumption and still have things work, 
but for right now, it's undocumented magic.  There's several of us very 
interested in doing this, so it'll get better.  Also new in 0.4 is the 
eachindex method, which helps here, too.  The key is to aggressively check 
bounds and explicitly error on any indexing method that you know might be 
ambiguous in its meaning (e.g., does the caller know that your array has 
funny indexing semantics or not?).

Related 
discussion: 
https://groups.google.com/forum/#!searchin/julia-users/offsetarray%7Csort:date/julia-users/fNisYpMdZ6o/tahp5AXaAwAJ

On Sunday, September 20, 2015 at 9:34:24 PM UTC-4, Greg Plowman wrote:
>
> Hi,
>
> I'm trying to define a custom Array type that can be indexed using 
> arbitrary ranges.
>
> e.g. A = MyArray(Int, 3:8) would define a 6-element vector with indexes 
> ranging from 3 to 8, rather than the default 1 to 6.
>
> I've made some progress, but am now stuck on how to handle colon indexing.
>
> A[4:6] works by defining appropriate getindex and setindex!
>
> e.g.  setindex!{T,S<:Real}(A::MyArray{T,1}, value, I::AbstractVector{S}) 
> = ...
>
> but A[:] = 0 seems to get translated to A[1:6] before dispatch on 
> setindex!, so I can't hijack the call.
>
> From subarray.jl, the code below suggests I can specialise on the Colon 
> type, but this doesn't seem to work for me. Colon appears to be converted 
> to UnitRange *before* calling setindex!
>
> sub(A::AbstractArray, I::Union(RangeIndex, Colon)...) = sub(A, ntuple(
> length(I), i-> isa(I[i], Colon) ? (1:size(A,i)) : I[i])...)
>
>
> Is there a way around this?
> Should I be able to specialise on the colon argument?
>
> -- Greg
>


Re: [julia-users] type of single values AND array?

2015-09-21 Thread Jon Norberg
Many thanks! works

Re: [julia-users] type of single values AND array?

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 9:06 AM, Jon Norberg  wrote:
> type x
>   value::Union{Array{Float64},Float64}
> end

Replace Union{} with Union() on 0.3 (or use Compat)

>
> gives me error:
>
> type: instantiate_type: expected TypeConstructor, got function
>


Re: [julia-users] type of single values AND array?

2015-09-21 Thread Jon Norberg
type x
  value::Union{Array{Float64},Float64}
end

gives me error:

type: instantiate_type: expected TypeConstructor, got function



Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Uwe Fechner
Did anyone ask Forio if they would change the license (as they are 
obviously not longer
interested in the project)?

Uwe

Am Montag, 21. September 2015 13:52:57 UTC+2 schrieb Christof Stocker:
>
> I did consider looking into that but as soon as I saw the license I ran 
> for my life. Its a similar issue with Julietta. Although what is an issue 
> to me doesn't have to be an issue to others
>
> On 2015-09-21 13:48, Steven Sagaert wrote:
>
> +1  
> & to add to Uwe's post: AFAIK JuliaStudio is based on Qt (& QtCreator I 
> believe). I thought that JuliaStudio was a nice start (also based on 
> QtCreator). I wish a group would fork it and develop it further in the 
> direction of RStudio.
>
> On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof Stocker 
> wrote: 
>>
>> I would be a huge fan of an RStudio like Julia IDE
>>
>> On 2015-09-18 10:05, Uwe Fechner wrote:
>>
>> I like QT a lot. There is more then one open source, QT based IDE out 
>> there, e.g. QT Creator.
>> QT has a GUI builder, that is much better then the GUI builders for GTK 
>> (in my opinion).
>> And you can use the java-script like QML language for building the user 
>> interface, if you want to.
>>
>> Tutorial for PyQT:
>> https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/
>>
>> As soon as the Julia/C++ integration is available by default (hopefully 
>> in Julia 0.5), QT integration
>> should be easy. For those, that want to play with Julia and QT now 
>> already, have a look at:
>>
>> https://github.com/jverzani/PySide.jl
>>
>> (very experimental)
>>
>> Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel Carrera: 
>>>
>>> There are no Qt bindings for Julia yet. I also don't know what text 
>>> editing component is provided by Qt or what its features are. I began 
>>> working with Gtk in part because the Julia Gtk bindings seem to be the most 
>>> developed. 
>>>
>>> Is there a reason you like Qt besides it being cross-platform?
>>>
>>>
>>> On 17 September 2015 at 23:50, SrAceves  wrote:
>>>
 What about Qt? RStudio is fantastic: Qt based, multi-platoform. 
 Everything anyone ever wanted of an IDE.

 El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5), Daniel Carrera 
 escribió: 
>
>
> Last night I started experimenting with Gtk, and started making a 
> sketch of what a Julia IDE might look like. In the process I am writing 
> down a list of things that are probably needed before a Julia IDE
>
>
>  getting a list of things that probably need to exist before a Julia 
> IDE can be completed. This is what I have so far:
> 1) A Julia package for the GNOME Docking Library
>
> I think most people expect that an IDE has docking 
>
> Despite the name, it does not depend on any GNOME libraries, only Gtk. 
> This is what Anjuta and MonoDevelop use to get docking windows. I think 
> most people expect to be able to move things around in an IDE.
>
> https://developer.gnome.org/gdl/
>
>
> 2)
>
>
>
> On 14 September 2015 at 17:10,  wrote:
>
>> Gtk, the code isn't published but it's very similar to Julietta: 
>>
>> https://github.com/tknopp/
>> Julietta.jl
>>
>
>
>>>
>>
>

Re: [julia-users] type of single values AND array?

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 8:55 AM, Jon Norberg  wrote:
> not sure what leaf type is?
>
> I actually need more fields in the type so I do need it as some field
>
> type x
> value::Array{Float64}
>otherfield...
> end

What I meant is that if you don't need `.value` to be type stable,
just `::Union{Array{Float64},Float64}` would do what you want.


Re: [julia-users] type of single values AND array?

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 8:53 AM, Jon Norberg  wrote:
> leaftype?

http://julia.readthedocs.org/en/latest/stdlib/base/?highlight=leaftype#Base.isleaftype

http://julia.readthedocs.org/en/latest/manual/performance-tips/#code-warntype

>
> On Monday, September 21, 2015 at 2:41:02 PM UTC+2, Yichao Yu wrote:
>>
>> On Mon, Sep 21, 2015 at 8:37 AM, Jon Norberg 
>> wrote:
>> > quick question: How do I define a type most effective so that I can give
>> > it both single values, vectors and Arrays as variables?
>> >
>> > I now have:
>> >
>> > type x
>> > value::Array{Float64}
>> > end
>> >
>> > I can do x(rand(3)) as well as x(rand(3,3)) but not x(0.1)
>>
>> Depends on what you need. If you don't need the field to be a leaftype
>> (as in your code above), Union should work fine.
>>
>> >
>> > the answer is probably in the forums but I couldn't construct a good
>> > search to find it :-/
>> >
>> > Thanks


Re: [julia-users] type of single values AND array?

2015-09-21 Thread Jon Norberg
not sure what leaf type is?

I actually need more fields in the type so I do need it as some field

type x
value::Array{Float64}
   otherfield...
end


Re: [julia-users] Re: Can Julia function be serialized and sent by network?

2015-09-21 Thread edward zhang
hi, dear, 
 have you already fixed this problem?


在 2015年8月14日星期五 UTC+8下午11:06:30,Andrei Zh写道:
>
>
> Hi Jake, 
>
> your example works because you don't leave Julia session. `foo` is defined 
> in this session, so the the pair of module name and function name is enough 
> to get function object. If you save serialized function (or just retype it 
> byte by byte) , it won't work. Here's an example: 
>
> Session #1: 
>
> julia> io = IOBuffer()
> IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, 
> append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
>
>
> julia> foo(x) =  x + 1
> foo (generic function with 1 method)
>
>
> julia> serialize(io, foo)
>
>
> julia> takebuf_array(io)
> 9-element Array{Uint8,1}:
>  0x13
>  0x02
>  0x23
>  0x2f
>  0x02
>  0x03
>  0x66
>  0x6f
>  0x6f
>
>
> julia>
>
>
>
> Session #2: 
>
> julia> data = Uint8[0x13, 0x02, 0x23, 0x2f, 0x02, 0x03, 0x66, 0x6f, 0x6f]
> 9-element Array{Uint8,1}:
>  0x13
>  0x02
>  0x23
>  0x2f
>  0x02
>  0x03
>  0x66
>  0x6f
>  0x6f
>
>
> julia> io = IOBuffer(data)
> IOBuffer(data=Uint8[...], readable=true, writable=false, seekable=true, 
> append=false, size=9, maxsize=Inf, ptr=1, mark=-1)
>
>
> julia> bar = deserialize(io)
> (anonymous function)
>
>
> julia> bar(1)
> ERROR: function foo not defined on process 1
>  in error at error.jl:21
>  in anonymous at serialize.jl:398
>
>
> julia>
>
>  
>
>
>
>
>
>
> On Friday, August 14, 2015 at 5:49:55 PM UTC+3, Jake Bolewski wrote:
>>
>> Andrei Zh
>>
>> I'm confused.  Have you actually tried?  
>>
>> julia> io = IOBuffer()
>> IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, 
>> append=false, size=0, maxsize=Inf, ptr=1, mark=-1)
>>
>> julia> foo(x) =  x + 1
>> foo (generic function with 1 method)
>>
>> julia> serialize(io, foo)
>>
>> julia> seekstart(io)
>> IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, 
>> append=false, size=9, maxsize=Inf, ptr=1, mark=-1)
>>
>> julia> baz = deserialize(io)
>> foo (generic function with 1 method)
>>
>> julia> baz(1)
>> 2
>>
>> The serialization code won't recursively serialize all the of the 
>> functions dependencies so you will have to send/serialize the code that 
>> defines the environment (types, constants, Packages, etc).
>>
>

Re: [julia-users] type of single values AND array?

2015-09-21 Thread Jon Norberg
leaftype?

On Monday, September 21, 2015 at 2:41:02 PM UTC+2, Yichao Yu wrote:
>
> On Mon, Sep 21, 2015 at 8:37 AM, Jon Norberg  > wrote: 
> > quick question: How do I define a type most effective so that I can give 
> it both single values, vectors and Arrays as variables? 
> > 
> > I now have: 
> > 
> > type x 
> > value::Array{Float64} 
> > end 
> > 
> > I can do x(rand(3)) as well as x(rand(3,3)) but not x(0.1) 
>
> Depends on what you need. If you don't need the field to be a leaftype 
> (as in your code above), Union should work fine. 
>
> > 
> > the answer is probably in the forums but I couldn't construct a good 
> search to find it :-/ 
> > 
> > Thanks 
>


[julia-users] Re: Boolean operations on arrays?

2015-09-21 Thread Daniel Carrera
It looks like I can get the right effect using component-wise
multiplication:

julia> ![true, true, false] .* [false, true, true]
3-element Array{Bool,1}:
 false
 false
  true


Is this the correct solution or is this an ugly hack?

Cheers,
Daniel.



On 21 September 2015 at 14:35, Daniel Carrera  wrote:

> Hello,
>
> I have two boolean arrays and I am trying to obtain the boolean array
> resulting from a component-wise `AND`:
>
> julia> [true, true, false] .&& [false, true, true]
> ERROR: syntax: invalid identifier name "&&"
>
> julia> [true, true, false] .& [false, true, true]
> ERROR: type Array has no field &
>
>
> Can anyone figure out what I'm doing wrong? I was hoping that `.&` and
> `.&&` would apply the operation on a per-component basis. Help?
>
> Cheers,
> Daniel.
>


Re: [julia-users] type of single values AND array?

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 8:37 AM, Jon Norberg  wrote:
> quick question: How do I define a type most effective so that I can give it 
> both single values, vectors and Arrays as variables?
>
> I now have:
>
> type x
> value::Array{Float64}
> end
>
> I can do x(rand(3)) as well as x(rand(3,3)) but not x(0.1)

Depends on what you need. If you don't need the field to be a leaftype
(as in your code above), Union should work fine.

>
> the answer is probably in the forums but I couldn't construct a good search 
> to find it :-/
>
> Thanks


Re: [julia-users] Boolean operations on arrays?

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 8:35 AM, Daniel Carrera  wrote:
> Hello,
>
> I have two boolean arrays and I am trying to obtain the boolean array
> resulting from a component-wise `AND`:
>
> julia> [true, true, false] .&& [false, true, true]
> ERROR: syntax: invalid identifier name "&&"
>
> julia> [true, true, false] .& [false, true, true]
> ERROR: type Array has no field &
>
>
> Can anyone figure out what I'm doing wrong? I was hoping that `.&` and `.&&`
> would apply the operation on a per-component basis. Help?

julia> [true, true, false] & [false, true, true]
3-element Array{Bool,1}:
false
 true
false



>
> Cheers,
> Daniel.


[julia-users] type of single values AND array?

2015-09-21 Thread Jon Norberg
quick question: How do I define a type most effective so that I can give it 
both single values, vectors and Arrays as variables?

I now have:

type x
value::Array{Float64}
end

I can do x(rand(3)) as well as x(rand(3,3)) but not x(0.1)

the answer is probably in the forums but I couldn't construct a good search to 
find it :-/

Thanks

Re: [julia-users] Re: Check if type "contains" Any

2015-09-21 Thread Yichao Yu
On Mon, Sep 21, 2015 at 8:09 AM, Tommy Hofmann  wrote:
> @Tomas: I also want contains_any(Array{Any, 2}) ==
> contains_any(Union{Integer, Any}) == true. I tried isleaftype before but
> isleaftype(Integer) == isleaftype(Any) == false, i.e. I cannot distinguish
> between abstract types and Any.
>
> @Mauro: Thanks for the T.parameters hint. This looks like the right tool.
>
> I use this to check wether the functions in my module have a bad return type
> causing type inference problems. Thus it does not have to be the fastest
> solution (of course I appreciate faster and more elegant solutions).

Any non-leaf type can be a type inference problem.

>
> Thanks for your help,
> Tommy


[julia-users] Boolean operations on arrays?

2015-09-21 Thread Daniel Carrera
Hello,

I have two boolean arrays and I am trying to obtain the boolean array
resulting from a component-wise `AND`:

julia> [true, true, false] .&& [false, true, true]
ERROR: syntax: invalid identifier name "&&"

julia> [true, true, false] .& [false, true, true]
ERROR: type Array has no field &


Can anyone figure out what I'm doing wrong? I was hoping that `.&` and
`.&&` would apply the operation on a per-component basis. Help?

Cheers,
Daniel.


[julia-users] Re: Check if type "contains" Any

2015-09-21 Thread Tommy Hofmann
@Tomas: I also want contains_any(Array{Any, 2}) == 
contains_any(Union{Integer, Any}) == true. I tried isleaftype before but 
isleaftype(Integer) == isleaftype(Any) == false, i.e. I cannot distinguish 
between abstract types and Any.

@Mauro: Thanks for the T.parameters hint. This looks like the right tool.

I use this to check wether the functions in my module have a bad return 
type causing type inference problems. Thus it does not have to be the 
fastest solution (of course I appreciate faster and more elegant solutions).

Thanks for your help,
Tommy


Re: [julia-users] Is UInt for storing binary strings or unsigned integers?

2015-09-21 Thread Milan Bouchet-Valat
Le dimanche 20 septembre 2015 à 17:07 -0400, Jesse Johnson a écrit :
> In a thread about printing UInt variables, Milan Bouchet-Valat said:
> > The point is, in Julia using unsigned ints to store values that
> > should
> > always be positive is *not* recommended. 
> If that is true, then shouldn't the type be called Byte? It seems the
> type has been misnamed if it was never intended to store unsigned
> integers.
> 
> Further, calling the type UInt is misleading to devs from C lang
> family
> who frequently depend on compile-time type checking (ex. int vs.
> uint)
> to help ensure no unexpected signs show up. I am not suggesting
> type-checking is a perfect defense against sign errors, and thorough
> runtime testing is definitely necessary. In my larger projects
> combining
> type checking and runtime tests is almost a practical necessity and
> can
> seriously cut down on time spent bug hunting sign errors.
> 
> That said, I am guessing the suggested solution in Julia is to rely
> solely on runtime sign checking? I can't see how I could make that
> practical for my use cases, but it would be good to know if that is 
> what the Julia devs intend.
I think so. One of the references I could find is this:
https://groups.google.com/d/msg/julia-users/RX8sFQHvEV4/ttxfYufL7WUJ


Regards


Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Christof Stocker
I did consider looking into that but as soon as I saw the license I ran 
for my life. Its a similar issue with Julietta. Although what is an 
issue to me doesn't have to be an issue to others


On 2015-09-21 13:48, Steven Sagaert wrote:

+1
& to add to Uwe's post: AFAIK JuliaStudio is based on Qt (& QtCreator 
I believe). I thought that JuliaStudio was a nice start (also based on 
QtCreator). I wish a group would fork it and develop it further in the 
direction of RStudio.


On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof Stocker 
wrote:


I would be a huge fan of an RStudio like Julia IDE

On 2015-09-18 10:05, Uwe Fechner wrote:

I like QT a lot. There is more then one open source, QT based IDE
out there, e.g. QT Creator.
QT has a GUI builder, that is much better then the GUI builders
for GTK (in my opinion).
And you can use the java-script like QML language for building
the user interface, if you want to.

Tutorial for PyQT:
https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/


As soon as the Julia/C++ integration is available by default
(hopefully in Julia 0.5), QT integration
should be easy. For those, that want to play with Julia and QT
now already, have a look at:

https://github.com/jverzani/PySide.jl


(very experimental)

Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel
Carrera:

There are no Qt bindings for Julia yet. I also don't know
what text editing component is provided by Qt or what its
features are. I began working with Gtk in part because the
Julia Gtk bindings seem to be the most developed.

Is there a reason you like Qt besides it being cross-platform?


On 17 September 2015 at 23:50, SrAceves
 wrote:

What about Qt? RStudio is fantastic: Qt based,
multi-platoform. Everything anyone ever wanted of an IDE.

El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5),
Daniel Carrera escribió:


Last night I started experimenting with Gtk, and
started making a sketch of what a Julia IDE might
look like. In the process I am writing down a list of
things that are probably needed before a Julia IDE


 getting a list of things that probably need to exist
before a Julia IDE can be completed. This is what I
have so far:
1) A Julia package for the GNOME Docking Library

I think most people expect that an IDE has docking

Despite the name, it does not depend on any GNOME
libraries, only Gtk. This is what Anjuta and
MonoDevelop use to get docking windows. I think most
people expect to be able to move things around in an IDE.

https://developer.gnome.org/gdl/



2)



On 14 September 2015 at 17:10,
 wrote:

Gtk, the code isn't published but it's very
similar to Julietta:

https://github.com/tknopp/Julietta.jl










Re: [julia-users] Re: IDE for Julia

2015-09-21 Thread Steven Sagaert
+1 
& to add to Uwe's post: AFAIK JuliaStudio is based on Qt (& QtCreator I 
believe). I thought that JuliaStudio was a nice start (also based on 
QtCreator). I wish a group would fork it and develop it further in the 
direction of RStudio.

On Friday, September 18, 2015 at 10:08:23 AM UTC+2, Christof Stocker wrote:
>
> I would be a huge fan of an RStudio like Julia IDE
>
> On 2015-09-18 10:05, Uwe Fechner wrote:
>
> I like QT a lot. There is more then one open source, QT based IDE out 
> there, e.g. QT Creator.
> QT has a GUI builder, that is much better then the GUI builders for GTK 
> (in my opinion).
> And you can use the java-script like QML language for building the user 
> interface, if you want to.
>
> Tutorial for PyQT:
> https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/
>
> As soon as the Julia/C++ integration is available by default (hopefully in 
> Julia 0.5), QT integration
> should be easy. For those, that want to play with Julia and QT now 
> already, have a look at:
>
> https://github.com/jverzani/PySide.jl
>
> (very experimental)
>
> Am Freitag, 18. September 2015 08:25:44 UTC+2 schrieb Daniel Carrera: 
>>
>> There are no Qt bindings for Julia yet. I also don't know what text 
>> editing component is provided by Qt or what its features are. I began 
>> working with Gtk in part because the Julia Gtk bindings seem to be the most 
>> developed. 
>>
>> Is there a reason you like Qt besides it being cross-platform?
>>
>>
>> On 17 September 2015 at 23:50, SrAceves  wrote:
>>
>>> What about Qt? RStudio is fantastic: Qt based, multi-platoform. 
>>> Everything anyone ever wanted of an IDE.
>>>
>>> El martes, 15 de septiembre de 2015, 8:13:04 (UTC-5), Daniel Carrera 
>>> escribió: 


 Last night I started experimenting with Gtk, and started making a 
 sketch of what a Julia IDE might look like. In the process I am writing 
 down a list of things that are probably needed before a Julia IDE


  getting a list of things that probably need to exist before a Julia 
 IDE can be completed. This is what I have so far:
 1) A Julia package for the GNOME Docking Library

 I think most people expect that an IDE has docking 

 Despite the name, it does not depend on any GNOME libraries, only Gtk. 
 This is what Anjuta and MonoDevelop use to get docking windows. I think 
 most people expect to be able to move things around in an IDE.

 https://developer.gnome.org/gdl/


 2)



 On 14 September 2015 at 17:10,  wrote:

> Gtk, the code isn't published but it's very similar to Julietta: 
>
> https://github.com/tknopp/Julietta.jl
>


>>
>

Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford
Thanks - will take look. 

On Monday, 21 September 2015 10:40:45 UTC+1, Mauro wrote:
>
> > Thanks all! I can now see what I was attempting makes no sense with the 
> > array comprehension and why I needed a nested solution. 
>
> If you end up using it like so: 
>
>   vcat([[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]...) 
>
> then have a look at https://github.com/mbauman/RaggedArrays.jl 
>
> > On 21 Sep 2015 10:20, "Michael Hatherly"  > wrote: 
> > 
> >> The indices need to all be independent since otherwise you’d end up 
> >> producing an array with some rows/columns being of different length, 
> which 
> >> isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since 
> for 
> >> i = 1:3, j = 1:i isn’t trying to fill up an array directly though. 
> >> 
> >> — Mike 
> >> ​ 
> >> 
> >> On Monday, 21 September 2015 10:59:31 UTC+2, Alan Crawford wrote: 
> >>> 
> >>> Thanks Mike - precisely what i was after. 
> >>> 
> >>> While this is a perfectly acceptable solution I wondered 
> >>> whether, following Mauro's suggestion, it was worth opening an issue 
> in any 
> >>> case because it seems like it  be nice to be able to link indexes in 
> array 
> >>> comprehensions in a similar way to for-loops. Views? 
> >>> 
> >>> 
> >>> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote: 
>  
>  MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K] 
>  
>  seems to do what you want I think. Using 2 nested 1-d comprehensions 
>  instead of a single 2-d comprehension. 
>  
>  — Mike 
>  ​ 
>  On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote: 
> > 
> > 
> > Thanks Tomas. If I do: 
> > 
> > Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] 
> > 
> > Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 
> vector). 
> > However, the issue for Y[2] and above. For example, if I do Y[2][k] 
> where 
> > k∈[1,binomial(J,2)] 
> > then i get a length 1 vector, whereas I would like length 2 vector. 
> > Similarly for Y[3][k] I would like a length 3 vector. 
> > 
> > 
> > On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote: 
> >> 
> >> Ah. 
> >> 
> >> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is 
> what 
> >> you’re looking for? 
> >> 
> >> // T 
> >> 
> >> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford 
> >> wrote: 
> >> 
> >> The lower case k is intentional. I didn't want such a 'large' array 
> as 
> >>> the one created when I use K because large parts of that array 
> would be 
> >>> redundant. Ideally, I want this array to be as small as possible, 
> >>> especially since J and K might be quite a bit larger than in the 
> example. 
> >>> 
> >>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote: 
>  
>  Are you sure that’s not just a typo between k and K (note the 
> case 
>  difference)? 
>  
>  This works for me: 
>  
>  J=10 
>  K=3 
>  MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)] 
>  
>  // T 
>  
>  On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford 
>  wrote: 
>  
>  Hi, 
> > 
> > I'd like to be able to define an array of vectors where the 
> number 
> > of vectors in the array is linked to the length of the vector. 
> For example, 
> > I want to be define an array with say 10 scalars, 45 length 2 
> vectors, 120 
> > length 3 vectors,  and so on. Intuitively, I thought the 
> following code 
> > might achieve this: 
> > 
> > J=10 
> > K=3 
> > MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)] 
> > 
> > 
> > However, it seems i cannot use k to define the number of element 
> > indexed by n. 
> > 
> > I was wondering if anyone knew how to create the desired array? 
> > 
> > Thanks 
> > Alan 
> > 
>  ​ 
>  
> >>> ​ 
> >> 
> > 
>
>

Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
> Thanks all! I can now see what I was attempting makes no sense with the
> array comprehension and why I needed a nested solution.

If you end up using it like so:

  vcat([[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]...)

then have a look at https://github.com/mbauman/RaggedArrays.jl

> On 21 Sep 2015 10:20, "Michael Hatherly"  wrote:
>
>> The indices need to all be independent since otherwise you’d end up
>> producing an array with some rows/columns being of different length, which
>> isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since for
>> i = 1:3, j = 1:i isn’t trying to fill up an array directly though.
>>
>> — Mike
>> ​
>>
>> On Monday, 21 September 2015 10:59:31 UTC+2, Alan Crawford wrote:
>>>
>>> Thanks Mike - precisely what i was after.
>>>
>>> While this is a perfectly acceptable solution I wondered
>>> whether, following Mauro's suggestion, it was worth opening an issue in any
>>> case because it seems like it  be nice to be able to link indexes in array
>>> comprehensions in a similar way to for-loops. Views?
>>>
>>>
>>> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:

 MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]

 seems to do what you want I think. Using 2 nested 1-d comprehensions
 instead of a single 2-d comprehension.

 — Mike
 ​
 On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:
>
>
> Thanks Tomas. If I do:
>
> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>
> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector).
> However, the issue for Y[2] and above. For example, if I do Y[2][k] where
> k∈[1,binomial(J,2)]
> then i get a length 1 vector, whereas I would like length 2 vector.
> Similarly for Y[3][k] I would like a length 3 vector.
>
>
> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>>
>> Ah.
>>
>> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what
>> you’re looking for?
>>
>> // T
>>
>> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford
>> wrote:
>>
>> The lower case k is intentional. I didn't want such a 'large' array as
>>> the one created when I use K because large parts of that array would be
>>> redundant. Ideally, I want this array to be as small as possible,
>>> especially since J and K might be quite a bit larger than in the 
>>> example.
>>>
>>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:

 Are you sure that’s not just a typo between k and K (note the case
 difference)?

 This works for me:

 J=10
 K=3
 MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]

 // T

 On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford
 wrote:

 Hi,
>
> I'd like to be able to define an array of vectors where the number
> of vectors in the array is linked to the length of the vector. For 
> example,
> I want to be define an array with say 10 scalars, 45 length 2 
> vectors, 120
> length 3 vectors,  and so on. Intuitively, I thought the 
> following code
> might achieve this:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>
>
> However, it seems i cannot use k to define the number of element
> indexed by n.
>
> I was wondering if anyone knew how to create the desired array?
>
> Thanks
> Alan
>
 ​

>>> ​
>>
>



Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
> The indices need to all be independent since otherwise you’d end up 
> producing an array with some rows/columns being of different length, which 
> isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since for i 
> = 1:3, j = 1:i isn’t trying to fill up an array directly though.

That is a good point.  Maybe something to add to the documentation
though...

> — Mike
> ​
>
> On Monday, 21 September 2015 10:59:31 UTC+2, Alan Crawford wrote:
>>
>> Thanks Mike - precisely what i was after. 
>>
>> While this is a perfectly acceptable solution I wondered 
>> whether, following Mauro's suggestion, it was worth opening an issue in any 
>> case because it seems like it  be nice to be able to link indexes in array 
>> comprehensions in a similar way to for-loops. Views? 
>>
>>
>> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:
>>>
>>> MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]
>>>
>>> seems to do what you want I think. Using 2 nested 1-d comprehensions 
>>> instead of a single 2-d comprehension.
>>>
>>> — Mike
>>> ​
>>> On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:


 Thanks Tomas. If I do:

 Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]

 Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
 However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
 k∈[1,binomial(J,2)]
 then i get a length 1 vector, whereas I would like length 2 vector. 
 Similarly for Y[3][k] I would like a length 3 vector.


 On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>
> Ah.
>
> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
> you’re looking for?
>
> // T
>
> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:
>
> The lower case k is intentional. I didn't want such a 'large' array as 
>> the one created when I use K because large parts of that array would be 
>> redundant. Ideally, I want this array to be as small as possible, 
>> especially since J and K might be quite a bit larger than in the example.
>>
>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>>
>>> Are you sure that’s not just a typo between k and K (note the case 
>>> difference)?
>>>
>>> This works for me:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>>
>>> // T
>>>
>>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford 
>>> wrote:
>>>
>>> Hi,

 I'd like to be able to define an array of vectors where the number 
 of vectors in the array is linked to the length of the vector. For 
 example, 
 I want to be define an array with say 10 scalars, 45 length 2 vectors, 
 120 
 length 3 vectors,  and so on. Intuitively, I thought the following 
 code 
 might achieve this:

 J=10
 K=3
 MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]


 However, it seems i cannot use k to define the number of element 
 indexed by n.  

 I was wondering if anyone knew how to create the desired array?

 Thanks
 Alan

>>> ​
>>>
>> ​
>




Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford
Thanks all! I can now see what I was attempting makes no sense with the
array comprehension and why I needed a nested solution.
On 21 Sep 2015 10:20, "Michael Hatherly"  wrote:

> The indices need to all be independent since otherwise you’d end up
> producing an array with some rows/columns being of different length, which
> isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since for
> i = 1:3, j = 1:i isn’t trying to fill up an array directly though.
>
> — Mike
> ​
>
> On Monday, 21 September 2015 10:59:31 UTC+2, Alan Crawford wrote:
>>
>> Thanks Mike - precisely what i was after.
>>
>> While this is a perfectly acceptable solution I wondered
>> whether, following Mauro's suggestion, it was worth opening an issue in any
>> case because it seems like it  be nice to be able to link indexes in array
>> comprehensions in a similar way to for-loops. Views?
>>
>>
>> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:
>>>
>>> MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]
>>>
>>> seems to do what you want I think. Using 2 nested 1-d comprehensions
>>> instead of a single 2-d comprehension.
>>>
>>> — Mike
>>> ​
>>> On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:


 Thanks Tomas. If I do:

 Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]

 Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector).
 However, the issue for Y[2] and above. For example, if I do Y[2][k] where
 k∈[1,binomial(J,2)]
 then i get a length 1 vector, whereas I would like length 2 vector.
 Similarly for Y[3][k] I would like a length 3 vector.


 On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>
> Ah.
>
> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what
> you’re looking for?
>
> // T
>
> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford
> wrote:
>
> The lower case k is intentional. I didn't want such a 'large' array as
>> the one created when I use K because large parts of that array would be
>> redundant. Ideally, I want this array to be as small as possible,
>> especially since J and K might be quite a bit larger than in the example.
>>
>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>>
>>> Are you sure that’s not just a typo between k and K (note the case
>>> difference)?
>>>
>>> This works for me:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>>
>>> // T
>>>
>>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford
>>> wrote:
>>>
>>> Hi,

 I'd like to be able to define an array of vectors where the number
 of vectors in the array is linked to the length of the vector. For 
 example,
 I want to be define an array with say 10 scalars, 45 length 2 vectors, 
 120
 length 3 vectors,  and so on. Intuitively, I thought the following 
 code
 might achieve this:

 J=10
 K=3
 MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]


 However, it seems i cannot use k to define the number of element
 indexed by n.

 I was wondering if anyone knew how to create the desired array?

 Thanks
 Alan

>>> ​
>>>
>> ​
>



[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Michael Hatherly


The indices need to all be independent since otherwise you’d end up 
producing an array with some rows/columns being of different length, which 
isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since for i 
= 1:3, j = 1:i isn’t trying to fill up an array directly though.

— Mike
​

On Monday, 21 September 2015 10:59:31 UTC+2, Alan Crawford wrote:
>
> Thanks Mike - precisely what i was after. 
>
> While this is a perfectly acceptable solution I wondered 
> whether, following Mauro's suggestion, it was worth opening an issue in any 
> case because it seems like it  be nice to be able to link indexes in array 
> comprehensions in a similar way to for-loops. Views? 
>
>
> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:
>>
>> MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]
>>
>> seems to do what you want I think. Using 2 nested 1-d comprehensions 
>> instead of a single 2-d comprehension.
>>
>> — Mike
>> ​
>> On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:
>>>
>>>
>>> Thanks Tomas. If I do:
>>>
>>> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>>>
>>> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
>>> However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
>>> k∈[1,binomial(J,2)]
>>> then i get a length 1 vector, whereas I would like length 2 vector. 
>>> Similarly for Y[3][k] I would like a length 3 vector.
>>>
>>>
>>> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:

 Ah.

 Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
 you’re looking for?

 // T

 On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:

 The lower case k is intentional. I didn't want such a 'large' array as 
> the one created when I use K because large parts of that array would be 
> redundant. Ideally, I want this array to be as small as possible, 
> especially since J and K might be quite a bit larger than in the example.
>
> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>
>> Are you sure that’s not just a typo between k and K (note the case 
>> difference)?
>>
>> This works for me:
>>
>> J=10
>> K=3
>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>
>> // T
>>
>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford 
>> wrote:
>>
>> Hi,
>>>
>>> I'd like to be able to define an array of vectors where the number 
>>> of vectors in the array is linked to the length of the vector. For 
>>> example, 
>>> I want to be define an array with say 10 scalars, 45 length 2 vectors, 
>>> 120 
>>> length 3 vectors,  and so on. Intuitively, I thought the following 
>>> code 
>>> might achieve this:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>>>
>>>
>>> However, it seems i cannot use k to define the number of element 
>>> indexed by n.  
>>>
>>> I was wondering if anyone knew how to create the desired array?
>>>
>>> Thanks
>>> Alan
>>>
>> ​
>>
> ​

>>>

[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Tomas Lycken


Now that we see the solution you were after, I note a few things:

   - What we *really* ended up with, is an Array{Array{Array{Int, 1}, 1}, 1}, 
   which is something fundamentally different than an Array{Array{Int, 1}, 
   2}. 
   - If we were to try to reshape this into a matrix-like shape, there 
   would be a lot of unfilled positions, which won’t be good for memory usage. 
   (This is because you can’t have a matrix where the columns have different 
   lengths - neither can you have one were rows have different lengths.) 

Thus, I don’t think this is a problem with list comprehensions. The problem 
is rather that it’s impossible to know the final size of the array without 
running the loops (*we* know that binomial(J,k) is monotonous, but the 
compiler doesn’t know that. So the compiler has to run binomial(J,k) *for 
every k* to know how large the largest is, so it can allocate space for the 
array.

// T

On Monday, September 21, 2015 at 10:59:31 AM UTC+2, Alan Crawford wrote:

Thanks Mike - precisely what i was after. 
>
> While this is a perfectly acceptable solution I wondered 
> whether, following Mauro's suggestion, it was worth opening an issue in any 
> case because it seems like it  be nice to be able to link indexes in array 
> comprehensions in a similar way to for-loops. Views? 
>
>
> On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:
>>
>> MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]
>>
>> seems to do what you want I think. Using 2 nested 1-d comprehensions 
>> instead of a single 2-d comprehension.
>>
>> — Mike
>> ​
>> On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:
>>>
>>>
>>> Thanks Tomas. If I do:
>>>
>>> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>>>
>>> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
>>> However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
>>> k∈[1,binomial(J,2)]
>>> then i get a length 1 vector, whereas I would like length 2 vector. 
>>> Similarly for Y[3][k] I would like a length 3 vector.
>>>
>>>
>>> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:

 Ah.

 Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
 you’re looking for?

 // T

 On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:

 The lower case k is intentional. I didn't want such a 'large' array as 
> the one created when I use K because large parts of that array would be 
> redundant. Ideally, I want this array to be as small as possible, 
> especially since J and K might be quite a bit larger than in the example.
>
> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>
>> Are you sure that’s not just a typo between k and K (note the case 
>> difference)?
>>
>> This works for me:
>>
>> J=10
>> K=3
>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>
>> // T
>>
>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford 
>> wrote:
>>
>> Hi,
>>>
>>> I'd like to be able to define an array of vectors where the number 
>>> of vectors in the array is linked to the length of the vector. For 
>>> example, 
>>> I want to be define an array with say 10 scalars, 45 length 2 vectors, 
>>> 120 
>>> length 3 vectors,  and so on. Intuitively, I thought the following 
>>> code 
>>> might achieve this:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>>>
>>>
>>> However, it seems i cannot use k to define the number of element 
>>> indexed by n.  
>>>
>>> I was wondering if anyone knew how to create the desired array?
>>>
>>> Thanks
>>> Alan
>>>
>> ​
>>
> ​

>>> ​


[julia-users] Re: Interview with the Julia language creators in The Programmer magazine (Chinese)

2015-09-21 Thread Sisyphuss
GitHub was blocked between Jan 20, 2013 to Jan 23, 2013 in China. 
Now it is accessible in China. However, Gist may be still blocked. 
All in all, it is much more available than Google.

Btw, I'm Chinese, but I'm in France currently.




On Monday, September 21, 2015 at 3:18:54 AM UTC+2, Eric Forgy wrote:
>
> Out of curiosity (and sorry for off topic)...
>
> How is Github in China? I like that the experimental Discourse forum can 
> be authenticated with Github. Would it make a difference for JuliaBox in 
> China if it was authenticated with Github as an alternative?
>
> Making Julia friendly for Asia seems to be a good path to massive 
> adoption. Btw, any Julians here in Asia? I'm in HK.
>
> On Monday, September 21, 2015 at 12:49:41 AM UTC+8, Sisyphuss wrote:
>>
>> I tried it in China last Christmas. Anything using Google service (e.g. 
>> google api, google font, google ajax) is extremely slow and often 
>> inaccessible. 
>>
>> On Sunday, September 20, 2015 at 9:00:57 AM UTC+2, Viral Shah wrote:
>>>
>>> Is it difficult to access JuliaBox in China because of Google 
>>> authentication?
>>>
>>> -viral
>>>
>>> On Saturday, September 19, 2015 at 7:12:35 PM UTC+5:30, Roger Luo wrote:

 Hi Jiahao Chen,
 I'm an undergraduate student in University of Science and Technology of 
 China, and working on Bohm trajectories in the key laboratory of quantum 
 information of CAS. After I used Julia0.3 in calculating the Bohmian 
 mechanics I think it's much better than cpp or python in Science.

 I heard from Hao Xu,the drone guy, who said he was with your guys in 
 Boston last year,that you are one of the developer. And it's pretty weird 
 that I didn't find any Chinese community on the julialang.org since 
 there is other communities. And few people use this language in my 
 university (at least among people I know)

 Is there any Chinese User Group in China? I just started a student club 
 in USTC(University of Science and Technology of China) called USTC Julia 
 User Group, and if there is a community mail-list about Chinese users and 
 if there a Chinese community I hope we can stay in touch. And I think it 
 would be more convenient for Chinese users to ask questions in Chinese.

 BTW,is there any possibility to start a juliabox service in 
 inner-China? I found accessing this is really hard in inner-China. If it's 
 possible, I can help to establish one in my university with members in 
 lug.(
 https://lug.ustc.edu.cn/wiki/) but I think I would need help cause I 
 only used Julia to program for my questions in the lab before.

 在 2014年3月14日星期五 UTC+8上午10:06:49,Jiahao Chen写道:
>
>
> 摘要:一群科学家对现有计算工具感到不满:他们想要一套开源系统,有C的快速,Ruby的动态,Python的通用,R般在统计分析上得心应手,Perl的处理字符串处理,Matlab的线性代数运算能力……易学又不让真正的黑客感到无聊。
>
> Abstract: a group of scientists are dissatisfied with existing 
> computational tools: they wish to have an original/pioneering system,
> with the speed of C, the dynamism of Ruby, the useability/widespread
> use of Python, the ease of statistical analysis à la R, the ability to 
> process strings like Perl, the ability to do linear algebra operations 
> like 
> Matlab... to be easy to learn, yet not be boring to real hackers.
>
> http://www.csdn.net/article/2014-03-12/2818732
>


[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford
Thanks Mike - precisely what i was after. 

While this is a perfectly acceptable solution I wondered whether, following 
Mauro's suggestion, it was worth opening an issue in any case because it 
seems like it  be nice to be able to link indexes in array comprehensions 
in a similar way to for-loops. Views? 


On Monday, 21 September 2015 09:49:57 UTC+1, Michael Hatherly wrote:
>
> MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]
>
> seems to do what you want I think. Using 2 nested 1-d comprehensions 
> instead of a single 2-d comprehension.
>
> — Mike
> ​
> On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:
>>
>>
>> Thanks Tomas. If I do:
>>
>> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>>
>> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
>> However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
>> k∈[1,binomial(J,2)]
>> then i get a length 1 vector, whereas I would like length 2 vector. 
>> Similarly for Y[3][k] I would like a length 3 vector.
>>
>>
>> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>>>
>>> Ah.
>>>
>>> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
>>> you’re looking for?
>>>
>>> // T
>>>
>>> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:
>>>
>>> The lower case k is intentional. I didn't want such a 'large' array as 
 the one created when I use K because large parts of that array would be 
 redundant. Ideally, I want this array to be as small as possible, 
 especially since J and K might be quite a bit larger than in the example.

 On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>
> Are you sure that’s not just a typo between k and K (note the case 
> difference)?
>
> This works for me:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>
> // T
>
> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford 
> wrote:
>
> Hi,
>>
>> I'd like to be able to define an array of vectors where the number of 
>> vectors in the array is linked to the length of the vector. For example, 
>> I 
>> want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
>> length 3 vectors,  and so on. Intuitively, I thought the following 
>> code 
>> might achieve this:
>>
>> J=10
>> K=3
>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>>
>>
>> However, it seems i cannot use k to define the number of element 
>> indexed by n.  
>>
>> I was wondering if anyone knew how to create the desired array?
>>
>> Thanks
>> Alan
>>
> ​
>
 ​
>>>
>>

[julia-users] Re: @sprintf with a format string

2015-09-21 Thread Michael Hatherly


https://github.com/JuliaLang/Formatting.jl might help.

— Mike
​
On Monday, 21 September 2015 10:46:31 UTC+2, Ferran Mazzanti wrote:
>
> Dear all,
>
> I could use some help here, because I can't believe I'm not able to easily 
> print formatted numbers under Julia in a easy way. What I try to do is to 
> write a function that, given a vector, prints all its components with a 
> user-defined format. I was trying something of the form
>
> function Print_Vec(aux_VEC,form_VEC)
> form_VEC :: ASCIIString
> str_VEC  = "%16.8f"
> for elem_VEC in aux_VEC
> str_VEC += @sprintf(form_VEC,elem_VEC)
> end
> return str_VEC
> end
>
> However, that doesn't work because it looks like the first argument in 
> @sprintf must be a explicit string, and not a variable.
> Is there anything I can do with that?
>
> Thanks a lot for your help.
>


[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Michael Hatherly


MyArray = [[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]

seems to do what you want I think. Using 2 nested 1-d comprehensions 
instead of a single 2-d comprehension.

— Mike
​
On Monday, 21 September 2015 10:37:06 UTC+2, Alan Crawford wrote:
>
>
> Thanks Tomas. If I do:
>
> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>
> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
> However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
> k∈[1,binomial(J,2)]
> then i get a length 1 vector, whereas I would like length 2 vector. 
> Similarly for Y[3][k] I would like a length 3 vector.
>
>
> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>>
>> Ah.
>>
>> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
>> you’re looking for?
>>
>> // T
>>
>> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:
>>
>> The lower case k is intentional. I didn't want such a 'large' array as 
>>> the one created when I use K because large parts of that array would be 
>>> redundant. Ideally, I want this array to be as small as possible, 
>>> especially since J and K might be quite a bit larger than in the example.
>>>
>>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:

 Are you sure that’s not just a typo between k and K (note the case 
 difference)?

 This works for me:

 J=10
 K=3
 MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]

 // T

 On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford wrote:

 Hi,
>
> I'd like to be able to define an array of vectors where the number of 
> vectors in the array is linked to the length of the vector. For example, 
> I 
> want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
> length 3 vectors,  and so on. Intuitively, I thought the following 
> code 
> might achieve this:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>
>
> However, it seems i cannot use k to define the number of element 
> indexed by n.  
>
> I was wondering if anyone knew how to create the desired array?
>
> Thanks
> Alan
>
 ​

>>> ​
>>
>

[julia-users] @sprintf with a format string

2015-09-21 Thread Ferran Mazzanti
Dear all,

I could use some help here, because I can't believe I'm not able to easily 
print formatted numbers under Julia in a easy way. What I try to do is to 
write a function that, given a vector, prints all its components with a 
user-defined format. I was trying something of the form

function Print_Vec(aux_VEC,form_VEC)
form_VEC :: ASCIIString
str_VEC  = "%16.8f"
for elem_VEC in aux_VEC
str_VEC += @sprintf(form_VEC,elem_VEC)
end
return str_VEC
end

However, that doesn't work because it looks like the first argument in 
@sprintf must be a explicit string, and not a variable.
Is there anything I can do with that?

Thanks a lot for your help.


Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
I think this is a limitation of list comprehensions:

julia> [(i,j) for i=1:3, j=1:i]
ERROR: i not defined
 in anonymous at no file

but doing the loop works:

julia> for i=1:3, j=1:i
   @show i,j
   end
(i,j) => (1,1)
(i,j) => (2,1)
(i,j) => (2,2)
(i,j) => (3,1)
(i,j) => (3,2)
(i,j) => (3,3)

Maybe you could check whether there is an issue about this already and
if not file one?

On Mon, 2015-09-21 at 10:37, Alan Crawford  wrote:
> Thanks Tomas. If I do:
>
> Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]
>
> Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector).
> However, the issue for Y[2] and above. For example, if I do Y[2][k] where
> k∈[1,binomial(J,2)]
> then i get a length 1 vector, whereas I would like length 2 vector. Similarly
> for Y[3][k] I would like a length 3 vector.
>
>
> On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>
>
> Ah.
>
> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
> you’re
> looking for?
>
> // T
>
> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:
>
> The lower case k is intentional. I didn't want such a 'large' array as
> the one created when I use K because large parts of that array would 
> be
> redundant. Ideally, I want this array to be as small as possible,
> especially since J and K might be quite a bit larger than in the
> example.
>
> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>
>
> Are you sure that’s not just a typo between k and K (note the case
> difference)?
>
> This works for me:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>
> // T
>
> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford
> wrote:
>
> Hi,
>
> I'd like to be able to define an array of vectors where the
> number of vectors in the array is linked to the length of the
> vector. For example, I want to be define an array with say 10
> scalars, 45 length 2 vectors, 120 length 3 vectors,  and 
> so
> on. Intuitively, I thought the following code might achieve
> this:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>
>
> However, it seems i cannot use kto define the number of
> element indexed by n. 
>
> I was wondering if anyone knew how to create the desired 
> array?
>
> Thanks
> Alan
>
> ​
>
> ​



[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford

Thanks Tomas. If I do:

Y = [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)]

Then Y[1] gives the desired result (i.e. Y[1][k] is a length 1 vector). 
However, the issue for Y[2] and above. For example, if I do Y[2][k] where 
k∈[1,binomial(J,2)]
then i get a length 1 vector, whereas I would like length 2 vector. 
Similarly for Y[3][k] I would like a length 3 vector.


On Monday, 21 September 2015 09:23:56 UTC+1, Tomas Lycken wrote:
>
> Ah.
>
> Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what 
> you’re looking for?
>
> // T
>
> On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:
>
> The lower case k is intentional. I didn't want such a 'large' array as the 
>> one created when I use K because large parts of that array would be 
>> redundant. Ideally, I want this array to be as small as possible, 
>> especially since J and K might be quite a bit larger than in the example.
>>
>> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>>
>>> Are you sure that’s not just a typo between k and K (note the case 
>>> difference)?
>>>
>>> This works for me:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>>
>>> // T
>>>
>>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford wrote:
>>>
>>> Hi,

 I'd like to be able to define an array of vectors where the number of 
 vectors in the array is linked to the length of the vector. For example, I 
 want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
 length 3 vectors,  and so on. Intuitively, I thought the following 
 code 
 might achieve this:

 J=10
 K=3
 MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]


 However, it seems i cannot use k to define the number of element 
 indexed by n.  

 I was wondering if anyone knew how to create the desired array?

 Thanks
 Alan

>>> ​
>>>
>> ​
>


[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Tomas Lycken


Ah.

Maybe [Array(Int64,n) for n in map(k -> binomial(J,k), 1:K)] is what you’re 
looking for?

// T

On Monday, September 21, 2015 at 10:18:31 AM UTC+2, Alan Crawford wrote:

The lower case k is intentional. I didn't want such a 'large' array as the 
> one created when I use K because large parts of that array would be 
> redundant. Ideally, I want this array to be as small as possible, 
> especially since J and K might be quite a bit larger than in the example.
>
> On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>>
>> Are you sure that’s not just a typo between k and K (note the case 
>> difference)?
>>
>> This works for me:
>>
>> J=10
>> K=3
>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>>
>> // T
>>
>> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford wrote:
>>
>> Hi,
>>>
>>> I'd like to be able to define an array of vectors where the number of 
>>> vectors in the array is linked to the length of the vector. For example, I 
>>> want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
>>> length 3 vectors,  and so on. Intuitively, I thought the following code 
>>> might achieve this:
>>>
>>> J=10
>>> K=3
>>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>>>
>>>
>>> However, it seems i cannot use k to define the number of element indexed 
>>> by n.  
>>>
>>> I was wondering if anyone knew how to create the desired array?
>>>
>>> Thanks
>>> Alan
>>>
>> ​
>>
> ​


[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford
The lower case k is intentional. I didn't want such a 'large' array as the 
one created when I use K because large parts of that array would be 
redundant. Ideally, I want this array to be as small as possible, 
especially since J and K might be quite a bit larger than in the example.

On Monday, 21 September 2015 09:13:53 UTC+1, Tomas Lycken wrote:
>
> Are you sure that’s not just a typo between k and K (note the case 
> difference)?
>
> This works for me:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]
>
> // T
>
> On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford wrote:
>
> Hi,
>>
>> I'd like to be able to define an array of vectors where the number of 
>> vectors in the array is linked to the length of the vector. For example, I 
>> want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
>> length 3 vectors,  and so on. Intuitively, I thought the following code 
>> might achieve this:
>>
>> J=10
>> K=3
>> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>>
>>
>> However, it seems i cannot use k to define the number of element indexed 
>> by n.  
>>
>> I was wondering if anyone knew how to create the desired array?
>>
>> Thanks
>> Alan
>>
> ​
>


[julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Tomas Lycken


Are you sure that’s not just a typo between k and K (note the case 
difference)?

This works for me:

J=10
K=3
MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,K)]

// T

On Monday, September 21, 2015 at 10:08:13 AM UTC+2, Alan Crawford wrote:

Hi,
>
> I'd like to be able to define an array of vectors where the number of 
> vectors in the array is linked to the length of the vector. For example, I 
> want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
> length 3 vectors,  and so on. Intuitively, I thought the following code 
> might achieve this:
>
> J=10
> K=3
> MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]
>
>
> However, it seems i cannot use k to define the number of element indexed 
> by n.  
>
> I was wondering if anyone knew how to create the desired array?
>
> Thanks
> Alan
>
​


Re: [julia-users] Re: ERROR: curve_fit not defined

2015-09-21 Thread Pontus Stenetorp
On 21 September 2015 at 08:30, testertester  wrote:
>
> YAK ALERT: ABANDON SHI(T)P
> I'll try installing it on Windows tomorrow. Every attempt at installing
> 0.3.11 on ubuntu failed no matter how many dependencies I installed. Also,
> the link to download the .debs no workey. Not at all surprised.

Try the advice that Tony gave you, use the tarballs.


JLTAR=https://julialang.s3.amazonaws.com/bin/linux/x86/0.3/julia-0.3.11-linux-i686.tar.gz
mkdir julia && wget -O - "${JLTAR}" | tar -C julia \
--strip-components=1 -x -z -f - && julia/bin/julia

As for guides on Stack Overflow and personal home pages, it is
difficult for it to be in sync with a fast moving target that still
has not had a 1.0 release.  For up-to-date documentation, please see
the official homepage [1].

Pontus

[1]: http://docs.julialang.org/en/release-0.3/


Re: [julia-users] When does colon indexing get evaluated / converted?

2015-09-21 Thread Tomas Lycken


I recently implemented a similar transformation for array-like objects 
, in which I decided 
to create functions bounds(A, dim) = (lbound(A, dim), ubound(A, dim)) which 
return the end points of the indexing axes; without those, it was really 
hard to deduce what indices things should map to.

It might be that these should actually be included in Base and used by the 
colon indexing implementation for AbstractArrays (bounds(A, dim) = (1, 
size(A, dim)) for all Arrays, so could probably be inlined at no runtime 
cost). If so, you could use them too and have your FArray type return e.g. (-2, 
8), which would allow the default colon indexing implementation to Just 
Work™.

// T

On Monday, September 21, 2015 at 9:54:38 AM UTC+2, Mauro wrote:

I seem to recall that this was discussed recently, probably by Matt, but 
> cannot find it.  I did however find this gist: 
> https://gist.github.com/alsam/8283205, maybe of help. 
>
>
> On Mon, 2015-09-21 at 06:38, 'Greg Plowman' via julia-users <
> julia...@googlegroups.com > wrote: 
> > To further clarify, I thought I could specialise getindex / setindex! on 
> colon 
> > type argument. 
> > 
> > see below, getindex2 is being called, but getindex is not being called. 
> > A[:] calls getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> > abstractarray.jl:380 
> > presumably after [:] has been converted to [1:8] 
> > 
> > 
> > 
> > julia> getindex(A::FArray, ::Colon) = A[start(A) : endof(A)] 
> > getindex (generic function with 177 methods) 
> > 
> > julia> getindex2(A::FArray, ::Colon) = A[start(A) : endof(A)] 
> > getindex2 (generic function with 1 method) 
> > 
> > julia> A = FZeros(Int, -2:8) 
> > 11-element FArray{Int64,1} (-2:8,) 
> > 
> > julia> A[:] 
> > 8-element Array{Int64,1}: 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> > 
> > julia> @which A[:] 
> > getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> > abstractarray.jl:380 
> > 
> > julia> getindex2(A, :) 
> > 11-element Array{Int64,1}: 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> >  0 
> > 
> > julia> 
>
> ​


[julia-users] Array of vectors of variable number and lengths

2015-09-21 Thread Alan Crawford
Hi,

I'd like to be able to define an array of vectors where the number of 
vectors in the array is linked to the length of the vector. For example, I 
want to be define an array with say 10 scalars, 45 length 2 vectors, 120 
length 3 vectors,  and so on. Intuitively, I thought the following code 
might achieve this:

J=10
K=3
MyArray = [Array(Int64,k) for k in 1:K, n in 1:binomial(J,k)]


However, it seems i cannot use k to define the number of element indexed by 
n.  

I was wondering if anyone knew how to create the desired array?

Thanks
Alan


Re: [julia-users] When does colon indexing get evaluated / converted?

2015-09-21 Thread Mauro
I seem to recall that this was discussed recently, probably by Matt, but
cannot find it.  I did however find this gist:
https://gist.github.com/alsam/8283205, maybe of help.


On Mon, 2015-09-21 at 06:38, 'Greg Plowman' via julia-users 
 wrote:
> To further clarify, I thought I could specialise getindex / setindex! on 
> colon 
> type argument.
>
> see below, getindex2 is being called, but getindex is not being called.
> A[:] calls getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> abstractarray.jl:380
> presumably after [:] has been converted to [1:8]
>
>
>
> julia> getindex(A::FArray, ::Colon) = A[start(A) : endof(A)]
> getindex (generic function with 177 methods)
>
> julia> getindex2(A::FArray, ::Colon) = A[start(A) : endof(A)]
> getindex2 (generic function with 1 method)
>
> julia> A = FZeros(Int, -2:8)
> 11-element FArray{Int64,1} (-2:8,)
>
> julia> A[:]
> 8-element Array{Int64,1}:
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>
> julia> @which A[:]
> getindex(A::AbstractArray{T,N},I::AbstractArray{T,N}) at 
> abstractarray.jl:380
>
> julia> getindex2(A, :)
> 11-element Array{Int64,1}:
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>  0
>
> julia>



Re: [julia-users] Check if type "contains" Any

2015-09-21 Thread Mauro
You can access the type parameters with T.parameters.  Have a look at
https://github.com/mbauman/Tuples.jl.  Also note possible complications
with vararg types.

However, doing this for non-tuple types this is probably a sign of bad
design as was recently discussed here:
https://groups.google.com/forum/#!searchin/julia-users/parameters/julia-users/d-HQdYEDjbc/VP8MydPBAgAJ

On Mon, 2015-09-21 at 05:10, Tommy Hofmann  wrote:
> I would like to write a function "contains_any(T)" which checks wether a 
> type T "contains" Any. For example
>
> contains_any(Integer) = false
> contains_any(Any) = true
> contains_any(Tuple{Integer, Any}) = true
> contains_any(Tuple{Tuple{Integer, Any}, Float64}) = true
>
> etc. How could one do this in julia?
>
> Thanks,
> Tommy



Re: [julia-users] Guideline for Function Documentation

2015-09-21 Thread Christof Stocker
What would be really nice and useful for documenting functions would be 
support for something like the "description" environment in Latex. 
However, I don't think standard markdown even has something like that


On 2015-09-20 22:15, Milan Bouchet-Valat wrote:

Le dimanche 20 septembre 2015 à 21:46 +0200, Christof Stocker a écrit :

So the website is (probably on purpose) not very specific on
recommendations for how to document ones functions (stylewise) using
the
new doc system. However, since I am writing an enduser-facing library
with a lot of parameters, I am wondering about what useful guidelines
others here came up with that seem to work nicely for documentation.

I work a lot with R so naturally I have taken inspiration from how
the R
help docs are structured. However, now I wonder what would be a good
way
to list and describe all the named arguments of a function. Simply
making bullet points doesn't seem like the most readable option

any opinions, references, or tips on that?

I suspect the manual doesn't say anything because there's no convention
yet. See:
https://github.com/JuliaLang/julia/issues/8966


Regards





[julia-users] Adding Github authentication to JuliaBox

2015-09-21 Thread Eric Forgy
Hi,

In this comment 
, 
Viral suggested that it should be easy to add Github authentication to 
JuliaBox.

We had a look and this is what we found so far:

   - The main page is located here: JuliaBox/engine/www/index.tpl
   - The Google sign-in button is 
   here: JuliaBox/engine/src/juliabox/plugins/auth_google/google_login_btn.tpl
   - We'd probably add a folder "auth_github" to 
   JuliaBox/engine/src/juliabox/plugins/

We are not experts in JuliaBox technologies (Docker, Drupal/PHP/Smarty, 
Python), so we'll probably put this on the back burner for now, but thought 
we'd share this in case it helps anyone else who wants to give it a try.

Cheers,
Eric


[julia-users] Re: ERROR: curve_fit not defined

2015-09-21 Thread testertester
YAK ALERT: ABANDON SHI(T)P
I'll try installing it on Windows tomorrow. Every attempt at installing 
0.3.11 on ubuntu failed no matter how many dependencies I installed. Also, 
the link to download the .debs 
 no 
workey. Not at all surprised.


On Sunday, September 20, 2015 at 7:30:19 PM UTC-4, testertester wrote:
>
> I'm using Lubuntu 15.04. VERSION gives me 0.3.2 and x86_64-linux-gnu. 
> However, I'm getting this error after changing WalkingRandomly's demo: 
>
> "ERROR: `curve_fit` has no method matching curve_fit(::Function, 
> ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1})"
>
> What it suggests is 
> # 2 methods for generic function "curve_fit":
> curve_fit{T}(::Type{T},x,y) at 
> /home/paul/.julia/v0.3/CurveFit/src/linfit.jl:72
> curve_fit{T}(::Type{T},x,y,args...) at 
> /home/paul/.julia/v0.3/CurveFit/src/linfit.jl:73
>
> What is the difference between WR's example and what is suggested?
>
> I'm trying nonlinear_fit(), but the example in the readme is rather obtuse.
>
>
>
> On Sunday, September 20, 2015 at 2:54:55 PM UTC-4, Tony Kelman wrote:
>>
>> Call the function versioninfo(), or enter the constant VERSION
>>
>> Depending on what version of Ubuntu you're using, the Julia that you 
>> installed from apt-get is probably quite out of date. It's better to use 
>> the more recent tarball releases available from 
>> www.julialang.org/downloads.
>>
>>
>> On Sunday, September 20, 2015 at 10:46:53 AM UTC-7, testertester wrote:
>>>
>>> I am on Ubuntu, and my copy of julia was installed with apt-get install 
>>> julia.
>>>
>>> I was trying the curve fitting tutorial found here (
>>> http://www.walkingrandomly.com/?p=5181) but I kept getting the error 
>>> "curve_fit not defined". Yes, I have done "Pkg.add("Optim")" and 
>>> "Pkg.add("LsqFit")", that doesn't help. Apparently, nobody else on the 
>>> internet has ever had this problem. 
>>> I'm
>>>  
>>> surprised.
>>>
>>> Also, it doesn't seem like I can find the version number of Julia that 
>>> I'm using. Following this (
>>> http://stackoverflow.com/questions/25326890/how-to-find-version-number-of-julia-is-there-a-ver-command)
>>>  
>>> just gives me the error "verbose not defined". Is every piece of 
>>> documentation about Julia from earlier than 6/2015 invalid now? The 
>>> responses I found here 
>>> are 
>>> pretty useless, as curve_fit doesn't even work by itself.
>>>
>>

[julia-users] Re: Check if type "contains" Any

2015-09-21 Thread Tomas Lycken


Is it only tuples that you want to consider as “composite”, would e.g. 
contains_any(Array{Any,2}) or contains_any(Union{Integer,Any}) also return 
true?

Also, all use cases I can think of for this function indicate that you 
could just as well use isleaftype directly, so you might not need to figure 
this out at all :)

// T

On Monday, September 21, 2015 at 5:13:02 AM UTC+2, Tommy Hofmann wrote:

I would like to write a function "contains_any(T)" which checks wether a 
> type T "contains" Any. For example
>
> contains_any(Integer) = false
> contains_any(Any) = true
> contains_any(Tuple{Integer, Any}) = true
> contains_any(Tuple{Tuple{Integer, Any}, Float64}) = true
>
> etc. How could one do this in julia?
>
> Thanks,
> Tommy
>
​