Re: [julia-users] Why is julia interpreting what's inside a string?

2015-09-06 Thread Leah Hanson
Julia has some special characters it recognizes inside string. For example,
`$` lets you interpolate Julia variables or expressions inside a string. To
get a string that represents what you've literally typed in, you need to
add a backslash before the backslash and dollar sign characters. The
backslash will not be present when you print the strings out or otherwise
use them, although it will appear when Julia shows the value to you at the
REPL.

~~~
julia> "3.2 3.6 z(x,y) = x@~\\327@~exp(-x@+2@+-y@+2@+)"
"3.2 3.6 z(x,y) = x@~\\327@~exp(-x@+2@+-y@+2@+)"

julia> print(ans)
3.2 3.6 z(x,y) = x@~\327@~exp(-x@+2@+-y@+2@+)

julia> "grdmath \$ DDX"
"grdmath \$ DDX"

julia> print(ans)
grdmath $ DDX
~~~

-- Leah

On Sun, Sep 6, 2015 at 4:08 PM, J Luis  wrote:

> I need to create these, not to interpret what julia thinks it means.
>
> julia> "3.2 3.6 z(x,y) = x@~\327@~exp(-x@+2@+-y@+2@+)"
> ERROR: syntax: invalid UTF-8 sequence
>
> julia> "grdmath $ DDX"
> ERROR: syntax: invalid interpolation syntax: "$ "
>
> How do I do that?
>
> Thanks
>


Re: [julia-users] what are "hard" and "soft" bindings?

2015-07-07 Thread Leah Hanson
I think his summary in #11031 is accurate, and the reason given directly in
the reply is the reason for using/importall to be different. Issue #8000 is
a discussion of ways to change/simplify the syntax.

I'll take a stab at rephrasing the different in case that helps. There is
only one difference, and on the surface (syntax-wise) it may seem very
minor. The difference between "using" and "importall" is that with "using"
you need to say "function Foo.bar(.." to extend module Foo's function bar
with a new method, but with "importall" or "import Foo.bar", you only need
to say "function bar(..." and it automatically extends module Foo's
function bar.

If you use "importall", then "function Foo.bar(..." and "function bar(..."
become equivalent. If you use "using", then they are different.

The reason this is important enough to have been given separate syntax is
that you don't want to accidentally extend a function that you didn't know
existed, because that could easily cause a bug. This is most likely to
happen with a method that takes a common type like string or int, because
both you and the other module could define a method to handle such a common
type. If you use importall, then you'll replace the other module's
implementation of "bar(s::String)" with your new implementation, which
could easily do something complete different (and break all/many future
usages of the other functions in module Foo that depend on calling bar).

Does this make more sense to you?
(And is it an answer to the question you were asking, or did I
misunderstand?)

Best,
 Leah

On Tue, Jul 7, 2015 at 9:05 AM, andrew cooke  wrote:

>
> i'm trying to understand the difference between "using" and "importall".
> i have the same confusion described at
> https://github.com/JuliaLang/julia/issues/11031 but, unlike the OP there,
> reading https://github.com/JuliaLang/julia/issues/8000 had not clarified
> things for me.
>
> thanks,
> andrew
>
>


Re: [julia-users] Re: Call function from a string with its name

2015-07-03 Thread Leah Hanson
You want to pass the symbol into the macro or convert before the quote
block:

~~~julia
macro create_function(name::String)
n = symbol(name)
return quote
(x) -> ($n)(x) + 7
end
end
~~~

Or you can just add some parens:

~~~julia
macro create_function(name::String)
return quote
(x) -> ($(symbol(name)))(x) + 7
end
end
~~~

You want to convert from string to symbol *in macro context*, not at run
time. That way the code a run-time has a symbol that it will understand as
a function call.

-- Leah

On Fri, Jul 3, 2015 at 3:26 PM,  wrote:

> I meant inside the macro.
>
> Le vendredi 3 juillet 2015 15:26:01 UTC+2, ami...@gmail.com a écrit :
>>
>> Ok, it seems eval(parse($name)) inside the function does the trick...
>>
>


Re: [julia-users] Broken links on Julia frontpage

2015-06-27 Thread Leah Hanson
Hey,

Thanks for noticing this problem. Do you think you could make a pull
request with those changes?

The github repo is here: https://github.com/JuliaLang/julialang.github.com

I think you'll just need to edit index.md:
https://github.com/JuliaLang/julialang.github.com/blob/master/index.md

-- Leah


On Sat, Jun 27, 2015 at 8:53 PM, Alex Ames 
wrote:

> I found several broken links on julialang.org: the links for random
> number generation, signal processing, and string processing all lead to
> http://docs.julialang.org/en/release-0.3/stdlib/base/ instead of those
> topics' current locations. The corrected links should be:
>
>-
>http://docs.julialang.org/en/release-0.3/stdlib/numbers/#random-numbers
>-
>http://docs.julialang.org/en/release-0.3/stdlib/math/#signal-processing
>- http://docs.julialang.org/en/release-0.3/manual/strings/
>
>


[julia-users] YOW! Julia Talk

2015-03-23 Thread Leah Hanson
Hi,

I gave a talk at YOW! in Australia in December, and the video has been
posted. The talk is "How Julia Goes Fast"; it's about details of design and
implementation choices that help Julia get good performance. I think the
actual practical affects are common knowledge on this list, so I don't know
how useful this talk would be here.

Link:
https://yow.eventer.com/yow-2014-1222/how-julia-goes-faster-by-leah-hanson-1694

If you notice any inaccuracies in the talk, please let me know. (Or if
there's something not covered in the talk that's important to Julia's
performance.)

Best,
  Leah


Re: [julia-users] Does TypeCheck specify which methods failed ?

2015-01-14 Thread Leah Hanson
Hi,

Yes, the method signatures should print out between the call the
checkreturntypes and the "The total number..." line. Currently, it often
prints out a lot of unnecessary new lines, so you may need to scroll up.

If you don't see that output at all, please file an issue on the
TypeCheck.jl github repo.

(Sorry for not responding more promptly.)

-- Leah

On Thu Jan 08 2015 at 4:00:44 AM  wrote:

> I see this when I use TypeCheck:
>
>  checkreturntypes(ModuleName)
> blah blah
> The total number of failed methods in ModuleName is 2
>
> But I can't see which methods failed. Am I missing something ?
>
> --John
>
>


[julia-users] Example of a Package Install Breaking

2014-12-27 Thread Leah Hanson
I'm working on a book chapter about using the Julia package manager. One
example I want to include is debugging a broken package install. I'm
currently expecting to focus on a problem caused by binary installs, since
that seems to be the mostly likely cause of a Pkg.add failing.

However, it's hard for me to conjure one at will. Does anyone here have any
suggestions?

It would be helpful if you either (A) have a story about a package install
that broke at first and that you then got working (please say what happened
and how you fixed it) or (B) an idea for how to reliably create a problem
for Pkg.add (which would make it easier for me to get the example output
for the book).

Thanks!
Leah


Re: [julia-users] Re: do I misunderstand zip, or is it not referentially transparent?

2014-12-25 Thread Leah Hanson
Ronald, could you open up a fresh Julia REPL and try your code example
there? I'm not sure how it would happen with this example, but sometimes
when people find unreproducible problems it's caused by a previous
definition in their REPL.

-- Leah
On Wed, Dec 24, 2014 at 4:24 PM Steven G. Johnson 
wrote:

>
>
> On Sunday, December 21, 2014 11:22:39 PM UTC-6, Ronald L. Rivest wrote:
>>
>> Versioninfo() gives:
>>
>
> I have essentially exactly the same version (0.3.2 on
> x86_64-apple-darwin13.3.0, MacOS 10.10), and it works fine for me.
>


Re: [julia-users] Re: home page content

2014-12-09 Thread Leah Hanson
Seeing code examples of a type and a couple of functions that use it would
probably give a good idea of what the code looks like. The JuMP seems
exciting enough to highlight both as a package and a use of macros.

I don't know if you want to encourage different styles, but seeing examples
of Python like, c like, and functional-ish ways of writing Julia would be a
way to show off the variety of things you can do.

--Leah
On Wed, Dec 10, 2014 at 8:50 AM Elliot Saba  wrote:

> We're having intermittent DNS issues.  http://julialang.org is now up for
> me however, and I can dig it: (I couldn't, previously)
>
> $ dig julialang.org
>
> ; <<>> DiG 9.8.3-P1 <<>> julialang.org
> ;; global options: +cmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56740
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 4
>
> ;; QUESTION SECTION:
> ;julialang.org. IN  A
>
> ;; ANSWER SECTION:
> julialang.org.  2202IN  CNAME   julialang.github.io.
> julialang.github.io.2202IN  CNAME   github.map.fastly.net.
> github.map.fastly.net.  15  IN  A   199.27.79.133
> ...
> -E
>
>
>
> On Tue, Dec 9, 2014 at 2:46 PM,  wrote:
>
>>
>>
>> On Wednesday, December 10, 2014 8:23:26 AM UTC+10, Stefan Karpinski wrote:
>>>
>>> We're looking to redesign the JuliaLang.org home page and try to give it
>>> a little more focus than it currently has. Which raises the question of
>>> what to focus on. We could certainly have better code examples and maybe
>>> highlight features of the language and its ecosystem better. What do people
>>> think we should include?
>>>
>>
>> The whole site seems to be offline?  Is that because of this?
>>
>
>


Re: [julia-users] Re: parametrized type weirdness? or Julia bug?

2014-10-07 Thread Leah Hanson
You need to fully specify TDict when using it's constructor:

~~~
julia> module testnestparam2

   immutable Token{S,T}
   m::S
   t::T
   end

   typealias TDict{K,D} Token{Dict{K,D}, Int}

   function makeADict()
   a = TDict{Int64,String}([1=>"a",2=>"c"], 5)
   end

   end
Warning: replacing module testnestparam2

julia> testnestparam2.makeADict()
Token{Dict{Int64,String},Int64}([2=>"c",1=>"a"],5)
~~~

On Tue, Oct 7, 2014 at 11:41 AM,  wrote:

> Oops, sorry, in my last posting there was obviously an error in my code
> because I used the wrong syntax to call an array constructor.  Here is
> another example where now I am using the correct constructor syntax (I
> think?).  But I still get the same error message concerning 'apply'.
>
> module testnestparam2
>
> immutable Token{S,T}
> m::S
> t::T
> end
>
> typealias TDict{K,D} Token{Dict{K,D}, Int}
>
> function makeADict()
> a = TDict([1=>"a",2=>"c"], 5)
> end
>
> end
>
>
>
>
>
>
>
>
>
>
> On Tuesday, October 7, 2014 12:29:49 PM UTC-4, vav...@uwaterloo.ca wrote:
>>
>> Here is a very short Julia code that gives a mysterious error message in
>> the latest build (952).  Is it an error in my code or a bug in Julia?  (In
>> addition to the answer to this question, I would also like help with the
>> code design question in my previous posting of two hours ago.)
>>
>> Thanks,
>> Steve
>>
>> module testnestparam2
>>
>> typealias ADict{K,D} Array{Dict{K,D},1}
>>
>> function makeADict()
>> a = ADict([[-9=>"a"],[15=>"b"]]) #line 6
>> println("a[1][-9] = ", a[1][-9])
>> end
>>
>> end
>>
>> julia> testnestparam2.makeADict()
>> ERROR: type: makeADict: in apply, expected Function, got
>> Type{Array{Dict{K,D},1
>> }
>>  in makeADict at c:\Users\vavasis\Documents\Projects\qmg21\julia\
>> testnestparam2
>> jl:6
>>
>>
>>
>> On Tuesday, October 7, 2014 10:05:09 AM UTC-4, vav...@uwaterloo.ca wrote:
>>>
>>> Thanks for the explanation!  Although I think I understand your answer,
>>> I'm not sure how to define the types to accomplish my goal.
>>>
>>> * a Token should have two parts, a container and a semitoken, both
>>> abstract
>>>
>>> * an SDToken should be a specialization of Token in which the container
>>> portion is SortedDict{K,D} for a specific K,D and the semitoken portion is
>>> IntSemiToken (both parts concrete)
>>>
>>> * Some functions take SDToken's as input.  These should be generic,
>>> i.e., work for all choices of K,D.
>>>
>>> * There are also generic functions that return SDTokens as output (in
>>> which K and D are determined from the input args).
>>>
>>> Can I write typealias SDToken{K,D} Token{SortedDict{K,D},IntSemiToken}?
>>> I tried this and got an unexpected error message:
>>>
>>> ERROR: type: test1: in apply, expected Function, got
>>> Type{Token{SortedDict{K,D},
>>> IntSemiToken}}
>>>  in test1 at c:\Users\vavasis\Documents\Projects\qmg21\julia\
>>> testnestparam.jl:32
>>>
>>> (No 'apply' in my code!)  And in any case, even if I could write this,
>>> I'm not sure it solves the problem.
>>>
>>> -- Steve
>>>
>>>
>>>
>>> On Tuesday, October 7, 2014 2:15:01 AM UTC-4, Jutho wrote:

 I don't see the problem regarding point one.

 A type with parameters, as your SortedDict{D,K}, becomes an abstract
 type when the parameters are unspecified, e.g. SortedDict, but this is
 indeed printed/formatted with unspecified parameters put back (I guess with
 the name as you defined them), e.g. as SortedDict{D,K}.

 Regarding point 2, this relates to the invariance of parametric types.

 isa(t2,Token{SortedDict, IntSemiToken})
 will return false, because
 Token{SortedDict{Int64,ASCIIString},IntSemiToken} <: Token{SortedDict,
 IntSemiToken}
 is false. There are many discussions regarding this both on the forum
 and I guess in the manual. Search for invariance versus covariance of
 parametric types.


 Op dinsdag 7 oktober 2014 04:42:12 UTC+2 schreef vav...@uwaterloo.ca:
>
> The code below is an excerpt from a more complicated code I am
> writing.  It contains a parametrized type in which the parameter is itself
> another parametrized type. I have attached the printout (0.4.0-dev+323).
> Notice the error message at the end.  My questions are:
>
> (1) How is it possible that the type of t includes dummy parameters K
> and D, which aren't real types at all?
>
> (2) Why is Julia not able to match t2 but it is able to match t to the
> signature of test0()?
>
> Thanks,
> Steve Vavasis
>
>
> julia> testnestparam.test1()
> typeof(t) = Token{SortedDict{K,D},IntSemiToken}
> typeof(t2) = Token{SortedDict{Int64,ASCIIString},IntSemiToken}
> methods(test0) = # 1 method for generic function "test0":
> test0(i::Token{SortedDict{K,D},IntSemiToken}) at
> c:\Users\vavasis\Documents\Projects\qmg21\julia\testnestparam.jl:28
> ERROR: `test0` has no method matchi

Re: [julia-users] Re: a good IDE for Julia ? (Julia Studio does not work with Julia v 0.3.0)

2014-09-30 Thread Leah Hanson
Maybe you could start a new julia-users thread, and post the code and the
error message so we can help? It's hard to make specific recommendations
without seeing the code/error.

-- Leah

On Tue, Sep 30, 2014 at 9:27 AM, Ján Dolinský 
wrote:

> Hello guys,
>
> Indeed, www.junolab.org makes me want to go with Julia farther too :).
>
> I was asking about debugging because I implemented a custom type (in a
> module) of which constructor is failing somewhere but I just get an error
> about some array multiplication in some julia file instead of a concrete
> line number in the constructor function. Any idea how to get through this ?
>
> Thanks a lot,
> Jan
>
>
> Dňa pondelok, 29. septembra 2014 12:27:07 UTC+2 Viral Shah napísal(-a):
>
>> The light table work that Mike Innes has done is now packaged and
>> available at http://www.junolab.org/
>>
>> We are hoping to work towards making self-sufficient binaries and getting
>> it to a point where it is usable with a single download. The real fun is to
>> then try and do more interesting things. I don't know what those are, but I
>> do feel that we are setting ourselves up with a good base.
>>
>> -viral
>>
>> On Saturday, September 27, 2014 12:38:39 PM UTC+5:30, colint...@gmail.com
>> wrote:
>>>
>>> No, I don't think it has debugging a la the Matlab IDE or R-Studio
>>> (yet). My understanding is that for now the Debug package is all that is
>>> available. Personally I make do with sending blocks of code to a console in
>>> Sublime-IJulia (you can do this with shift+enter, just like in R-Studio).
>>>
>>> Cheers,
>>>
>>> Colin
>>>
>>> On Friday, September 26, 2014 7:00:09 PM UTC+10, Ján Dolinský wrote:

 Hello,

 I cloned the master branch of Julia Studio and compiled it. I am
 however getting this error when running ./JuliaStudio :
 libExtensionSystem.so.1: cannot open shared object file: No such file
 or directory

 however when running using ./julia-studio.sh it runs but fails to open
 a console with the following errors:
 Error: Failed to start Julia.
 Expected location: /usr/local/Julia_Studio/julia

 I am little bit lost here but exploring the Julia Studio menu I assume
 that it doe not provide debugging capability (I had an impression that it
 does).

 Thanks,
 Jan


 Dňa piatok, 19. septembra 2014 11:57:47 UTC+2 Uwe Fechner napísal(-a):
>
> I think that this branch is already merged into the master branch:
> https://github.com/forio/julia-studio/tree/julia-0.3-compatibility
>
> On Friday, September 19, 2014 11:54:41 AM UTC+2, Uwe Fechner wrote:
>>
>> If you compile Julia Studio from source it should work with Julia
>> 0.3. See:
>> https://github.com/forio/julia-studio/issues/241
>>
>> Regards:
>>
>> Uwe
>>
>> On Friday, September 19, 2014 10:58:26 AM UTC+2, Ján Dolinský wrote:
>>>
>>> Hello guys,
>>>
>>> After upgrading to Julia 0.3.0 Julia Studio stopped working (I
>>> changed the symbolic links in Julia Studio directory but nevertheless 
>>> ...).
>>> Can somebody suggest any workaround ? Is it true that Julia Studio will 
>>> not
>>> support newer versions of Julia ?
>>> What are you guys using now ?
>>>
>>> Thanks a lot,
>>> Jan
>>>
>>


Re: [julia-users] Legend for layers with specified colors in Gadfly

2014-09-28 Thread Leah Hanson
It don't know if you'll like it better, but here's another way to get the
same effect using Gadfly. The `Scale.discrete_color_manual` controls the
colors used by the scale.

~~~
using Gadfly, DataFrames

# populate the data in the format from your example
x1 = [1:10]; y1=[12:21]
x2 = [1:10]; y2 = [30:-1:21]

# make a 3 column DataFrame (x,y,line); maybe not the best way to make a
DataFrame, but it works.
df = DataFrame(Dict((:x,:y,:line),([x1,x2],[y1,y2],[["Line 1" for
i=1:10],["Line 2" for i=1:10]])))

# plot the DataFrame
plot(df,x=:x,y=:y,color=:line,Scale.discrete_color_manual("red","purple"),Geom.line,Guide.colorkey("Legend
title"))
~~~

-- Leah

On Sun, Sep 28, 2014 at 4:52 PM, Tomas Lycken 
wrote:

> The only way I’ve figured out to have two layers with different-color
> lines and a legend is to do something like this:
>
> plot(
> layer(
> x = x1,
> y = y1,
> color = ["Line 1" for i in 1:length(x1)],
> Geom.path,
> ),
> layer(
> x = x2,
> y = y2,
> color = ["Line 2" for i in 1:length(x2)],
> Geom.path
> ),
>
> Guide.colorkey("Legend title"),
> )
>
> This works in that it gives me a legend with the text I want, but it
> doesn’t give me any way to control the color of the lines - I usually do it
> with a Theme(default_color=color("red")) or similar, but since I’ve given
> each datapoint a color value (which isn’t really a color) that doesn’t have
> any effect.
>
> Is there any way I can get a layered plot, where each layer has its own
> legend entry, and at the same time control the color of the plot elements
> in each layer?
>
> // T
> ​
>


Re: [julia-users] Re: Pretty Printing of Results

2014-09-24 Thread Leah Hanson
Hey Don,

Have you considered putting your CoefTable function in a Julia package
somewhere?

I'm not sure whether there's an existing one that would be appropriate, but
this looks like a useful bit of code that could go in a library.

-- Leah

On Wed, Sep 24, 2014 at 7:49 PM, Donald Lacombe  wrote:

> Jason,
>
> I think you may have saved my sanity! Here is the output:
>
> In  [22]: temp = CoefTable(mat,colnms,rownms)
>
> Out [22]:  a b c
> a1 2 3
> b4 5 6
> c7 8 9
>
>
> In  [23]: show(temp)
>  a b c
> a1 2 3
> b4 5 6
> c7 8 9
>
> These actually line up perfectly in my Sublime Editor so I think I'm fine.
> I also did the following as a more realistic example:
>
> In  [30]: show(temp)
>Posterior Mean Lower 95% Upper 95%
> Income  -0.451334   1.60543  -1.05135
> Education 1.80312  0.382321  -2.06968
> Price-0.58198  -1.53586  0.569491
>
> Again, it lines up perfectly in my Sublime window. I think all I will have
> to do is to omit the p-value code and it should work fine with my spatial
> models.
>
> Thank you again for answering my basic questions and this should make my
> code much nicer.
>
> Regards,
> Don
>
> On Wednesday, September 24, 2014 8:22:23 PM UTC-4, Jason wrote:
>>
>> In  [11]: show(CoefTable)
>>>
>>> Out [11]: ERROR: `show` has no method matching show(::Type{CoefTable})
>>> you may have intended to import Base.show
>>> while loading In[11], in expression starting on line 1
>>>
>>>
>>> In  [12]: import Base.show
>>>
>>> Warning: import of Base.show into Main conflicts with an existing
>>> identifier; ignored.
>>>
>>
>>  Don,
>>
>> You need to import Base.show *before* defining the
>> show(::Type{CoefTable}) that I'm assuming you copied from the link I sent
>> earlier. Try doing it that way and let us know how it goes.
>>
>> If you'd like to read more check out http://docs.julialang.org/
>> en/latest/manual/modules/
>>
>


Re: [julia-users] Strange vector operation

2014-09-24 Thread Leah Hanson
No comment on the rest, but the element-wise division operator is `./`,
which does work:

~~~
julia> x1 = [1.0, 1, 1];

julia> 1.0 ./ x1
3-element Array{Float64,1}:
 1.0
 1.0
 1.0
~~~

-- Leah

On Wed, Sep 24, 2014 at 5:17 PM, Hans W Borchers 
wrote:

> I have been updated to version 0.4 though I seem to remember it was said
> the
> PPA archive will not move to 0.4 before a stable prerelease has been
> reached.
>
> Now I get the following strange behavior in vector operations:
>
> julia> x1 = [1.0, 1, 1]; x2 = [1:3];
>
> julia> x1 / x2
> 3x3 Array{Float64,2}:
>  0.0714286  0.142857  0.214286
>  0.0714286  0.142857  0.214286
>  0.0714286  0.142857  0.214286
>
> I believe to remember this led to an error in 0.3 -- am I totally wrong
> here?
> At the same time  1.0 / x1  does throw an error though it should work as
> elementwise division (at least so says the manual).
>
> julia> 1.0 / x1
> ERROR: `/` has no method matching /(::Float64, ::Array{Float64,1})
>
> And while we are at it, please remove this irritating behavior a.s.a.p.
> (Yes, I know what happens, `x1*0.2`, it's still not tolerable):
>
> julia> x1.2
> 3-element Array{Float64,1}:
>  0.2
>  0.2
>  0.2
>
> Even in the state of a chaotic transformation (from 03 to 0.4). please let
> your casual users not stand out in the cold.
>
> Difficult to imagine that anything would reach Mars following such laws.
> (Sorry for the pun.)
>


Re: [julia-users] Re: windows 7: cut&paste, window width&position, etc

2014-09-23 Thread Leah Hanson
The display of Julia REPL colors is controlled by the settings of the
terminal; Julia says "this text is blue" and the terminal/command prompt
decides what that means. I know you can change the terminal color
preferences on Linux; I don't know how to do that on Windows.

-- Leah

On Tue, Sep 23, 2014 at 8:38 AM, Johan Sigfrids 
wrote:

> The first three questions aren't related to Julia REPL specifically. On
> Windows when you launch Julia it runs in a command prompt window, so all
> the normal command prompt stuff applies: you change setting by going to
> Properties in the drop down menu of the icon in the upper right, and you
> copy by going into mark mode (via right-click) and select something and
> click enter.
>
> Colors I don't know how to change but I agree they are terrible.
>
> On Tuesday, September 23, 2014 4:21:21 PM UTC+3, Ben Arthur wrote:
>>
>> normally i use mac or linux, but am now having to use windows as well,
>> and have the following questions:
>>
>> 1. i can make the julia repl window taller, but not wider.  is the latter
>> possible?
>>
>> 2. i can paste into the julia repl, but not copy anything from it.
>>  again, possible?
>>
>> 3. is there any way on windows to get it to remember the last
>> size/position of the window?
>>
>> 4. on my monitor, the shade of blue used by info() is difficult to read
>> against the black background.  is there a way to change it without having
>> to compile julia?
>>
>> thanks.
>>
>


Re: [julia-users] Re: a good IDE for Julia ? (Julia Studio does not work with Julia v 0.3.0)

2014-09-19 Thread Leah Hanson
When I've wanted a Julia IDE, I've used LightTable with the Julia plugin. I
liked it when I used it, and there's been active development since then.

LightTable: http://www.lighttable.com/
Julia plugin: https://github.com/one-more-minute/Juno-LT


On Fri, Sep 19, 2014 at 6:25 AM, Ján Dolinský 
wrote:

> Thanks a lot for the tip. I'll compile from the source then.
>
> Regards,
> Jan
>
> Dňa piatok, 19. septembra 2014 11:57:47 UTC+2 Uwe Fechner napísal(-a):
>
>> I think that this branch is already merged into the master branch:
>> https://github.com/forio/julia-studio/tree/julia-0.3-compatibility
>>
>> On Friday, September 19, 2014 11:54:41 AM UTC+2, Uwe Fechner wrote:
>>>
>>> If you compile Julia Studio from source it should work with Julia 0.3.
>>> See:
>>> https://github.com/forio/julia-studio/issues/241
>>>
>>> Regards:
>>>
>>> Uwe
>>>
>>> On Friday, September 19, 2014 10:58:26 AM UTC+2, Ján Dolinský wrote:

 Hello guys,

 After upgrading to Julia 0.3.0 Julia Studio stopped working (I changed
 the symbolic links in Julia Studio directory but nevertheless ...). Can
 somebody suggest any workaround ? Is it true that Julia Studio will not
 support newer versions of Julia ?
 What are you guys using now ?

 Thanks a lot,
 Jan

>>>


Re: [julia-users] Example of how to write line by line to a CSV file in Julia?

2014-09-16 Thread Leah Hanson
Is this what you're looking for?

~~~
julia> csvfile = open("ysavetuple.csv","w")
IOStream()

julia> write(csvfile,"ColName A, ColName B, ColName C\n")
32

julia> foo(i) = tuple(rand(Int,3)...)
foo (generic function with 1 method)

julia> for i = 1:20
 y1,y2,y3 = foo(i)
 ysavetuple = y1, y2, y3
 write(csvfile, join(ysavetuple,","), "\n")
   end

julia> close(csvfile)

shell> cat ysavetuple.csv
ColName A, ColName B, ColName C
3341065172693628568,2785375663699326345,3139303717694603190
6079317564046002747,-9078602496166771942,316842938125726587
-3417130537836373451,-2125006311387038993,7377203727928183519
8358027301276313215,-550007455247301253,4550810412861259284
6923216407498203989,-6554142179327706075,-7691369716492508716
-1686152429396775777,8749188497040439214,-7530985225065041867
-1703823086470161742,8611509687251940012,4568676596067050636
5799892753953213008,3071911357874547504,-5404969669875969538
-2454300728611454039,6075726156412295188,-2730595046142414415
-4745225085034107111,6326943245021453770,-1335744683672406184
-8241065834050575249,9081437527204936820,-5382908887176747766
380946841985672,8705023102801762616,-7272701245961853612
8636161548674726627,5531655905953625247,-2539551872166338494
-1075777440989646159,1220494169889323606,3141159378055978579
2137393503615038568,-1785476893677818827,-411925966250929747
-5315012022696729804,858923725586425906,-7987423971277696135
3115970830776320266,6147819354500740390,-9153883089584687671
-5801765622147987138,-6846434057707600414,-850327360071980009
-4113725585379526907,5602712312389731368,2811295763696425064
-1191524940193068432,-3389508986455397789,2511100231858228670
~~~

-- Leah

On Tue, Sep 16, 2014 at 3:52 PM,  wrote:

> Hi Guys,
>
> I'm struggling to find some examples regarding how to write line by line
> to a CSV file. Scouring the documentation, I have been able to come across
> this so far:
> http://julia-cn.readthedocs.org/en/latest/stdlib/base/?highlight=writecsv
> So I currently have a function that is part of a for loop that outputs
> some data in each iteration.
> In pseudocode, here is what I want to do:
>
> for i in 1:2000
> y1,y2,y3 = f(i)
> ysavetuple = y1,y2,y3
> writecsv("ysavetuple.csv",ysavetuple)
>
> However, I am not sure how to go about saving line by line, separating the
> tuple into individual cells under labeled column headers.
>
> Any guidance would be appreciated.
>
> Thanks,
> Wally
>


Re: [julia-users] Re: Module Includes Problem

2014-09-16 Thread Leah Hanson
Great! I'm glad it works. :)

As Ivar said, you should keep in mind the difference between `require` and
`include`. Defaulting to using `include` inside module definitions should
avoid this kind of problem in the future.

On Mon, Sep 15, 2014 at 3:35 PM, Ivar Nesje  wrote:

> If dirlist.jl declares a module, you might have to use the full name
> `YourModule.dirlist`.  Another potential gotcha is that require() only will
> load the file once, and when you're inside a module definition you might
> want to include() the file so that it will be loaded multiple times in the
> same session, or define a package you can be `using` instead.
>



On Tue, Sep 16, 2014 at 8:50 AM, RecentConvert  wrote:

> include("O:\\Code\\Julia\\dirlist.jl") does ineed work
>
> dirlist.jl does not call or define any modules
>


Re: [julia-users] Re: Module Includes Problem

2014-09-16 Thread Leah Hanson
1) Have you tried changing the `require("dirlist.jl")` inside module
Aerodyne to `include("dirlist.jl")`? If so, what happened?

2) If that didn't work, does dirlist.jl define any modules?

-- Leah

On Tue, Sep 16, 2014 at 4:46 AM, RecentConvert  wrote:

> My .juliarc.jl file has three sections: the first adds any paths to
> LOAD_PATH, the second loads common modules including the Aerodyne one I am
> having issues with, and the final one is a list of requires of common
> functions I use including dirlist.jl. Aerodyne does call it earlier as a
> require when it is loaded as well.
>
> # 3 methods for generic function "dirlist":
> dirlist() at O:\Code\Julia\dirlist.jl:11
> dirlist(directory::ASCIIString) at O:\Code\Julia\dirlist.jl:32
> dirlist(directories::Array{ASCIIString,1}) at O:\Code\Julia\dirlist.jl:36
>


Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-09-15 Thread Leah Hanson
The @doc macro lets you do things that the doc_str can't:

1) Attach to the following method/function/etc. The string just sits there;
the macro can do the work to put the string into the documentation. (the
doc_str wouldn't be able to see the context around the string it's parsing)
2) Add a metadata dictionary after the doc string.
3) Allow other formats of documentation string (rst, asciidoc, whatever) as
long as the implement some interface of functions (likely some writemime
methods). Something like `@doc rst" ...rst formatted text"`, where using
`doc" text"` would remove the possibility of format tagging via rst_str.

-- Leah

On Mon, Sep 15, 2014 at 12:37 PM, Gray Calhoun  wrote:

> I should add that I'm excited to try out the package as is and
> successfully document my functions.
>
>
> On Monday, September 15, 2014 12:36:03 PM UTC-5, Gray Calhoun wrote:
>>
>> Just to engage in some bikeshedding is @doc better than defining
>> doc_str or d_str? The triple quote notation seems like an unnecessary
>> pythonism. doc_str gives:
>>
>> doc"
>> Markdown formatted text goes here...
>> " ->
>> function myfunc(x, y)
>> x + y
>> end
>>
>>
>>
>> On Monday, September 15, 2014 10:02:49 AM UTC-5, Michael Hatherly wrote:
>>
>>> *Readability of @doc:*
>>>
>>> I think that this probably just comes down to personal preference for me
>>> - I’ve not done an extensive comparison between different syntax.
>>>
>>> @doc introduces a docstring and seems pretty straightforward to me. It
>>> explicitly states that what follows is documentation. That example from
>>> Docile.jl could probably do with some simplifications since that metadata
>>> section looks terrible if I’m honest. Something like the following might
>>> be
>>> better as an initial example:
>>>
>>> module PackageName
>>>
>>> using Docile
>>> @docstrings # must appear before any `@doc` calls
>>>
>>> @doc """
>>>
>>> Markdown formatted text goes here...
>>>
>>> """ ->
>>> function myfunc(x, y)
>>> x + y
>>> end
>>>
>>> end
>>>
>>> And then leave introducing metadata until after this since I’ve found
>>> metadata to not be needed for every docstring I write.
>>>
>>> I’m not sure about the “clearly visible bounded block” though, what in
>>> particular could be clearer? I’m asking since I’ve been staring at these
>>> for a while now and have become quite accustomed to them.
>>>
>>


Re: [julia-users] Copy a BigFloat?

2014-09-13 Thread Leah Hanson
Do you mean independent for the purposes of editing, or just specifically
for the equality operators?

copy and deepcopy both work for editing purposes:
~~~
julia> a=with_bigfloat_precision(()->BigFloat("0.1"),64)
1.0001e-01 with 64 bits of precision

julia> z=copy(a)
1.0001e-01 with 64 bits of precision

julia> z += 2
2.100013552527156068805425093160010874271392822265625e+00
with 256 bits of precision

julia> a
1.0001e-01 with 64 bits of precision

julia> z
2.100013552527156068805425093160010874271392822265625e+00
with 256 bits of precision

julia> z=deepcopy(a)
1.0001e-01 with 64 bits of precision

julia> z += 2
2.100013552527156068805425093160010874271392822265625e+00
with 256 bits of precision

julia> a
1.0001e-01 with 64 bits of precision
~~~

I believe that BigFloats, like other numeric values types, are immutable.
This means that you can't tell the difference between instances of the same
value using `==` or even `===`. Every time there is a change a or z, it
acts as if it is just changing the binding to point to a new BigFloat [vs.
modifying the current value]. (I am not sure of the specific implementation
details of BigFloat at this time.)

On Sat, Sep 13, 2014 at 6:56 PM, Rick Graham  wrote:

> Might be a silly question, but how do you copy a BigFloat so that it is
> independent of the original?
>
>
> julia> a=with_bigfloat_precision(()->BigFloat("0.1"),64)
> 1.0001e-01 with 64 bits of precision
>
>
> julia> z=copy(a)
> 1.0001e-01 with 64 bits of precision
>
>
> julia> a.d==z.d
> true
>
>
> julia> z=deepcopy(a)
> 1.0001e-01 with 64 bits of precision
>
>
> julia> a.d==z.d
> true
>
>
>
>


Re: [julia-users] Re: Benchmark julia is 10x slower than fortran. Should I be happy?

2014-09-13 Thread Leah Hanson
Lint.jl is also good for checking that, depending on how much time you want
to spend learning to read the output of code_typed.

On Sat, Sep 13, 2014 at 3:27 PM, Elliot Saba  wrote:

> A good way to track down performance issues like this is to use
> @code_typed to output the typed code in your function and look for places
> where type inference doesn't know what to do; e.g. large type unions, Any
> types, etc  This is often caused by a variable taking on multiple
> separate types over its lifetime within the function and can cause
> slowdowns inside inner loops.
> -E
>
> On Sat, Sep 13, 2014 at 1:13 PM, Noah Brenowitz  wrote:
>
>> now i am pretty impressed.
>>
>> On Saturday, September 13, 2014 4:12:07 PM UTC-4, Noah Brenowitz wrote:
>>>
>>> I just replaced u = u0, with u = complex128(u0) in the julia code. Now
>>> it is only 2x as slow as fortran.
>>>
>>
>


Re: [julia-users] Re: dispatch based on expression head

2014-09-13 Thread Leah Hanson
I would expect the Expr type to be abstract, with different concrete
subtypes for each current value of head. Each value of head indicates a
specific structure in args, and this can just be reflected in the
definition of the subtypes. (Then you can dispatch on Expr type, use
"subtypes(Expr)" to see all possible kinds of Expr, etc.)

-- Leah

On Sat, Sep 13, 2014 at 10:47 AM, Jake Bolewski 
wrote:

> We've actually discussed changing our expression representation to use
>>> types instead of the more lisp-like symbols for distinguishing expression
>>> types. That would allow dispatch on expression types and be more compact.
>>> It would, however, break almost all macros that do any kind of expression
>>> inspection.
>>>
>>
> Hmm, interesting.  I guess the Expr type would then be Expr{:head} with
> getindex / setindex overloaded to manipulate the arguments?  This would be
> a nice change as for many nodes you would not have to allocate an args
> array which could be a performance win (i guess the serialized ast's would
> be more compact as well).  Can't comment on whether it would be enough of a
> win to justify such a massively breaking change.
>
>
>> On Sat, Sep 13, 2014 at 2:48 AM, Gray Calhoun 
>>> wrote:
>>>
 On Wednesday, September 10, 2014 11:50:44 AM UTC-5, Steven G. Johnson
 wrote:
>
> On Wednesday, September 10, 2014 12:20:59 PM UTC-4, Gray Calhoun
> wrote:
>>
>> Are there better ways to do this in general?
>>
>
> For this kind of expression-matching code, you may find the Match.jl
> package handy (https://github.com/kmsquire/Match.jl), to get ML- or
> Scala-like symbolic pattern-matching.
>

 Thanks, that's pretty cool. For simple cases like I'm using, do you
 know if there are advantages (or disadvantages) to using Match.jl, or
 should I just view it as a nicer syntax? (Obviously, when things get more
 complicated Match.jl looks very appealing).

>>>
>>>


Re: [julia-users] Re: Image acquisition

2014-09-12 Thread Leah Hanson
I just wanted to say that I copied the code from Simon's gist, and once I
had all the packages installed, it was really exciting to see video from
the webcam via Julia. :)

-- Leah

On Fri, Sep 12, 2014 at 12:19 PM, Simon Danisch  wrote:

> GStreamer has some shaders for the conversion:
>
> http://cgit.freedesktop.org/gstreamer/gst-plugins-gl/tree/gst-libs/gst/gl/gstgldownload.czz
> So I'd say we're not very far away from this goal, as the rest is already
> on the GPU ;)
>
> Am Montag, 8. September 2014 18:06:45 UTC+2 schrieb Miguel Belbut Gaspar:
>>
>> Hi,
>>
>> Has anyone found a way to do image acquisition (from a webcam or some
>> kind of digital camera) directly in Julia? Or should we communicate
>> directly with some library/dll to achieve that?
>>
>> Miguel
>>
>


Re: [julia-users] how to push!(::DataFrame,::DataFrameRow) or append!(::DataFrame,::DataFrameRow) ?

2014-09-12 Thread Leah Hanson
Oh, I didn't realize that. So, `eachrow(df)` is giving you
`[(:a,"hi"),(:x,0.703943)]` when you need `["hi",0.703943]` to use `push!`.

~~~
julia> df = DataFrame(a=["hi","there"],x = rand(2))
2x2 DataFrame
|---|-|--|
| Row # | a   | x|
| 1 | "hi"| 0.703943 |
| 2 | "there" | 0.269876 |

julia> df2 = DataFrame(a=["oh","yeah"],x = rand(2))
2x2 DataFrame
|---||--|
| Row # | a  | x|
| 1 | "oh"   | 0.138966 |
| 2 | "yeah" | 0.856162 |

julia> for e = eachrow(df)
 push!(df2,[v for (_,v) in e])
   end

julia> df2
4x2 DataFrame
|---|-|--|
| Row # | a   | x|
| 1 | "oh"| 0.138966 |
| 2 | "yeah"  | 0.856162 |
| 3 | "hi"| 0.703943 |
| 4 | "there" | 0.269876 |
~~~

Does this work for you?

-- Leah

On Fri, Sep 12, 2014 at 8:54 AM, Florian Oswald 
wrote:

> yeah I wasn't very clear in that example. i really need to append one row
> at a time.
>
> On 12 September 2014 14:50, Leah Hanson  wrote:
>
>> Have you tried append!(df2,df)?
>>
>> ~~~
>> julia> using DataFrames
>>
>>
>>
>> julia> df = DataFrame(a=["hi","there"],x = rand(2))
>>
>>
>> 2x2 DataFrame
>> |---|-|--|
>> | Row # | a   | x|
>> | 1 | "hi"| 0.862957 |
>> | 2 | "there" | 0.101378 |
>>
>>
>>
>> julia> df2 = DataFrame(a=["oh","yeah"],x = rand(2))
>>
>>
>> 2x2 DataFrame
>> |---|||
>> | Row # | a  | x  |
>> | 1 | "oh"   | 0.00803615 |
>> | 2 | "yeah" | 0.0222873  |
>>
>>
>>
>> julia> append!(df2,df)
>>
>>
>> 4x2 DataFrame
>> |---|-||
>> | Row # | a   | x  |
>> | 1 | "oh"| 0.00803615 |
>> | 2 | "yeah"  | 0.0222873  |
>> | 3 | "hi"| 0.862957   |
>> | 4 | "there" | 0.101378   |
>> ~~~
>>
>>
>>
>> On Fri, Sep 12, 2014 at 7:57 AM, Florian Oswald > > wrote:
>>
>>> i'm trying to do this:
>>>
>>> using DataFrames
>>> df = DataFrame(a=["hi","there"],x = rand(2))
>>> df2 = DataFrame(a=["oh","yeah"],x = rand(2))
>>>
>>> for e in eachrow(df)
>>> append!(df2,e)
>>> end
>>>
>>> ERROR: `append!` has no method matching append!(::DataFrame,
>>> ::DataFrameRow{DataFrame})
>>> in anonymous at no file:2
>>>
>>> or
>>>
>>> julia> for i in 1:nrow(df)
>>> push!(df2,df[i,:])
>>> end
>>>
>>> but that errors as well.
>>>
>>> this works:
>>>
>>> julia> for i in 1:nrow(df)
>>> push!(df2,array(df[i,:]))
>>> end
>>>
>>> but wondering whether that's the best way of achieving this efficiently.
>>>
>>
>>
>


Re: [julia-users] how to push!(::DataFrame,::DataFrameRow) or append!(::DataFrame,::DataFrameRow) ?

2014-09-12 Thread Leah Hanson
Have you tried append!(df2,df)?

~~~
julia> using DataFrames



julia> df = DataFrame(a=["hi","there"],x = rand(2))


2x2 DataFrame
|---|-|--|
| Row # | a   | x|
| 1 | "hi"| 0.862957 |
| 2 | "there" | 0.101378 |



julia> df2 = DataFrame(a=["oh","yeah"],x = rand(2))


2x2 DataFrame
|---|||
| Row # | a  | x  |
| 1 | "oh"   | 0.00803615 |
| 2 | "yeah" | 0.0222873  |



julia> append!(df2,df)


4x2 DataFrame
|---|-||
| Row # | a   | x  |
| 1 | "oh"| 0.00803615 |
| 2 | "yeah"  | 0.0222873  |
| 3 | "hi"| 0.862957   |
| 4 | "there" | 0.101378   |
~~~



On Fri, Sep 12, 2014 at 7:57 AM, Florian Oswald 
wrote:

> i'm trying to do this:
>
> using DataFrames
> df = DataFrame(a=["hi","there"],x = rand(2))
> df2 = DataFrame(a=["oh","yeah"],x = rand(2))
>
> for e in eachrow(df)
> append!(df2,e)
> end
>
> ERROR: `append!` has no method matching append!(::DataFrame,
> ::DataFrameRow{DataFrame})
> in anonymous at no file:2
>
> or
>
> julia> for i in 1:nrow(df)
> push!(df2,df[i,:])
> end
>
> but that errors as well.
>
> this works:
>
> julia> for i in 1:nrow(df)
> push!(df2,array(df[i,:]))
> end
>
> but wondering whether that's the best way of achieving this efficiently.
>


Re: [julia-users] Help needed with creating Julia package

2014-09-11 Thread Leah Hanson
Does your Nemo.jl contain

~~~
module Nemo

end
~~~

?

On Thu, Sep 11, 2014 at 5:56 PM, Bill Hart 
wrote:

> OK, I can build Nemo. But how do I load modules from Nemo now that it is
> installed and built.
>
> For example "using Nemo", "using Rings", "using Fields" all fail,
> complaining that it can't find the modules.
>
> I must be missing a step somewhere.
>
> Bill.
>
> On 12 September 2014 00:47, Bill Hart  wrote:
>
>> It's ok, I got it. Pkg.build()
>>
>> Bill.
>>
>> On 12 September 2014 00:38, Bill Hart 
>> wrote:
>>
>>> I had a go at making a preliminary package which should vaguely build on
>>> Linux when "using Nemo" is run from within the src/ directory.
>>>
>>> I checked this works on my machine at least.
>>>
>>> I also checked that Pkg.clone("https://github.com/wbhart/nemo.git";)
>>> clones the Nemo repository from within Julia. But this seems to only clone
>>> the repository and doesn't appear to issue "using Nemo" as I had expected.
>>>
>>> Also typing "using Nemo" manually says that it can't find Nemo. What
>>> command to users have to issue to get "using Nemo" to actually do something?
>>>
>>> Bill.
>>>
>>>
>>>
>>> On 10 September 2014 16:26, Isaiah Norton 
>>> wrote:
>>>

 This was what I thought of trying first. But I couldn't figure out how
> it worked out what GitHub repository to associate this with, or whether it
> would try to create one, possibly scrubbing my existing nemo repository on
> GitHub. Obviously I don't want to lose my commit history.


 For Pkg manager purposes, the association will be created later (when
 you register the package).

 It also isn't clear where Julia creates the empty git repository. In
> the current directory? Or in some subdirectory of the Julia source tree?


 Under `$HOME/.julia/v0.3` (or v0.4 if you are on git master)

 For the most part I can just run configure, make, make install for now
> and set some library paths (if I can figure out what kind of system I am
> on).


 There are some macros to help with this: @osx, @linux, @unix (both),
 and @windows. There is also a variable called OS_NAME with a
 platform-specific value (:Windows, :Linux, etc.) See:

 http://docs.julialang.org/en/release-0.3/manual/calling-c-and-fortran-code/#handling-platform-variations



 On Wed, Sep 10, 2014 at 10:18 AM, Bill Hart <
 goodwillh...@googlemail.com> wrote:

>
>
> On Wednesday, 10 September 2014 15:57:56 UTC+2, Isaiah wrote:
>>
>> Is there documentation somewhere explaining how to do the latter? Or
>>> can someone help me with doing the latter?
>>
>>
>> You could run `Pkg.generate("Nemo")` and then copy and commit (some
>> of) the resulting files in your own Nemo git tree; there aren't very 
>> many.
>>
>
> This was what I thought of trying first. But I couldn't figure out how
> it worked out what GitHub repository to associate this with, or whether it
> would try to create one, possibly scrubbing my existing nemo repository on
> GitHub. Obviously I don't want to lose my commit history.
>
> It also isn't clear where Julia creates the empty git repository. In
> the current directory? Or in some subdirectory of the Julia source tree?
>
>
>> I can't find any documentation explaining where to put the commands
>>> in a Pkg to actually git clone flint, build it, install it and set up 
>>> paths
>>> for Nemo. Given the complexities of installing flint for the user, I'd 
>>> like
>>> to have the Julia package manager do this automatically if at all 
>>> possible.
>>> And I see it does seem to be possible. I just can't figure out how.
>>>
>>
>> The Pkg manager will look for a file called `MYPKG/deps/build.jl` and
>> run that if it exists. That's just a Julia file, so you can do whatever 
>> you
>> want there (shell out, etc.).
>>
>
> Perfect. For the most part I can just run configure, make, make
> install for now and set some library paths (if I can figure out what kind
> of system I am on).
>
> Finding the Julia installation on the system in order to link against
> the gmp/mpfr might be slightly more difficult.
>
>
>> One option is to use the BinDeps package which provides primitives
>> for interacting with various package managers and build systems:
>>
>> https://github.com/JuliaLang/BinDeps.jl
>>
>> A very advanced and fully-developed usage example can be found in the
>> Cairo package, which has Autotools, Apt, Yum, and several other targets:
>>
>> https://github.com/JuliaLang/Cairo.jl/blob/master/deps/build.jl
>>
>> There are a number of other examples to draw from. Hopefully the
>> above links will give you a sense of where to start. I can help out on
>> Linux and Windows (@ihnorton on github).
>>
>
>

Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-09-11 Thread Leah Hanson
Oh, I missed that. That's totally the approach I would take, and I don't
really see it as a problem to use a separate channel to document the
documentation functions/macros. It seems like a messiness related more to
bootstrapping (documenting using the system you're writing) rather than a
design problem.

I guess the need to document @doc goes away if it become the keyword doc,
since you would need some separate way to document keywords (if you were
going to do that) anyway.

-- Leah

On Thu, Sep 11, 2014 at 4:58 PM, Michael Hatherly  wrote:

> I'm doing it using an internal macro `@docref` [1] to track the line
> number and then in `src/doc.jl` I store the documentation in `__METADATA__`
> along with the line and source file found using `@docref`. A bit hacky, but
> it's only for a couple of docs.
>
> [1]
> https://github.com/MichaelHatherly/Docile.jl/blob/c82675d4a39932d1d378e954844018cefc091858/src/Docile.jl#L14-L17
>


Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-09-11 Thread Leah Hanson
Could you manually add the `@doc` documentation to the _METDATA_ object?
The macro edits a variable, which you should be able to do outside the
macro as well, right?

-- Leah

On Thu, Sep 11, 2014 at 4:28 PM, Michael Hatherly  wrote:

> I am committed to continuing work on this, though other work can limit the
> amount of time I have. There's still some rough edges, and I'm not sure how
> to overcome some difficulties such as `@doc` not being able to document
> itself.
>
> -- Mike
>


Re: [julia-users] Re: What wrong , help ;0

2014-09-11 Thread Leah Hanson
do you have a variable named p2?

On Thu, Sep 11, 2014 at 3:12 PM, Paul Analyst  wrote:

>  julia> efy
> 4x1 Array{Int64,2}:
>   1
>   7
>   8
>  10
>
> W dniu 2014-09-11 o 20:27, Jake Bolewski pisze:
>
> what is efy?  Your example is not reproducible.
>
> On Thursday, September 11, 2014 2:22:31 PM UTC-4, paul analyst wrote:
>>
>> julia> i
>> 2
>> julia> pp=[];
>> julia> target=25;
>> julia> for i in efy;
>>var_name = symbol("p" * string(i));
>>pp=vcat(pp,@eval $var_name[1:target]);
>>#println(sum(@eval $var_name[1:target]))
>>end;
>> ERROR: p2 not defined
>>  in anonymous at no file:3
>>
>> julia>
>>
>> Paul
>>
>
>


Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-09-11 Thread Leah Hanson
If I understand correctly, Docile.jl is a macro-based implementation of
SGJ's suggestion, right? So if we're in agreement about non-comment-based
documentation, we could start using that now, and later switch from "@doc"
to the keyword "doc" when it's implemented.

Are any packages documented with Docile? That would be a good illustration
of how well this works.

-- Leah

On Thu, Sep 11, 2014 at 3:10 PM, Jason  wrote:

> Why is begin...end better than """""" ?
>>
>
> For block documentation they are equivalent, but the triple quotes are
> heavy for lots of single line comments. Eg: look at the average comment
> length of this randomly chosen Haskell source file
> 
> .
>
> But in the end, it's just bikeshedding over style at this point. It looks
> like most of us are in agreement about:
>
>1. Coupling the documentation to the AST
>2. Documentation being markup agnostic/flexible
>
> Now it's just a matter of syntax. Which ironically can sometimes derail
> entire language features for years at a time. Eg: better record syntax
>  in Haskell has been in
> the need of the right syntax (although semantics are a hangup there as
> well) for many years.
>
> Perhaps we need a temporary BDFL
>  for Julia to
> just make an arbitrary (good) decision and get us all into the glorious
> days of documented packages.
>


Re: [julia-users] Help needed with creating Julia package

2014-09-10 Thread Leah Hanson
1) You can try looking at other packages to see the structure.

Code goes is `src/` (and you'll need a `Nemo.jl` in there that will be what
Julia runs when you say `using Nemo`). Tests go in the `tests` folder; you
should have a file `runtests.jl` in there that runs the tests for your
package (if you want Julia's auto-testing stuff to work).

A file named REQUIRE is where any dependencies on other Julia go; it is
also where you specify compatible versions of Julia. Every package has one
of these, so you can look at them for examples to see the syntax. You
probably want a line like `julia 0.3-` if you believe you package works for
0.3 and will work for 0.4, but not in 0.2.

Like most OSS projects: license in LICENSE.md, some documentation in
README.md. (*.md means a plain text Markdown file; there's flexibility on
plain text format/filename here; these are just what's made by default by
`Pkg.generate`).

This is enough for people to get your package installed via the Julia
package manager by running `Pkg.clone("https://github.com/wbhart/nemo";)`.

Since Pkg.clone will put you package in the "right" place (i.e. where all
your other Julia packages are installed), you'll be able to follow the
normal package publishing (register with METADATA) instructions.

2) https://github.com/JuliaLang/BinDeps.jl is the package for installing
binary dependencies.

You should also search this mailing list for past BinDeps questions, as
there have been a number of them. Looking at other packages that use
BinDeps can also be very helpful; Cairo.jl is an example, but anything that
wraps C libraries would probably be helpful.

Best,
Leah



On Wed, Sep 10, 2014 at 8:31 AM, Bill Hart 
wrote:

> Hi,
>
> I have been writing a new Julia package, which I have called Nemo (it's
> essentially a limited computer algebra system).
>
> I have two specific problems:
>
> 1) The git and GitHub repository for Nemo already exists, but I haven't
> created a Julia Pkg yet.
>
> https://github.com/wbhart/nemo
>
> The documentation on creating a Julia Pkg seems to assume you are going to
> start with the Pkg then commit code to the git repository that it creates,
> not create a git/github project and then add the necessary stuff to turn it
> into a Julia package.
>
> Is there documentation somewhere explaining how to do the latter? Or can
> someone help me with doing the latter?
>
> (I have a couple of small build issues to fix in order for flint to work
> on Windows 64 before it will work there. But I will be working on those
> right away. I have managed to get it to work with Julia there, just not
> hacked the fixes into the flint build system yet. Other than this minor
> thing, I am quite ready to publish Nemo as a package right away (well,
> apart from a horrible 3x slowdown and excessive memory usage caused by gc,
> but I think I've given up on solving that problem for now).)
>
> 2) Nemo relies on mpir (or GMP), mpfr and flint, which are large external
> C/assembly libraries which need to get built or be available to run Nemo. I
> understand Julia has its own GMP and MPFR which I can probably link to if
> they are recent enough.
>
> Flint needs to be built when the package is installed. It takes a long
> time to build, e.g. 40 minutes or so on Windows, maybe a third of that on
> Linux.
>
> I can't find any documentation explaining where to put the commands in a
> Pkg to actually git clone flint, build it, install it and set up paths for
> Nemo. Given the complexities of installing flint for the user, I'd like to
> have the Julia package manager do this automatically if at all possible.
> And I see it does seem to be possible. I just can't figure out how.
>
> Flint is here:
>
> https://github.com/wbhart/flint2
>
> Can anyone help, or point me in the right direction?
>
> Bill.
>


Re: [julia-users] Passing an expression to a macro

2014-09-09 Thread Leah Hanson
So, currently, your @my macro is evaluating the arguments in the macro
context (vs. returning them to be evaluated in the calling context.

~~~
julia> macro my2(exp)
 quote
 for i in $exp.args
 println("the arg is ", i)
 end
  end
   end

julia> @my2 e
the arg is  # none, line 2:
the arg is a = 2
the arg is  # line 3:
the arg is b = 3
~~~

Note that I'm returning a quote block from the macro, and passing in `e`,
not `:e` when I call it. Your macro is only working at it is because the
macro context and the calling context are the same (in the REPL).

Have you seen the macroexpand function? It's often very useful when
debugging macros.

~~~
julia> macroexpand(quote @my2 e end)
quote  # none, line 1:
begin  # none, line 3:
for #168#i = e.args # line 4:
println("the arg is ",#168#i)
end
end
end

julia> macroexpand(quote @my :e end)
the arg is begin  # none, line 2:
a = 2 # line 3:
b = 3
end
quote  # none, line 1:
nothing
end
~~~

-- Leah


On Tue, Sep 9, 2014 at 11:42 AM,  wrote:

> Just puzzling over this simple problem I'm having while learning about
> macros. Here's an expression:
>
> julia> e = quote
>a = 2
>b  = 3
>end
>
> quote  # none, line 2:
> a = 2 # line 3:
> b = 3
> end
>
>
> If I go through this simply, I'll get a crack at each element of the args
> array:
>
>
>
> julia> for i in e.args
>println("the arg is ", i)
>end
>
>
>
> the arg is  # none, line 2:
> the arg is a = 2
> the arg is  # line 3:
> the arg is b = 3
>
>
> If I try to write a macro:
>
>
> julia> macro my(exp)
>   for i in exp.args
>   println("the arg is ", eval(i))
>   end
>   end
>
> and call it like this:
>
>
> julia> @my :e
> the arg is begin  # none, line 2:
> a = 2 # line 3:
> b = 3
> end
>
>
> it does all the elements at once.
>
> It's probably a simple thing, but I could do with a hint!
>
> cheers
>
>


Re: [julia-users] Re: Adding Julia package to METADATA.jl

2014-09-05 Thread Leah Hanson
If you run `Pkg.register("YourPkgName")` at the Julia REPL, it will
generate that folder for you (complete with the commit hashes).

Does that work for you?


On Fri, Sep 5, 2014 at 9:06 AM, Samuel S. Watson 
wrote:

> OK, that's a fair point. What I should have said is that my interpretation
> of what he said wasn't the right thing to do. It hinges on what stuff is
> supposed to be added to the directory. I had assumed it was the package
> stuff, and in fact it's supposed to be a directory containing some version
> information and a url. I can see why my original interpretation doesn't
> make sense. Nevertheless, it seems to me that the step of
> finding/generating this package metadata directory is nontrivial (e.g., it
> includes some long alphanumeric string). Can someone fill me in?
>
> On Friday, September 5, 2014 9:39:45 AM UTC-4, Jacob Quinn wrote:
>>
>> "wasn't the right thing to do"...
>>
>> I don't think I'd say that. It's essentially what Pkg.publish() is doing
>> underneath anyway (or tries to do). The steps he listed are actually how I
>> bump packages all the time, since I've had troubles with Pkg.publish() as
>> well.
>>
>> -Jacob
>>
>>
>> On Fri, Sep 5, 2014 at 9:36 AM, Samuel S. Watson 
>> wrote:
>>
>>> For the record, I tried Mauro's suggestion, and it worked but it wasn't
>>> the right thing to do. And the step where I'm stuck is Pkg.publish(), not
>>> Pkg.register(). That's the one that the documentation says often breaks,
>>> and it also doesn't take any arguments, which makes me think it's going to
>>> publish all my registered packages, which I'm not ready to do.
>>>


>>


[julia-users] Reading sideways CSV file into a DataFrame

2014-09-03 Thread Leah Hanson
So, assuming you have a CSV file that looks like this:

~~~
Column One,2,3,4
Column Two,2,5,7
Column Three,1,9,8
~~~

But each line has a lot more numbers in it. I would like to read it into a
DataFrame, where the DataFrame would understand it as:

~~~
Column One, Column Two, Column Three
2,2,1
3,5,9
4,7,8
~~~

Is the best thing just to edit the file first into a normal format, or is
there some option I can pass into DataFrames to make it understand? (I did
not see one on the I/O page of the DataFrames docs, but that can be out of
date sometimes.)

[I realize this is an unusual thing to want. I expect to just edit the file
to be in the right order, but I wanted to check to see if DataFrames
already handles this.]

Thanks,
Leah


Re: [julia-users] trouble after updating Julia

2014-09-03 Thread Leah Hanson
Hey Andrea,

You didn't do anything wrong. I think there's a bug in the Makefile that
makes things sometimes break, which is unfortunate.

-- Leah


On Wed, Sep 3, 2014 at 10:06 AM, Andrea Vigliotti <
andrea.viglio...@gmail.com> wrote:

> Hi all,
>
> I could compile Julia correctly again after
>
> make -C deps distclean-llvm
>
>
>
> (following an advice taken from the link posted by Kevin :
> https://github.com/JuliaLang/julia/issues/8200)
>
> but that meant I had to recompile the whole thing. I had also to 'make
> clean', after the first attempt,
>
> I was just wondering if there is anything I did wrong that put me in the
> situation of having to compile everything or every now and than, that
> cannot be avoided...
>
> thanks for your help and advices,
>
> andrea
>
>
> On Monday, September 1, 2014 9:36:43 AM UTC+1, Kevin Squire wrote:
>
>> See https://github.com/JuliaLang/julia/issues/8200.
>>
>>
>> On Sun, Aug 31, 2014 at 7:45 PM, Dan Luu  wrote:
>>
>>> I'm also having problems, and I wonder if I've run into the same issue.
>>>
>>> When I updated Julia today on my Mac (10.9.2), I got the following error:
>>>
>>> /bin/sh: line 1: 23089 Segmentation fault: 11
>>> /Users/danluu/dev/julia/usr/bin/julia --build
>>> /Users/danluu/dev/julia/usr/lib/julia/sys
>>> -J/Users/danluu/dev/julia/usr/lib/julia/$([ -e
>>> /Users/danluu/dev/julia/usr/lib/julia/sys.ji ] && echo sys.ji || echo
>>> sys0.ji) -f sysimg.jl
>>> * This error is usually fixed by running 'make clean'. If the error
>>> persists, try 'make cleanall'. *
>>> make[1]: * [/Users/danluu/dev/julia/usr/lib/julia/sys.o] Error 1
>>> make: * [release] Error 2
>>>
>>> I've tried doing make cleanall, and even wiping out my repository and
>>> re-cloning in case it's a problem with deps, and I still get the same
>>> error.
>>>
>>> On Linux (64-bit, 3.2.0-65-generic), the build doesn't error out, but
>>> Julia segfaults on startup. The gdb backtrace for that is:
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x76e2328c in jl_deserialize_gv (v=0x7bb138, s=0x7fffdcc0)
>>> at dump.c:145
>>> 145 *sysimg_gvars[gvname_index] = v;
>>> (gdb) bt
>>> #0  0x76e2328c in jl_deserialize_gv (v=0x7bb138,
>>> s=0x7fffdcc0) at dump.c:145
>>> #1  jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:854
>>> #2  0x76e233e5 in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #3  jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:937
>>> #4  0x76e2350d in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #5  jl_deserialize_datatype (pos=403560, s=0x7fffdcc0) at dump.c:646
>>> #6  jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:886
>>> #7  0x76e22818 in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #8  jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:715
>>> ...
>>> #134 jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:715
>>> #135 0x76e233e5 in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #136 jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:937
>>> #137 0x76e233e5 in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #138 jl_deserialize_value_internal (s=0x7fffdcc0) at dump.c:937
>>> #139 0x76e23881 in jl_deserialize_value (s=0x7fffdcc0) at
>>> dump.c:950
>>> #140 jl_restore_system_image (fname=) at dump.c:1060
>>> #141 0x76e1f33b in julia_init (
>>> imageFile=0x608e60
>>> "/home/dluu/dev/julia/usr/bin/../lib/julia/sys.ji") at init.c:826
>>> #142 0x0040140a in main (argc=0, argv=0x7fffe1c0) at
>>> repl.c:378
>>>
>>>
>>>
>>> On Sun, Aug 31, 2014 at 8:39 AM, Andrea Vigliotti
>>>  wrote:
>>> > Hi all!
>>> >
>>> >
>>> > I am having problems in updating Julia from the git. As usual, every
>>> three
>>> > four days I download the last updates from the git and
>>> > compile them, this is what I do (I'm running ubuntu with KDE, and
>>> Julia is
>>> > v0.4) from the source directory I typed
>>> >
>>> > git pull && make
>>> >
>>> >
>>> >
>>> > then I got this
>>> >
>>> > ...
>>> > ...
>>> > ...
>>> > iterator.jl
>>> > inference.jl
>>> > ERROR:
>>> > LoadError("/usr/local/julia/v0.4/base/sysimg.jl",65,
>>> LoadError("inference.jl",134,UndefVarError(:sizeof)))
>>> >  in include at ./boot.jl:245 (repeats 2 times)
>>> >  in include_from_node1 at loading.jl:128
>>> >  in process_options at ./client.jl:285
>>> >  in _start at ./client.jl:354
>>> >  in _start_3B_13569 at /usr/local/julia/v0.4/usr/lib/julia/sys.so
>>> >
>>> > *** This error is usually fixed by running 'make clean'. If the error
>>> > persists, try 'make cleanall'. ***
>>> > make[1]: *** [/usr/local/julia/v0.4/usr/lib/julia/sys.o] Error 1
>>> > make: *** [release] Error 2
>>> >
>>> >
>>> > after doing the make cleanall, tried make again and got
>>> >
>>> > ...
>>> > ...
>>> > ...
>>> >  /usr/bin/install -c -m 644 '_U_dyn_register.man'
>>> > '/usr/local/julia/v0.4/usr/share/man/man3/_U_

Re: [julia-users] List of useful macros for beginners?

2014-08-31 Thread Leah Hanson
@show and @which are two other common ones. There are examples of how to
use them in this blog post: http://www.juliabloggers.com/julia-helps/ (<- I
wrote this blog post.)

Are you looking for examples of macros you would want to use or examples of
macros to help you write your own macros?

-- Leah


On Sun, Aug 31, 2014 at 8:47 AM, Xiaowei Zhang 
wrote:

> For example, the Julia manual illustrates the usage of @inbound and @simd
> as performance tips. Can anyone provide a short list of macros with
> examples besides these two?
>


Re: [julia-users] Julia for general scripting and automation?

2014-08-29 Thread Leah Hanson
I really like Julia's API for starting/controlling subprocesses better than
the ones I've used in Python. (This is purely personal opinion, and is like
skewed by having a better understanding of what I was doing when I used
Julia.) Both of them can do the same things, so it's mostly a matter of
which API you prefer.

The relevant manual section:
http://docs.julialang.org/en/release-0.3/manual/running-external-programs/
A blog post I wrote:
http://blog.leahhanson.us/running-shell-commands-from-julia.html

The manual section talks more about Cmd objects (semantics, construction);
my blog post mostly gives examples of calling functions on Cmds (or calling
related functions). Neither of these resources is long; if you read both of
them, you should have a pretty fair idea of what you can do from Julia and
whether it has the capabilities you'll need for your specific use-cases.

-- Leah


On Fri, Aug 29, 2014 at 1:29 PM, Kevin Squire 
wrote:

> As far as capabilities are concerned, they should be pretty similar,
> although Julia hasn't been used as much for those things, and do likely
> still has some usage and bug issues lurking.
>
> One thing you'll probably find is that Julia's startup time might be a bit
> slow if you need anything beyond what's in Base. Precompiled modules are
> coming, but right now, modules are compiled on load.
>
> Other questions to ask yourself are who else will need to maintain things,
> and how willing you are to test and report bugs, usage issues, or
> documentation improvements.
>
> Julia is great for a lot of things, but is a lot younger than python, and
> so likely won't work as well out of the box.
>
> Just my opinions, others may differ.
>
> Cheers!
> Kevin
>
>
> On Friday, August 29, 2014, Ariel Katz  wrote:
>
>> Hi Everyone,
>>
>> Is there any effective differential  between  Julia and Python's
>> capabilities(subprocess module etc) and ease of use for general task
>> scripting and automation in windows and unix?
>>
>> Is there any reason one would be more suitable than the other?
>>
>> Thanks and have a great weekend!
>>
>> Ari
>>
>


Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-08-28 Thread Leah Hanson
Yes, that's it. I've partially written a custom generator for it in the
past; plugging into the API was pretty easy, the hard part was
understanding some of the internal type-representation data structures that
it exposed. The API exposes the AST to the plugin, which allows the plugin
to be more powerful than just a list of comments. Like Go, OCaml uses a
separate tool for building documentation; however, this is not the cool
part that I wanted to point out. The interesting idea to me was that it
exposes the AST and metadata to any interested OCaml plugin, and that it
was pretty straight-forward to get a basic plugin working.

It's important to me that there's an API for accessing the metadata &
associated AST in a way that allows for more creative displays (i.e.
Haskell's fancy type-aware search engine Hoogle
<http://www.haskell.org/hoogle/> (built using Haddock) or some other
visualization or fancy IDE integration). This would also be an API that a
package for building documentation websites/manuals could use.

I like Steven Johnson's proposal, and I think it already allows/has this --
since you can look up the metadata for a Function/Method/Module/etc, and
you can already get those within Julia (all functions/etc in a Module,
etc), this should "just work".

(I was initially expecting a comment-base approach, which I've seen work
well in languages where I've used it (OCaml, Java) with a notation
(@author, etc) for metadata embedded in comments. However, I think Julia
has much cooler things it can do with special string parsers (md"") and
writemime, and the flexibility of documentation format should really
benefit from that. A potential oddness is that we might end up with
"dependencies only for documentation" the way we have dependencies only for
testing, since you might have a package that defines your special
documentation string, but isn't otherwise used in your code.)


On Wed, Aug 27, 2014 at 5:09 PM, John Myles White 
wrote:

> Is it this system, Leah?
> http://caml.inria.fr/pub/docs/manual-ocaml-400/manual029.html
>
>  -- John
>
>
> On Aug 27, 2014, at 3:06 PM, Leah Hanson  wrote:
>
> I like OCaml's approach, which uses comments above functions/etc, and has
> a neat plugin system to output them in various formats.
>
> On Wednesday, August 27, 2014, John Myles White 
> wrote:
>
>> Ok, thanks for clarifying. I also like the idea of strategically placed
>> comments as automatic documentation.
>>
>>  -- John
>>
>> On Aug 27, 2014, at 2:54 PM, Job van der Zwan 
>> wrote:
>>
>> Right, that's what I meant with GoDoc being a separate tool: Go is
>> statically compiled and does not have something like a REPL or runtime
>> evaluation, so being a separate tool is only logical. In that sense it's
>> not a comparable situation.
>>
>> The comments-as-documentation and the conventions used to make it work
>> might still be worth looking into.
>>
>> I personally feel that from the point of view of people using Julia it's
>> a better option than introducing docstrings - comments are already the
>> source-level form of documentation-for-humans after all. Introducing
>> docstrings feels like creating two different options for the same role,
>> except one is ignored by tools and the other isn't. That just *feels*
>> unelegant to me (not the strongest argument, I know), and I worry that code
>> with both would become visually more noisy.
>>
>> I just googled for possible reasons for having both docstrings and
>> comments, and the only argument I found is that one describes the *what*
>> and the other a *how*. GoDoc only counts comments above the
>> package/variable/function definition as documentation, and ignoring
>> comments inside a function body or struct definition. Since the former
>> typically documents the *what* and the latter the *how* anyway, that
>> distinction automatically emerges through convention.
>>
>> Of course, if "not discarding comments during compilation" would require
>> a major overhaul to the compiler and docstrings are technically much easier
>> to introduce I can understand if that option is more appealing - a less
>> elegant feasible solution is better than an inelegant infeasable one. And
>> perhaps there are other arguments in favour of having both docstrings and
>> comments that I'm not aware of?
>>
>> On Tuesday, 26 August 2014 17:34:24 UTC+2, Stefan Karpinski wrote:
>>>
>>> To clarify – I meant that I like the style of GoDoc, not the fact that
>>> you run the tool as a separate pass. That doesn't strike me as completely
>>> out of the que

Re: [julia-users] Does Julia have something similar to Python's documentation string?

2014-08-27 Thread Leah Hanson
I like OCaml's approach, which uses comments above functions/etc, and has a
neat plugin system to output them in various formats.

On Wednesday, August 27, 2014, John Myles White 
wrote:

> Ok, thanks for clarifying. I also like the idea of strategically placed
> comments as automatic documentation.
>
>  -- John
>
> On Aug 27, 2014, at 2:54 PM, Job van der Zwan  > wrote:
>
> Right, that's what I meant with GoDoc being a separate tool: Go is
> statically compiled and does not have something like a REPL or runtime
> evaluation, so being a separate tool is only logical. In that sense it's
> not a comparable situation.
>
> The comments-as-documentation and the conventions used to make it work
> might still be worth looking into.
>
> I personally feel that from the point of view of people using Julia it's a
> better option than introducing docstrings - comments are already the
> source-level form of documentation-for-humans after all. Introducing
> docstrings feels like creating two different options for the same role,
> except one is ignored by tools and the other isn't. That just *feels*
> unelegant to me (not the strongest argument, I know), and I worry that code
> with both would become visually more noisy.
>
> I just googled for possible reasons for having both docstrings and
> comments, and the only argument I found is that one describes the *what*
> and the other a *how*. GoDoc only counts comments above the
> package/variable/function definition as documentation, and ignoring
> comments inside a function body or struct definition. Since the former
> typically documents the *what* and the latter the *how* anyway, that
> distinction automatically emerges through convention.
>
> Of course, if "not discarding comments during compilation" would require a
> major overhaul to the compiler and docstrings are technically much easier
> to introduce I can understand if that option is more appealing - a less
> elegant feasible solution is better than an inelegant infeasable one. And
> perhaps there are other arguments in favour of having both docstrings and
> comments that I'm not aware of?
>
> On Tuesday, 26 August 2014 17:34:24 UTC+2, Stefan Karpinski wrote:
>>
>> To clarify – I meant that I like the style of GoDoc, not the fact that
>> you run the tool as a separate pass. That doesn't strike me as completely
>> out of the question, but wouldn't be optimal.
>>
>>
>> On Tue, Aug 26, 2014 at 11:32 AM, John Myles White 
>> wrote:
>>
>>> No, I was talking about what I understood to be a design principle of
>>> GoDoc: doc generation and parsing occurs at doc-gen time, not at run-time.
>>>
>>> Yes, you would have to make comments non-ignorable to get this to work.
>>>
>>>  — John
>>>
>>> On Aug 26, 2014, at 12:44 AM, Job van der Zwan 
>>> wrote:
>>>
>>> On Tuesday, 26 August 2014 00:04:41 UTC+2, John Myles White wrote:

 The issue is that you want to have all code documentation show up in
 REPL. In the GoDoc approach, this might require an explicit "build" step --
 which is a non-trivial cost in usability.

  -- John

>>>
>>> I assume you talking about GoDoc as a tool?
>>>
>>> In case you are referring to comments as the source of documentation
>>> instead of docstrings: I assume comments are now simply discarded during
>>> compilation, making it impossible to use them for documentation, but if
>>> that could be changed they should be just as valid as the format for
>>> documentation, right?
>>>
>>>
>>>
>>
>


Re: [julia-users] Re: How to require the current master of pacakge

2014-08-19 Thread Leah Hanson
That should work. :)

-- Leah


On Tue, Aug 19, 2014 at 12:28 PM, Spencer Lyon 
wrote:

> That's what I thought. I'm happy to do that
>
> To do this I just need to do
>
> `Pkg.tag("PDMats")`
>
> Then push that commit to my fork of METADATA and submit a PR, right?
>
>
> On Tuesday, August 19, 2014 10:13:06 AM UTC-7, Spencer Lyon wrote:
>>
>> Is there a way to specify that a package depends on the current master
>> branch of another package.
>>
>> My problem is the following:
>>
>>- I am developing a package that samples from the MultivariateNormal
>>distribution in Distributions.jl.
>>- This pacakge calls unwhiten! from PDMats.jl.
>>- unwhiten! tries to access the uplo field of the Cholesky type in
>>base/lingalg/cholesky.jl
>>- The way this field is accessed was recently changed an PDMats.jl
>>just updated the unwhiten! method 2 days ago (https://github.com/
>>JuliaStats/PDMats.jl/commit/53cb7f5a182755e141bed5fb1c9c683d1283d304
>>
>> 
>>)
>>
>> I would like to make my package require the current master branch of
>> PDMats.jl. I know I can do this manually via Pkg.checkout("PDMats"), but
>> I don’t want to force users to do this.
>>
>> In the REQUIRE file can I specify that I need to “checkout” PDMats?
>> ​
>>
>


Re: [julia-users] Multiple dispatch issue: cat() and a custom abstract array

2014-08-04 Thread Leah Hanson
Have you tried `import Base.cat` or naming your methods `function
Base.cat(...`?

The first example on this page of the manual, specifically the `Base.show`
part, is relevant:
http://docs.julialang.org/en/release-0.2/manual/modules/?highlight=import

-- Leah


On Mon, Aug 4, 2014 at 3:10 PM, Michael Grant  wrote:

> Consider the following class hierarchy:
>
> module CVX
> immutable Scalar{T<:Number}
> abstract AbstractArray{T,N} <: Base.AbstractArray{Scalar{T},N}
> type Array{T,N} <: AbstractArray{T,N}
>
> Note in particular that CVX.Array{T,N} is an abstract array of Scalar{T}
> objects. For performance reasons, it is distinctly advantageous to avoid
> constructing Base.Array{Scalar{T},N} objects, so I'm overloading the
> various array manipulation operators to handle CVX.Array specially.
>
> But now consider cat(). What I would *like *to do is this:
>
> function cat( d::Integer, X::Union(Number,CVX.Scalar)... )
> function cat( d::Integer, X::Union(Number,CVX.Scalar,CVX.AbstractArray,
> Base.AbstractArray)... )
>
> The goal here is to override cat() for the case when there is at least one
> CVX object present. The problem here, of course, is that this overrides the
> catchall cat function, even if there are no CVX objects present:
>
> function cat( d::Integer, X::Any... )
>
> Is there an easy resolution to this problem? One solution is for Julia, or
> me, to define
>
> function cat( d::Integer, X::Union(Number,Base.AbstractArray)... )
> function cat( d::Integer, X::Number... )
>
> If I do it, I'd be reimplementing  the generic method, in the first case
> at least, unless there is a way for me to link these new declarations
> directly to the existing implementations. Is there?
>
>


Re: [julia-users] Re: Gadfly histogram woes

2014-08-03 Thread Leah Hanson
What version of Gadfly are you using? (You can find out using `Pkg.status`.)
You could try running `Pkg.update` to see if you can get a newer version.

If this isn't fixed by getting a newer version, then this is clearly a bug
and you should file an issue on Github here:
https://github.com/dcjones/Gadfly.jl/issues

-- Leah

On Sun, Aug 3, 2014 at 7:59 PM, Dave Kleinschmidt <
dave.f.kleinschm...@gmail.com> wrote:

> I know; it's the first plot in the NB (using Geom.histogram) that is the
> problem, not the second (which I included to show that _some_ Gadfly plots
> were produced as expected).  Apologies if that was unclear.
>
> Also, for what it's worth, this was using Julia 0.2.  Under 0.3-rc1 the
> histograms work just fine.  But I'm still puzzled why it wasn't working
> under 0.2...
>
> Dave
>
>
> On Sunday, August 3, 2014 8:45:23 PM UTC-4, j verzani wrote:
>>
>> Use `Geom.histogram` not `Geom.point`, as in your notebook.
>>
>> On Saturday, August 2, 2014 10:38:13 PM UTC-4, Dave Kleinschmidt wrote:
>>>
>>> Hi all,
>>>
>>> I'm a complete beginner with Julia, so perhaps I'm missing something
>>> obvious, but I'm not able to produce histograms with Gadfly.  I thought at
>>> first I was using it wrong but even the example from the docs
>>>  doesn't work
>>> for me.  Here's a notebook that shows what I get (same thing with writing
>>> the plot to a PNG file): http://nbviewer.ipython.org/gist/kleinschmidt/
>>> 46998cf74fd8f066485e
>>> 
>>>
>>> Any ideas?
>>>
>>> Thanks,
>>> Dave
>>>
>>


Re: [julia-users] Best way to eliminate parameters from a parametric type

2014-08-02 Thread Leah Hanson
T{P1,P2,P3} is a family of types; each member specifies all three type
parameters. There are no "super type" relationships within the family of T
types; they are just all members of the same family (think "set") of types.

Could you explain what you're trying to achieve? I don't think that making
a type with only 2 of it's three parameters defined makes sense, so maybe
we can find another way to achieve the same goal.

-- Leah


On Sat, Aug 2, 2014 at 6:37 AM, Jutho  wrote:

> Suppose I have some type T{P1,P2,P3} depending some parameters. I don't
> know which type exactly, except that it originates from a type hierarchy
> which has 3 parameters. What is the best way to construct, given e.g. a
> variable of type T{P1,P2,P3} with specific values for P1, P2, P3, to
> construct the 'super' type T{P1,P2}. If TT = T{Float64,Float64,Float64}
> then I know I could do  TT.parameters = (TT.parameters[1],
> TT.parameters[2], TypeVar(P3) ). But it turns out that is not yet
> completely identical to T{Float64,Float64}, although TT==T{Float64,Float64}
> and TT===T{Float64,Float64} evaluate to true. However, not all fields of TT
> seem to be identical to those of T{Float64,Float64}. What is the
> recommended strategy ? Is there a specific method for doing this?
>
>


Re: [julia-users] Counting instances from an array that fulfill some inequality statements

2014-07-30 Thread Leah Hanson
Your problem is with the first index (`i == 1`). You can't check if the
previous element is < 0. You could adjust your range (the
`1:length(outputarray)`) to only run through elements for which your
if-condition makes sense.

-- Leah


On Wed, Jul 30, 2014 at 5:12 PM,  wrote:

> I'm a bit stuck on this one. Could I get one more hint about a way I could
> get the same thing done without using the illegal indexing?
>
> On Wednesday, July 30, 2014 5:46:58 PM UTC-4, John Myles White wrote:
>
>> Yeah, it’s the combination of (a) the use of i and i+1 indexing with (b)
>> the use of a loop that goes from i = 1 to i = length(outputarray).
>>
>>  — John
>>
>>
>> On Jul 30, 2014, at 2:44 PM, yaois...@gmail.com wrote:
>>
>> To correct the bug, is it this?
>>
>> if outputarray[i] < 0 && outputarray[i+1] >= 0
>> count += 1
>> end
>>
>> Factoring in that Julia begins indexing from 1.
>>
>> On Wednesday, July 30, 2014 4:41:43 PM UTC-4, John Myles White wrote:
>>>
>>> This pseudocode almost works. Just replace Int64[1:len(outputarray)]
>>> with 1:length(outputarray).
>>>
>>> There’s also a bug in your core logic, but I’ll leave fixing that as an
>>> exercise to the reader.
>>>
>>>  — John
>>>
>>> On Jul 30, 2014, at 1:03 PM, yaois...@gmail.com wrote:
>>>
>>> Hi guys,
>>>
>>> I asked this in a previous thread, but because that diverged off-topic
>>> from my existing question, I decided to create a new thread.
>>>
>>> Anyhow, say I have an array
>>>
>>> outputarray = Float64[-1.23423,-3.23423,-2.34234,-2.12342,1.23234,2.
>>> 23423,-2.23432,5.2341,0.0,1.23423]
>>>
>>> This array lists the output of some function. I want to count the number
>>> of times that the function passes by or equals 0 while emerging from a
>>> negative f(x).
>>>
>>> In pseudocode, I want to do:
>>>
>>> function counter(outputarray)
>>> count = 0
>>> for i in Int64[1:len(outputarray)]
>>> if outputarray[i] >= 0 && outputarray[i-1] < 0
>>> count += 1
>>> end
>>> end
>>> return count
>>> end
>>>
>>> What would be the most efficient way of doing this in Julia?
>>>
>>> Thanks,
>>> Wally
>>>
>>>
>>>
>>


Re: [julia-users] [newb] confused about constructors

2014-07-30 Thread Leah Hanson
I think this is what you want:
~~~
type FIR{in_t, coef_t}
   in::Vector{in_t}
   coef::Vector{coef_t}
   FIR(in::Vector{in_t}, coef::Vector{coef_t}) = new(zeros(in_t,
size (in)), coef)
   end
~~~

In your defition of the inner constructor, you end with `x.coef = coef_`,
which returns `coef_`, which is a Vector{Float64}`. Instead, you want to
`return x`.

Your constructor has access to the default constructor, through `new`,
which takes the value for each property in order (so, `new(in, coef)`).
Additionally, the underscores aren't necessary; in C++, you need to add
them to make it clear you don't mean the class properties; in Julia, you
never have the class properties available without scoping them (`x.in`), so
this is not a problem.

Best,
Leah


On Wed, Jul 30, 2014 at 10:00 AM, Neal Becker  wrote:

> As a learning exercise, I am trying to code a simple FIR filter.
> As a start, it has 2 fields and a constructor:
>
> type FIR{in_t, coef_t}
> in::Vector{in_t}
> coef::Vector{coef_t}
> FIR (in_::Vector{in_t}, coef_::Vector{coef_t}) = (x=new(); x.in =
> zeros(in_t, size (in_)); x.coef = coef_;)
> end
>
> w = zeros (Float64, 10)
> f = FIR{Float64,Float64}(w,w)
>
> This code executes, but seems very confused:
> julia> typeof(f)
> Array{Float64,1}
>
> Huh?  I expected "f" to be of type FIR{Float64,Float64}.  Clearly I'm doing
> something very wrong.
>
>


Re: [julia-users] a function for calling functions inside module

2014-07-29 Thread Leah Hanson
In general, you should avoid using `eval`. Is there a reason you don't want
to pass in a function and make it `func::Function` in your type?

Your `eval` inside module `Bar` is evaluating the code inside the scope of
`Bar`, which is what's causing your problem.

-- Leah


On Tue, Jul 29, 2014 at 3:58 PM, g  wrote:

> I'm trying to write a small module that allows one to define a Step that
> describes operations on an HDF5 file.
>
> immutable Step
> func::String
> a_ins::(String...) #attribute inputs
> d_ins::(String...) #dataset inputs
> a_outs::(String...) #attribute outputs
> d_outs::(String...) #dataset outputs
> end
>
> The idea is to gather up the inputs specified by a_ins and d_ins, pass
> them to the function specified by func, and place the outputs in HDF5
> datasets and attributes as specified by a_outs and d_outs.  The issues I'm
> having is finding the correct function given that it is defined in some
> other Module.  A minimal example is given by
>
> module Bar
> bar(s::String, args...) = eval(parse(s))(args...)
> export bar
> end
> using Bar
> foo(s::String, args...) = eval(parse(s))(args...)
>
> baz(x...) = +(x...)
>
> baz(4,5,6)
> foo("baz",4,5,6)
> bar("baz",4,5,6) # ERROR: baz not defined
>
> One path I can see is that when I create the Step I could pass an actual
> function to the constructor.  If I knew how to access the fully qualified
> name of the function, I could record that instead of just the name.  I'm
> not sure if that is possible. Any ideas on how I should approach this?
>
> Also I probably shouldn't be using eval(parse(s)) since that opens up the
> opportunity for arbitrary code execution.
>


Re: [julia-users] Re: [Gadfly] How do I put layers inside a facet/subplot?

2014-07-28 Thread Leah Hanson
Is there a way to make the color scale separate for each subplot?

Since the lines only need to be distinguishable by color within a subplot,
I'd like to only use a small number of colors. My real plot has 4 subplots,
with 1-4 lines per subplot; this is a lot of different colors when each
line has it's own color, but only 4 colors when there's a different color
scheme per plot.

Additionally, if each subplot can have it's own color key, it would make it
easier to line up colors with meanings. The long list of color-name
mappings is hard to read, especially because it's not sorted by subplot.

Thanks,
Leah


On Sat, Jul 26, 2014 at 7:39 PM, Daniel Jones 
wrote:

>
> Unfortunately there's not an option to manually change those labels, so
> you'll have to change the "true"/"false" to some more informative string.
> There definitely should be an option to relabel those. I'll make a note to
> do that.
>
>
> On Friday, July 25, 2014 9:19:14 PM UTC-7, Leah Hanson wrote:
>
>> Thank you! That makes sense. I can add a new column to group by to put
>> sets of points on the right lines.
>>
>> So, now the y-axis is "value by isspeed" and "true" and "false". I can
>> change the "value by isspeed" part using Guide.ylabel("New Label"), but I'm
>> not sure how to make "true" and "false" into real labels. Do I need to put
>> strings into that column so that they'd automatically become the label, or
>> is there a way to set that as part of the call to plot?
>>
>> Thanks! :D
>> Leah
>>
>>
>> On Fri, Jul 25, 2014 at 7:03 PM, Daniel Jones 
>> wrote:
>>
>>>
>>> Hmm, tricky one. Maybe something like this:
>>>
>>> t_melted = melt(t, [:_type, :rank])
>>> t_melted[:isspeed] = t_melted[:variable] .== :speed
>>>
>>> plot(t_melted,
>>>  ygroup=:isspeed, x=:rank, y=:value, color=:variable,
>>>  Geom.subplot_grid(Geom.point, free_y_axis=true),
>>>  Scale.discrete_color_manual("purple", "orange"))
>>>
>>>
>>>
>>> On Friday, July 25, 2014 2:56:43 PM UTC-7, Leah Hanson wrote:
>>>
>>>> Yay! Thank you. That does make things a lot easier. I think I'm better
>>>> understanding how to use melt.
>>>>
>>>> However, now there's another plot I want to make. For one :_type, I
>>>> want to make two subplots (vertically stacked). The top one should have
>>>> :thing1 and :thing2 in different colors; the bottom one should have :speed.
>>>> (The :x is always :rank.)
>>>>
>>>> I tried melting it, but I'm not sure how to get two variables on one
>>>> plot and one on the other:
>>>> ~~~
>>>> julia> reds = t[t[:_type] .== "red",:]
>>>> 3x5 DataFrame
>>>> |---|---|--|---|||
>>>> | Row # | _type | rank | speed | thing1 | thing2 |
>>>> | 1 | "red" | 1| 10.0  | 0.0| 0.0|
>>>> | 2 | "red" | 2| 11.1  | 0.1| 0.2|
>>>> | 3 | "red" | 3| 12.4  | 0.3| 0.0|
>>>>
>>>> julia> m_reds = melt(reds,[:_type,:rank],[:speed,:thing1,:thing2])
>>>> 9x4 DataFrame
>>>> |---|--|---|---|--|
>>>> | Row # | variable | value | _type | rank |
>>>> | 1 | speed| 10.0  | "red" | 1|
>>>> | 2 | speed| 11.1  | "red" | 2|
>>>> | 3 | speed| 12.4  | "red" | 3|
>>>> | 4 | thing1   | 0.0   | "red" | 1|
>>>> | 5 | thing1   | 0.1   | "red" | 2|
>>>> | 6 | thing1   | 0.3   | "red" | 3|
>>>> | 7 | thing2   | 0.0   | "red" | 1|
>>>> | 8 | thing2   | 0.2   | "red" | 2|
>>>> | 9 | thing2   | 0.0   | "red" | 3|
>>>>
>>>> julia> plot(m_reds,
>>>> ygroup=:variable, x=:rank, y=:value, color=:variable,
>>>> Geom.subplot_grid(Geom.point))
>>>> ~~~
>>>>
>>>> Another problem is that I want :thing1 and :thing2 to be on one y-scale
>>>> and :speed to be on a different one. (The x-axis scale is the same for
>>>> both.) I don't want to set them each separately to a specific scale, just
>>>> let them each be separately determined 

Re: [julia-users] Creation of custom iterators.

2014-07-27 Thread Leah Hanson
You need to either `import Base.start` or implement a function named
`Base.start` instead of `start`. That change will make your `start`
function extend the one from Base with new methods, rather than being a
separate function that happens to be named `start`. (This is a super common
confusion.)

-- Leah


On Sun, Jul 27, 2014 at 2:40 PM, Ben Ward  wrote:

> I've given this a go but it does not quite work as expected:
>
> immutable DepthFirst
> tree::Phylogeny
> end
>
> function start(x::DepthFirst)
>   state = Stack(PhyNode)
>   push!(state, x.tree.Root)
>   return state
> end
>
> function next(x::DepthFirst, state)
>   current::PhyNode = pop!(state)
>   for i in current.Children
> push!(state, i)
>   end
>   return current, state
> end
>
> function done(x::DepthFirst, state)
>   return length(state) == 0 ? true : false
> end
>
> Then:
>
> *for i in DepthFirst(myTree)*
>
> *i*
>
> *end*
>
> results in:
>
> *ERROR: `start` has no method matching start(::DepthFirst)*
>
>
>
>
> * in anonymous at no file*
>
> I'm not sure why this is - I have a method defined start() for the
> utterable immutable DepthFirst trivial type. I'm clearly missing something
> here.
>
>
> On Sunday, July 27, 2014 7:58:09 PM UTC+1, Tim Holy wrote:
>>
>> Did you check out the examples I suggested? :)
>>
>> On Sunday, July 27, 2014 11:56:16 AM Ben Ward wrote:
>> > I had not considered this - so state variable is a complex type which
>> would
>> > have say the Queue/Stack and current value, and the start, next and
>> done
>> > methods update it?
>> >
>> > On Sunday, July 27, 2014 7:48:56 PM UTC+1, Tim Holy wrote:
>> > > Why can't you keep track of everything in the state variable, and
>> make
>> > > your
>> > > iterator-types trivial?
>> > >
>> > > --Tim
>> > >
>> > > On Sunday, July 27, 2014 11:07:36 AM Ben Ward wrote:
>> > > > My traverser types are not exactly wrappers quite a simple as they
>> > >
>> > > contain
>> > >
>> > > > FIFO and FILO structures that keep track of things - I struggle to
>> > >
>> > > imagine
>> > >
>> > > > how else to have them. Do the three iterate methods necessarily
>> need to
>> > > > have the second argument "state"? My types know they are done -
>> > > > hasReachedEnd() - because there are no more nodes to visit in their
>> > >
>> > > Ahead
>> > >
>> > > > Queue/Stack. So would a done() that only requires the type be
>> sufficient
>> > > > with no state input variable as in done(tier, state)?
>> > > >
>> > > > Best,
>> > > > Ben.
>> > > >
>> > > > On Sunday, July 27, 2014 4:49:24 PM UTC+1, Tim Holy wrote:
>> > > > > You can obtain different types of iteration simply by wrapping
>> "obj"
>> > >
>> > > in
>> > >
>> > > > > different thin-wrappers. For example, you can define
>> > > > >
>> > > > > immutable SomeOtherWayOfTraversing{T}
>> > > > >
>> > > > > obj::T
>> > > > >
>> > > > > end
>> > > > >
>> > > > > which is used as
>> > > > >
>> > > > > for x in SomeOtherWayOfTraversing(obj)
>> > > > >
>> > > > > # blah
>> > > > >
>> > > > > end
>> > > > >
>> > > > > and then write the specific start, next, done methods like this:
>> > > > >
>> > > > > start{T}(iter::SomeOtherWayOfTraversing{T})
>> > > > >
>> > > > > You can get totally different behavior this way from what would
>> happen
>> > > > > when you
>> > > > > just say "for x in obj...".
>> > > > >
>> > > > >
>> > > > > You might want to browse through more packages to see more
>> examples.
>> > > > > Here's
>> > >
>> > > > > one:
>> > > https://github.com/timholy/Grid.jl/blob/
>> 600cbcf645a73525fb6d563d5a148b9d8b
>> > >
>> > > > > 2668aa/src/counter.jl but many other packages (DataFrames, Gtk,
>> HDF5,
>> > >
>> > > etc)
>> > >
>> > > > > define iterators.
>> > > > >
>> > > > > --Tim
>> > > > >
>> > > > > On Sunday, July 27, 2014 06:41:43 AM Ben Ward wrote:
>> > > > > > I'm not nessecerily trying it iterate over the children of a
>> node.
>> > > > >
>> > > > > Rather I
>> > > > >
>> > > > > > have defined a series of types that facilitate traversing a
>> tree in
>> > > > >
>> > > > > various
>> > > > >
>> > > > > > ways for my Phylogenetics.jl package, for example by depth
>> first:
>> > > > > >
>> > > > > > type TraverserCore
>> > > > > >
>> > > > > >   Start::PhyNode
>> > > > > >   Behind::Stack
>> > > > > >   History::Array{PhyNode, 1}
>> > > > > >   Current::PhyNode
>> > > > > >
>> > > > > > end
>> > > > > >
>> > > > > >
>> > > > > > type DepthFirstTraverser <: TreeTraverser
>> > > > > >
>> > > > > >   Ahead::Stack
>> > > > > >   Core::TraverserCore
>> > > > > >   function DepthFirstTraverser(tree::Phylogeny)
>> > > > > >
>> > > > > > x = new(Stack(PhyNode), TraverserCore(tree.Root,
>> Stack(PhyNode),
>> > > > >
>> > > > > PhyNode
>> > > > >
>> > > > > > [], tree.Root))
>> > > > > >
>> > > > > > for i in x.Core.Current.Children
>> > > > > >
>> > > > > >   push!(x.Ahead, i)
>> > > > > >
>> > > > > > end
>> > > > > > return x
>> > > > > >
>> > > > > >   end
>> > > > > >
>> > > > > > end
>> > > > > >
>> > > >

Re: [julia-users] Re: [Gadfly] How do I put layers inside a facet/subplot?

2014-07-25 Thread Leah Hanson
Thank you! That makes sense. I can add a new column to group by to put sets
of points on the right lines.

So, now the y-axis is "value by isspeed" and "true" and "false". I can
change the "value by isspeed" part using Guide.ylabel("New Label"), but I'm
not sure how to make "true" and "false" into real labels. Do I need to put
strings into that column so that they'd automatically become the label, or
is there a way to set that as part of the call to plot?

Thanks! :D
Leah


On Fri, Jul 25, 2014 at 7:03 PM, Daniel Jones 
wrote:

>
> Hmm, tricky one. Maybe something like this:
>
> t_melted = melt(t, [:_type, :rank])
> t_melted[:isspeed] = t_melted[:variable] .== :speed
>
> plot(t_melted,
>  ygroup=:isspeed, x=:rank, y=:value, color=:variable,
>  Geom.subplot_grid(Geom.point, free_y_axis=true),
>  Scale.discrete_color_manual("purple", "orange"))
>
>
>
> On Friday, July 25, 2014 2:56:43 PM UTC-7, Leah Hanson wrote:
>
>> Yay! Thank you. That does make things a lot easier. I think I'm better
>> understanding how to use melt.
>>
>> However, now there's another plot I want to make. For one :_type, I want
>> to make two subplots (vertically stacked). The top one should have :thing1
>> and :thing2 in different colors; the bottom one should have :speed. (The :x
>> is always :rank.)
>>
>> I tried melting it, but I'm not sure how to get two variables on one plot
>> and one on the other:
>> ~~~
>> julia> reds = t[t[:_type] .== "red",:]
>> 3x5 DataFrame
>> |---|---|--|---|||
>> | Row # | _type | rank | speed | thing1 | thing2 |
>> | 1 | "red" | 1| 10.0  | 0.0| 0.0|
>> | 2 | "red" | 2| 11.1  | 0.1| 0.2|
>> | 3 | "red" | 3| 12.4  | 0.3| 0.0|
>>
>> julia> m_reds = melt(reds,[:_type,:rank],[:speed,:thing1,:thing2])
>> 9x4 DataFrame
>> |---|--|---|---|--|
>> | Row # | variable | value | _type | rank |
>> | 1 | speed| 10.0  | "red" | 1|
>> | 2 | speed| 11.1  | "red" | 2|
>> | 3 | speed| 12.4  | "red" | 3|
>> | 4 | thing1   | 0.0   | "red" | 1|
>> | 5 | thing1   | 0.1   | "red" | 2|
>> | 6 | thing1   | 0.3   | "red" | 3|
>> | 7 | thing2   | 0.0   | "red" | 1|
>> | 8 | thing2   | 0.2   | "red" | 2|
>> | 9 | thing2   | 0.0   | "red" | 3|
>>
>> julia> plot(m_reds,
>> ygroup=:variable, x=:rank, y=:value, color=:variable,
>> Geom.subplot_grid(Geom.point))
>> ~~~
>>
>> Another problem is that I want :thing1 and :thing2 to be on one y-scale
>> and :speed to be on a different one. (The x-axis scale is the same for
>> both.) I don't want to set them each separately to a specific scale, just
>> let them each be separately determined automatically.
>>
>> Thanks for your help,
>> Leah
>>
>>
>> On Fri, Jul 25, 2014 at 4:01 PM, Daniel Jones 
>> wrote:
>>
>>> Oh, I see. I think the easiest way would be to rearrange the data with
>>> the melt function.
>>>
>>>
>>> melt(t, [:_type, :rank, :speed]) makes a table like:
>>>
>>> |---|--|---|-|--|---|
>>> | Row # | variable | value | _type   | rank | speed |
>>> | 1 | thing1   | 0.0   | "red"   | 1| 10.0  |
>>> | 2 | thing1   | 0.1   | "red"   | 2| 11.1  |
>>> | 3 | thing1   | 0.3   | "red"   | 3| 12.4  |
>>> | 4 | thing1   | 0.2   | "green" | 1| 8.0   |
>>> | 5 | thing1   | 0.1   | "green" | 2| 7.0   |
>>> | 6 | thing1   | 0.2   | "green" | 3| 9.0   |
>>> | 7 | thing1   | 1.0   | "blue"  | 1| 1.0   |
>>> | 8 | thing1   | 0.2   | "blue"  | 2| 2.0   |
>>> | 9 | thing1   | 0.1   | "blue"  | 3| 3.0   |
>>> | 10| thing2   | 0.0   | "red"   | 1| 10.0  |
>>> | 11| thing2   | 0.2   | "red"   | 2| 11.1  |
>>> | 12| thing2   | 0.0   | "red"   | 3| 12.4  |
>>> | 13| thing2   | 1.0   | "green" | 1| 8.0   |
>>> | 14| thing2   | 0.5   | "green" | 2| 7.0   |
>>> | 15| thing2   | 0.0   | "green" | 3

Re: [julia-users] Re: [Gadfly] How do I put layers inside a facet/subplot?

2014-07-25 Thread Leah Hanson
Yay! Thank you. That does make things a lot easier. I think I'm better
understanding how to use melt.

However, now there's another plot I want to make. For one :_type, I want to
make two subplots (vertically stacked). The top one should have :thing1 and
:thing2 in different colors; the bottom one should have :speed. (The :x is
always :rank.)

I tried melting it, but I'm not sure how to get two variables on one plot
and one on the other:
~~~
julia> reds = t[t[:_type] .== "red",:]
3x5 DataFrame
|---|---|--|---|||
| Row # | _type | rank | speed | thing1 | thing2 |
| 1 | "red" | 1| 10.0  | 0.0| 0.0|
| 2 | "red" | 2| 11.1  | 0.1| 0.2|
| 3 | "red" | 3| 12.4  | 0.3| 0.0|

julia> m_reds = melt(reds,[:_type,:rank],[:speed,:thing1,:thing2])
9x4 DataFrame
|---|--|---|---|--|
| Row # | variable | value | _type | rank |
| 1 | speed| 10.0  | "red" | 1|
| 2 | speed| 11.1  | "red" | 2|
| 3 | speed| 12.4  | "red" | 3|
| 4 | thing1   | 0.0   | "red" | 1|
| 5 | thing1   | 0.1   | "red" | 2|
| 6 | thing1   | 0.3   | "red" | 3|
| 7 | thing2   | 0.0   | "red" | 1|
| 8 | thing2   | 0.2   | "red" | 2|
| 9 | thing2   | 0.0   | "red" | 3|

julia> plot(m_reds,
ygroup=:variable, x=:rank, y=:value, color=:variable,
Geom.subplot_grid(Geom.point))
~~~

Another problem is that I want :thing1 and :thing2 to be on one y-scale and
:speed to be on a different one. (The x-axis scale is the same for both.) I
don't want to set them each separately to a specific scale, just let them
each be separately determined automatically.

Thanks for your help,
Leah


On Fri, Jul 25, 2014 at 4:01 PM, Daniel Jones 
wrote:

> Oh, I see. I think the easiest way would be to rearrange the data with the
> melt function.
>
>
> melt(t, [:_type, :rank, :speed]) makes a table like:
>
> |---|--|---|-|--|---|
> | Row # | variable | value | _type   | rank | speed |
> | 1 | thing1   | 0.0   | "red"   | 1| 10.0  |
> | 2 | thing1   | 0.1   | "red"   | 2| 11.1  |
> | 3 | thing1   | 0.3   | "red"   | 3| 12.4  |
> | 4 | thing1   | 0.2   | "green" | 1| 8.0   |
> | 5 | thing1   | 0.1   | "green" | 2| 7.0   |
> | 6 | thing1   | 0.2   | "green" | 3| 9.0   |
> | 7 | thing1   | 1.0   | "blue"  | 1| 1.0   |
> | 8 | thing1   | 0.2   | "blue"  | 2| 2.0   |
> | 9 | thing1   | 0.1   | "blue"  | 3| 3.0   |
> | 10| thing2   | 0.0   | "red"   | 1| 10.0  |
> | 11| thing2   | 0.2   | "red"   | 2| 11.1  |
> | 12| thing2   | 0.0   | "red"   | 3| 12.4  |
> | 13| thing2   | 1.0   | "green" | 1| 8.0   |
> | 14| thing2   | 0.5   | "green" | 2| 7.0   |
> | 15| thing2   | 0.0   | "green" | 3| 9.0   |
> | 16| thing2   | 1.0   | "blue"  | 1| 1.0   |
> | 17| thing2   | 0.2   | "blue"  | 2| 2.0   |
> | 18| thing2   | 0.1   | "blue"  | 3| 3.0   |
>
> With which the plot can be simplified to:
>
> plot(melt(t, [:_type, :rank, :speed]),
>  ygroup=:_type, x=:rank, y=:value, color=:variable,
>  Geom.subplot_grid(Geom.point),
>  Scale.discrete_color_manual("purple", "orange"))
>
>
>
> On Friday, July 25, 2014 12:05:02 PM UTC-7, Leah Hanson wrote:
>
>> That's not quite it. I think the :_type values being color names is
>> confusing things. I don't want the dots to be colored by :_type.
>>
>> I would like dots for :thing1 to be in purple and the dots for :thing2 to
>> be in orange. So every dot in the first layer needs to be purple and every
>> data in the second layer needs to be orange.
>>
>> Thanks,
>> Leah
>>
>>
>> On Fri, Jul 25, 2014 at 1:36 PM, Daniel Jones 
>> wrote:
>>
>>>
>>> I think this will do the trick, if I understand what you're going for.
>>>
>>>  plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_
>>> type,x=:rank,y=:thing1,color=:_type),
>>> layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,
>>> y=:thing2,color=:_type),
>>> Scale.discrete_color_manual("red", "green", "blue"))
>>>
>>>
>>> On Friday, July 25, 2014 10:51:14 AM UTC-7, Leah Hanson wrote:
>>>
>>>> Tha

Re: [julia-users] Re: [Gadfly] How do I put layers inside a facet/subplot?

2014-07-25 Thread Leah Hanson
That's not quite it. I think the :_type values being color names is
confusing things. I don't want the dots to be colored by :_type.

I would like dots for :thing1 to be in purple and the dots for :thing2 to
be in orange. So every dot in the first layer needs to be purple and every
data in the second layer needs to be orange.

Thanks,
Leah


On Fri, Jul 25, 2014 at 1:36 PM, Daniel Jones 
wrote:

>
> I think this will do the trick, if I understand what you're going for.
>
>
>  
> plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color=:_type),
>
> layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color=:_type),
> Scale.discrete_color_manual("red", "green", "blue"))
>
>
> On Friday, July 25, 2014 10:51:14 AM UTC-7, Leah Hanson wrote:
>
>> Thank, that's very helpful. :)
>>
>> This is what worked:
>> ~~~
>> plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_
>> type,x=:rank,y=:thing1,color=:_type),
>>   layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,
>> y=:thing2,color=:_type))
>> ~~~
>>
>> However, now I'd like to color by layer instead of by :_type, since I
>> want the two layers of dots to be different colors.
>>
>> This does not work:
>> ~~~
>> plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_
>> type,x=:rank,y=:thing1,color="red"),
>>   layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,
>> y=:thing2,color="blue"))
>> ~~~
>>
>> I've also tried passing the color argument into Geom.point or
>> Geom.subplot_grid. I tried setting the value of color to be a
>> "Scale.discrete_color_manual", but the color aesthetic did not consider
>> that to be an appropriate type.
>>
>> How do assign per-layer colors?
>>
>> Thanks,
>> Leah
>>
>>
>> On Fri, Jul 25, 2014 at 12:34 PM, Johan Sigfrids 
>> wrote:
>>
>>> I think you might have to put the Geom.subplot_grid inside the layers.
>>>
>>>
>>> On Friday, July 25, 2014 7:37:48 PM UTC+3, Leah Hanson wrote:
>>>>
>>>> I am trying to make a relatively complicated graph in Gadfly, and am
>>>> struggling.
>>>>
>>>> This is some sample data with the same structure as my data.
>>>> ~~~
>>>> julia> t = readtable("testdata.csv")
>>>> 9x5 DataFrame
>>>> |---|-|--|---|||
>>>> | Row # | _type   | rank | speed | thing1 | thing2 |
>>>> | 1 | "red"   | 1| 10.0  | 0.0| 0.0|
>>>> | 2 | "red"   | 2| 11.1  | 0.1| 0.2|
>>>> | 3 | "red"   | 3| 12.4  | 0.3| 0.0|
>>>> | 4 | "green" | 1| 8.0   | 0.2| 1.0|
>>>> | 5 | "green" | 2| 7.0   | 0.1| 0.5|
>>>> | 6 | "green" | 3| 9.0   | 0.2| 0.0|
>>>> | 7 | "blue"  | 1| 1.0   | 1.0| 1.0|
>>>> | 8 | "blue"  | 2| 2.0   | 0.2| 0.2|
>>>> | 9 | "blue"  | 3| 3.0   | 0.1| 0.1|
>>>> ~~~
>>>>
>>>> Currently, I am trying to make a plot with three rows; each row has a
>>>> plot with two layers. The rows are by :_type. The x-axis for everything is
>>>> :rank. The two layers should be scatterplots of :thing1 and :thing2.
>>>>
>>>> I have tried several variations, here is one of them:
>>>> ~~~
>>>> julia> plot(t,Geom.subplot_grid(Geom.point),ygroup=:_type,layer(x=:
>>>> rank,y=:thing1),layer(x=:rank,y=:thing2))
>>>> Error showing value of type Plot:
>>>> ERROR: The following aesthetics are required by Geom.point but are not
>>>> defined: x, y
>>>>
>>>>  in error at error.jl:21
>>>>  in assert_aesthetics_defined at /usr/local/google/home/lhanson
>>>> /.julia/v0.3/Gadfly/src/aesthetics.jl:148
>>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>>> src/geom/point.jl:27
>>>>  in render_prepared at /usr/local/google/home/lhanson
>>>> /.julia/v0.3/Gadfly/src/Gadfly.jl:718
>>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>>>> src/geom/subplot.jl:234
>>>>  in render_prepared at /usr/local/google/home/lhanson
>>>> /.julia/v0.3/Gadfly/src/Gadfly.jl:718
>>>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/
>>>> Gadfly.jl:673
>>>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/
>>>> Gadfly.jl:922
>>>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/
>>>> Gadfly.jl:837
>>>>  in print_response at REPL.jl:140
>>>>  in print_response at REPL.jl:125
>>>>  in anonymous at REPL.jl:584
>>>>  in run_interface at ./LineEdit.jl:1377
>>>>  in run_frontend at ./REPL.jl:816
>>>>  in run_repl at ./REPL.jl:170
>>>>  in _start at ./client.jl:399
>>>> ~~~
>>>>
>>>> How do I put layers inside a subplot?
>>>>
>>>> Thanks,
>>>> Leah
>>>>
>>>
>>


Re: [julia-users] Re: [Gadfly] How do I put layers inside a facet/subplot?

2014-07-25 Thread Leah Hanson
Thank, that's very helpful. :)

This is what worked:
~~~
plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color=:_type),

layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color=:_type))
~~~

However, now I'd like to color by layer instead of by :_type, since I want
the two layers of dots to be different colors.

This does not work:
~~~
plot(t,layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing1,color="red"),

layer(Geom.subplot_grid(Geom.point),ygroup=:_type,x=:rank,y=:thing2,color="blue"))
~~~

I've also tried passing the color argument into Geom.point or
Geom.subplot_grid. I tried setting the value of color to be a
"Scale.discrete_color_manual", but the color aesthetic did not consider
that to be an appropriate type.

How do assign per-layer colors?

Thanks,
Leah


On Fri, Jul 25, 2014 at 12:34 PM, Johan Sigfrids 
wrote:

> I think you might have to put the Geom.subplot_grid inside the layers.
>
>
> On Friday, July 25, 2014 7:37:48 PM UTC+3, Leah Hanson wrote:
>>
>> I am trying to make a relatively complicated graph in Gadfly, and am
>> struggling.
>>
>> This is some sample data with the same structure as my data.
>> ~~~
>> julia> t = readtable("testdata.csv")
>> 9x5 DataFrame
>> |---|-|--|---|||
>> | Row # | _type   | rank | speed | thing1 | thing2 |
>> | 1 | "red"   | 1| 10.0  | 0.0| 0.0|
>> | 2 | "red"   | 2| 11.1  | 0.1| 0.2|
>> | 3 | "red"   | 3| 12.4  | 0.3| 0.0|
>> | 4 | "green" | 1| 8.0   | 0.2| 1.0|
>> | 5 | "green" | 2| 7.0   | 0.1| 0.5|
>> | 6 | "green" | 3| 9.0   | 0.2| 0.0|
>> | 7 | "blue"  | 1| 1.0   | 1.0| 1.0|
>> | 8 | "blue"  | 2| 2.0   | 0.2| 0.2|
>> | 9 | "blue"  | 3| 3.0   | 0.1| 0.1|
>> ~~~
>>
>> Currently, I am trying to make a plot with three rows; each row has a
>> plot with two layers. The rows are by :_type. The x-axis for everything is
>> :rank. The two layers should be scatterplots of :thing1 and :thing2.
>>
>> I have tried several variations, here is one of them:
>> ~~~
>> julia> plot(t,Geom.subplot_grid(Geom.point),ygroup=:_type,layer(x=:
>> rank,y=:thing1),layer(x=:rank,y=:thing2))
>> Error showing value of type Plot:
>> ERROR: The following aesthetics are required by Geom.point but are not
>> defined: x, y
>>
>>  in error at error.jl:21
>>  in assert_aesthetics_defined at /usr/local/google/home/
>> lhanson/.julia/v0.3/Gadfly/src/aesthetics.jl:148
>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/geom/point.jl:27
>>  in render_prepared at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/Gadfly.jl:718
>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/geom/subplot.jl:234
>>  in render_prepared at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/Gadfly.jl:718
>>  in render at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/Gadfly.jl:673
>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/Gadfly.jl:922
>>  in display at /usr/local/google/home/lhanson/.julia/v0.3/Gadfly/
>> src/Gadfly.jl:837
>>  in print_response at REPL.jl:140
>>  in print_response at REPL.jl:125
>>  in anonymous at REPL.jl:584
>>  in run_interface at ./LineEdit.jl:1377
>>  in run_frontend at ./REPL.jl:816
>>  in run_repl at ./REPL.jl:170
>>  in _start at ./client.jl:399
>> ~~~
>>
>> How do I put layers inside a subplot?
>>
>> Thanks,
>> Leah
>>
>


Re: [julia-users] A couple tuple questions

2014-07-25 Thread Leah Hanson
Here's one way to go about it:

~~~
julia> tuplearray = [(3,2,1),(1,2,3),(3,1,2)]
3-element Array{(Int64,Int64,Int64),1}:
 (3,2,1)
 (1,2,3)
 (3,1,2)

julia> minimum(tuplearray)
(1,2,3)

julia> minimum(x->x[2],tuplearray)
1

julia> find(x->x[2]==1,tuplearray)
1-element Array{Int64,1}:
 3

julia> tuplearray[3]
(3,1,2)
~~~

Similarly, if you want to use your x2array:
~~~
julia> x2array = [2,2,1]
3-element Array{Int64,1}:
 2
 2
 1

julia> minimum(x2array)
1

julia> find(x->x==1,x2array)
1-element Array{Int64,1}:
 3
~~~


On Fri, Jul 25, 2014 at 12:29 PM,  wrote:

> One more tuple question -- I am trying to find a tuple associated with a
> minimum x[n].
>
> So taking let's say
>
> tuplearray = [(3,2,1),(1,2,3),(3,1,2)]
>
> I want to to find the min x[2] for x in tuplearray
>
> minx2tuple = (3,1,2)
>
> Using the method Kevin showed above, I can unpack the tuples to get three
> element arrays
>
> x1array,x2array,x3array = collect(zip(tuplearray...))
>
> Then, I can do
>
> minx2 = minimum(x2array)
>
> to get
>
> minx2 = 1
>
> However, if I do a comprehension,
>
> [x for x in tuplearray if x[2] == minx2]
>
> or
>
> [x for x in tuplearray if x[2] == 1]
>
> this comprehension does not work. The error I get is -- ERROR: syntax:
> unexpected "]".
>
> How can I fix the comprehension to make it work in Julia?
>
> Thanks,
> Wally
>
> On Friday, July 25, 2014 11:05:45 AM UTC-4, yaois...@gmail.com wrote:
>>
>> Ah, thank you!
>>
>> This Google group community is fantastic.
>>
>> On Thursday, July 24, 2014 6:32:19 PM UTC-4, Kevin Squire wrote:
>>>
>>> Hi there,
>>>
>>> In regards to a), I keep on getting the error message with the second
>>>> option
>>>> ERROR: type: apply: expected Function, got (Int64,Int64,Int64)
>>>>
>>>
>>> I'm guessing you accidentally redefined the symbol "tuple" to a tuple:
>>>
>>>  julia> tuple(testtuple...,testvar)
>>> (1,2,3,4)
>>>
>>> julia> tuple = (1,2,3)
>>> Warning: imported binding for tuple overwritten in module Main
>>> (1,2,3)
>>>
>>> julia> tuple(testtuple...,testvar)
>>> ERROR: type: apply: expected Function, got (Int64,Int64,Int64)
>>>
>>>
>>> For your second example, zip(tuplearray...) is actually about right.
>>>  The main differences from what you want are
>>>
>>> 1) it returns an iterator, not a set of arrays
>>> 2) the iterator yields tuples, not arrays
>>>
>>> julia> zip(tuplearray)
>>> Zip{(Array{(Int64,Int64,Int64),1},)}(([(1,2,3),(10,20,30),(
>>> 100,200,300)],))
>>>
>>> julia> collect(zip(tuplearray...))
>>> 3-element Array{(Int64,Int64,Int64),1}:
>>>  (1,10,100)
>>>  (2,20,200)
>>>  (3,30,300)
>>>
>>> Cheers,
>>>Kevin
>>>
>>>
>>> Just making sure, are you using 0.3? If so, hmm, I would be a bit
>>>> stumped as to why the same line is not working for me.
>>>>
>>>> On Thursday, July 24, 2014 5:30:44 PM UTC-4, Leah Hanson wrote:
>>>>
>>>>> a) Your second option works for me:
>>>>> ~~~
>>>>> julia> testtuple = (1,2,3)
>>>>> (1,2,3)
>>>>>
>>>>> julia> testvar = 4
>>>>> 4
>>>>>
>>>>> julia> tuple(testtuple...,testvar)
>>>>> (1,2,3,4)
>>>>> ~~~
>>>>>
>>>>> b) I'm not sure what the cleanest code for your example would be, but
>>>>> here's one possibility:
>>>>>
>>>>> ~~~
>>>>> julia> tuplearray = [(1,2,3),(10,20,30),(100,200,300)]
>>>>> 3-element Array{(Int64,Int64,Int64),1}:
>>>>>  (1,2,3)
>>>>>  (10,20,30)
>>>>>  (100,200,300)
>>>>>
>>>>> julia> aarray = Int[]
>>>>> 0-element Array{Int64,1}
>>>>>
>>>>> julia> barray = Int[]
>>>>> 0-element Array{Int64,1}
>>>>>
>>>>> julia> carray = Int[]
>>>>> 0-element Array{Int64,1}
>>>>>
>>>>> julia> for (a,b,c) in tuplearray
>>>>>  push!(aarray,a)
>>>>>  push!(barray,b)
>>>>>  push!(carray,c)
>>>>>end
>>>>>
>>>>> julia> aarray

[julia-users] [Gadfly] How do I put layers inside a facet/subplot?

2014-07-25 Thread Leah Hanson
I am trying to make a relatively complicated graph in Gadfly, and am
struggling.

This is some sample data with the same structure as my data.
~~~
julia> t = readtable("testdata.csv")
9x5 DataFrame
|---|-|--|---|||
| Row # | _type   | rank | speed | thing1 | thing2 |
| 1 | "red"   | 1| 10.0  | 0.0| 0.0|
| 2 | "red"   | 2| 11.1  | 0.1| 0.2|
| 3 | "red"   | 3| 12.4  | 0.3| 0.0|
| 4 | "green" | 1| 8.0   | 0.2| 1.0|
| 5 | "green" | 2| 7.0   | 0.1| 0.5|
| 6 | "green" | 3| 9.0   | 0.2| 0.0|
| 7 | "blue"  | 1| 1.0   | 1.0| 1.0|
| 8 | "blue"  | 2| 2.0   | 0.2| 0.2|
| 9 | "blue"  | 3| 3.0   | 0.1| 0.1|
~~~

Currently, I am trying to make a plot with three rows; each row has a plot
with two layers. The rows are by :_type. The x-axis for everything is
:rank. The two layers should be scatterplots of :thing1 and :thing2.

I have tried several variations, here is one of them:
~~~
julia>
plot(t,Geom.subplot_grid(Geom.point),ygroup=:_type,layer(x=:rank,y=:thing1),layer(x=:rank,y=:thing2))
Error showing value of type Plot:
ERROR: The following aesthetics are required by Geom.point but are not
defined: x, y

 in error at error.jl:21
 in assert_aesthetics_defined at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/aesthetics.jl:148
 in render at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/geom/point.jl:27
 in render_prepared at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:718
 in render at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/geom/subplot.jl:234
 in render_prepared at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:718
 in render at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:673
 in display at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:922
 in display at
/usr/local/google/home/lhanson/.julia/v0.3/Gadfly/src/Gadfly.jl:837
 in print_response at REPL.jl:140
 in print_response at REPL.jl:125
 in anonymous at REPL.jl:584
 in run_interface at ./LineEdit.jl:1377
 in run_frontend at ./REPL.jl:816
 in run_repl at ./REPL.jl:170
 in _start at ./client.jl:399
~~~

How do I put layers inside a subplot?

Thanks,
Leah


Re: [julia-users] bug found in a for loop, some help needed

2014-07-25 Thread Leah Hanson
It sounds like the error message is asking you to open a github issue here:
https://github.com/julialang/julia/issues?milestone=7&state=open . Seeing
an error message that asks you to report an error (where the error is
coming from the compiler, and not a message you added yourself) usually
means that you found an exciting bug that's in the compiler, rather than
your code.

When you create the issue, you should include the full error message, your
code, and your julia version. The code needs to be a full, runnable example
that produces that error. You can find out what version of Julia you're
running using the `versioninfo()` function; run it at the REPL and paste
the answer into your issue.

Thanks for finding a bug!
Leah


On Fri, Jul 25, 2014 at 7:23 AM, Alexander Kagermanov <
alexanderkagerma...@gmail.com> wrote:

> Hi!, I have quite a long code for finite element analysis in Julia,, when
> I come to the point of assembling the stiffness matrix (which is a loop
> "for", for each element), I get the following error:
>
> " please submit a bug report with steps to reproduce this fault.
> Exception: EXCEPTION_ACCESS_VIOLATION at @x1ooob75 -- hvcat at
> abstractarray.jl 1017   "
>
> ,,. something like that. The part of the code where it happens, looks like
> this:
>
> #Assemblege of initial Kglob
> for e=1:size(Imatrix,1) #for each element
>
>  # here I compute the element stiffness matrix Kglobel
>
> #Assemble
> for j=1:12
> dof1=Imatrix[e,j];
> s1=posdof(Adof,dof1);
> if s1!=0
> for k=1:12
> dof2=Imatrix[e,k];
> s2=posdof(Adof,dof2);
> if s2!=0
> Kglobst[s1,s2]=Kglobst[s1,s2]+Kglobel[j,k];
> end
> end
> end
> end
> end
>
> It´s strange because the error appears at different points, and in a few
> cases no error appeared, and it was able to finish the loop.
>
> Thanks
> Alex
>


Re: [julia-users] A couple tuple questions

2014-07-24 Thread Leah Hanson
a) Your second option works for me:
~~~
julia> testtuple = (1,2,3)
(1,2,3)

julia> testvar = 4
4

julia> tuple(testtuple...,testvar)
(1,2,3,4)
~~~

b) I'm not sure what the cleanest code for your example would be, but
here's one possibility:

~~~
julia> tuplearray = [(1,2,3),(10,20,30),(100,200,300)]
3-element Array{(Int64,Int64,Int64),1}:
 (1,2,3)
 (10,20,30)
 (100,200,300)

julia> aarray = Int[]
0-element Array{Int64,1}

julia> barray = Int[]
0-element Array{Int64,1}

julia> carray = Int[]
0-element Array{Int64,1}

julia> for (a,b,c) in tuplearray
 push!(aarray,a)
 push!(barray,b)
 push!(carray,c)
   end

julia> aarray
3-element Array{Int64,1}:
   1
  10
 100

julia> barray
3-element Array{Int64,1}:
   2
  20
 200

julia> carray
3-element Array{Int64,1}:
   3
  30
 300
~~~

If would be faster to pre-allocate the arrays (to the length of the
tuplearray), and then just put the elements in at the correct indices, but
I'm not sure if that matters for your application.

-- Leah



On Thu, Jul 24, 2014 at 4:15 PM,  wrote:

> Hi all,
>
> I thought to just add to my previous thread, but created a new one because
> the topic is a bit different. Hope y'all don't mind.
>
> Anyhow:
>
> a) How would I concatenate two tuples? Or a tuple with a variable?
>
> Say I have
>
> testtuple = (1,2,3)
> testvar = 4
>
> and want to get
>
> newtuple = (1,2,3,4)
>
> (not ((1,2,3),4)
>
> I've tried
> newtuple = tuple(testtuple...,testvar...)
> newtuple = tuple(testtuple...,testvar)
> newtuple = testtuple...,testvar
>
> but none of those have worked to produce the desired result.
>
> b) I have an array of tuples
>
> tuplearray = [(a1,b1,c1),(a2,b2,c2)...,(an,bn,cn)]
>
> How could I then unpack the array into
>
> aarray = [a1,a2...,an]
> barray = [b1,b2...,bn]
> carray = [c1,c3...,cn]
>
> such that each position in the tuple gets unpacked into a corresponding
> individual array?
>
> In Python, I would use
>
> alist,blist,clist = zip(*tuplelist)
>
> It appears that
>
> aarray,barray,carray = zip(tuplearray...)
>
> is not the Julia equivalent.
>
> My version of Julia is the .3 RC.
>
> Thanks for your help
>


Re: [julia-users] Equivalent for Python 'pass' statement in Julia

2014-07-22 Thread Leah Hanson
Because Julia has begin-end blocks, you can just use an empty block.

Here are some examples of what I mean:

~~~
function foo()
end
~~~

~~~
if true
elseif false
else
end
~~~

~~~
for i=1:10
end
~~~

Does that do what you wanted?

-- Leah


On Tue, Jul 22, 2014 at 3:44 PM,  wrote:

> Hi,
>
> Python has a 'pass' statement which allows null operations to be placed in
> control flows with ease.
> I guess I could just use a print statement, but I was just wondering
> whether Julia had an equivalent?
>
> Thanks
>


[julia-users] Static Analysis in Julia talk

2014-07-21 Thread Leah Hanson
I've spoken twice about TypeCheck.jl in the past couple of weeks (at
JuliaCon and Midwest.io). The Midwest.io talk has been posted:
https://www.youtube.com/watch?v=mL1Ow03G8tk&feature=youtu.be

Because Midwest.io is a general programming conference, there's background
on Julia before we get into the actual analysis. However, since it's the
second time I gave the talk, it's more polished. But otherwise, it's the
same content as the one I gave at JuliaCon.

-- Leah


Re: [julia-users] String from a substring

2014-07-21 Thread Leah Hanson
SubString is a subtype of String, so any function accepting a String should
accept a SubString. What function are you calling where this doesn't work?

-- Leah


On Mon, Jul 21, 2014 at 11:13 AM, Ben Ward  wrote:

> This is probably a simple question, I've done a string splitting operation
> with split(), which has given me an array of SubString types, but I want
> them to be of type String so as I can feed the bits of the split up string
> to some method that requires a String type. string(*substring type*) does
> not work.
>
> Thanks,
> Ben.
>


Re: [julia-users] Re: Sorting behavior

2014-07-21 Thread Leah Hanson
I hadn't seen that issue; thanks for the link. I'm glad there's a
discussion going on about that. :)

-- Leah


On Mon, Jul 21, 2014 at 10:43 AM, Ivar Nesje  wrote:

> Warning for 2d row vectors used in context where only a 1d column vector
> is used could definelty be implemented as help when you get a MethodError.
>
> See also https://github.com/JuliaLang/julia/issues/7512.
>
> Ivar
>
> kl. 16:03:46 UTC+2 mandag 21. juli 2014 skrev Leah Hanson følgende:
>>
>> I agree that the `["a" "b" "c"]` vs `["a", "b", "c"]` syntax is something
>> likely to catch new-to-Julia users. I have personally watched people
>> struggle with that. Programmers familiar with other languages take a bit to
>> understand the vectors vs row-matrixes thing, when they were just expecting
>> a list/array type. While you can read `Array{ASCIIString, 2}` in the REPL
>> response to `["a" "b" "c"]` (and in the `sort` error message), you have to
>> know that matrixes/row-matrixes exist in Julia and that we've chosen not to
>> interpret a row-matrix as a list.
>>
>> I'm not in favor of make `sort` work for row-matrixes. This distinction
>> is an important one to learn as a Julia programmer and you will continue to
>> encounter it. However, maybe our error messages could be a lot better. The
>> most magical version would be to say something like:
>>
>> ~~~
>> julia> sort(lst)
>>
>> sort(lst)
>>  ~~~
>> `lst` is an Array{ASCIIString, 2}, which `sort` has no method for.
>> Did you mean to define `lst` as `lst = ["a", "b", "c"]`?
>> ~~~
>>
>> This is most appropriate in a "I just used a row-matrix literal."
>> context, but for any (short) row-matrix, it could be helpful. I use C++ at
>> work, and this is what many of my error messages look like: the line (with
>> line number/file), with the problem underlined/highlighted, a brief
>> description of the problem, and (often) a suggestion of what I may have
>> meant. The suggests are literally copy-paste-able code, not a prose
>> description.
>>
>> I find these to be very useful, especially as a less experienced C++
>> user. The suggestions appear for things like "->" vs "." (when you've got
>> the wrong one), when you've mistyped a variable name (there's a variable of
>> the proper type in-scope, and you used a non-existant/other-type variable),
>> when you forgot to namespace a variable/function (you used `vector` but
>> have to use `std::vector`).
>>
>> These error messages do a great job of "I'm not going to except your
>> incorrect input, but I do have a solid guess about what you meant, so I'll
>> tell you the answer.". They are probably my favorite thing about using C++,
>> and I think they are the most friendly thing you can do for new users.
>>
>> -- Leah
>>
>>
>>
>> On Mon, Jul 21, 2014 at 6:01 AM, Ivar Nesje  wrote:
>>
>>> 1. It clearly isn't.
>>>
>>> 2. It will not cause any overhead in the common case (because it would
>>> be a separate method in Julia). The question is whether this is a case
>>> where we should guess what the user intended, or force the user to fix a
>>> potential problem.
>>>
>>> Not sure what we could do about this though, because the distinction is
>>> useful and it becomes much more annoying if you discover such subtle
>>> differences later rather than earlier.
>>>
>>> Ivar
>>>
>>> kl. 04:19:53 UTC+2 mandag 21. juli 2014 skrev Abe Schneider følgende:
>>>
>>>> It wasn't obvious to me initially why `sort` wasn't working for me
>>>> (strings and composite types). On further investigation it looks like that
>>>> it only works for single-dimension arrays -- which makes sense. However, if
>>>> I type:
>>>>
>>>> lst = ["a" "b" "c"]
>>>> sort(lst)
>>>>
>>>> I get an error. The answer is that it's of type `Array{ASCIIString,
>>>> 2}`, whereas `sort` wants the type to be `Array{ASCIIString, 1}`. The
>>>> correct solution is to write this instead:
>>>>
>>>> lst = ["a", "b", "c"]
>>>> sort(lst)
>>>>
>>>> The problem seems to derive from two design decisions:
>>>>
>>>>1. It is not obvious to someone new to Julia why one form gives a
>>>>two dimensional array whereas the other gives a one dimensional array.
>>>>2. `sort` doesn't try to determine if the array passed is actually
>>>>jeust one dimensional.
>>>>
>>>> I'm not sure there is a simple solution. I assume there's a good reason
>>>> for (1) and (2) involves some overhead which might be undesirable.
>>>>
>>>
>>


Re: [julia-users] Re: Sorting behavior

2014-07-21 Thread Leah Hanson
I agree that the `["a" "b" "c"]` vs `["a", "b", "c"]` syntax is something
likely to catch new-to-Julia users. I have personally watched people
struggle with that. Programmers familiar with other languages take a bit to
understand the vectors vs row-matrixes thing, when they were just expecting
a list/array type. While you can read `Array{ASCIIString, 2}` in the REPL
response to `["a" "b" "c"]` (and in the `sort` error message), you have to
know that matrixes/row-matrixes exist in Julia and that we've chosen not to
interpret a row-matrix as a list.

I'm not in favor of make `sort` work for row-matrixes. This distinction is
an important one to learn as a Julia programmer and you will continue to
encounter it. However, maybe our error messages could be a lot better. The
most magical version would be to say something like:

~~~
julia> sort(lst)

sort(lst)
 ~~~
`lst` is an Array{ASCIIString, 2}, which `sort` has no method for.
Did you mean to define `lst` as `lst = ["a", "b", "c"]`?
~~~

This is most appropriate in a "I just used a row-matrix literal." context,
but for any (short) row-matrix, it could be helpful. I use C++ at work, and
this is what many of my error messages look like: the line (with line
number/file), with the problem underlined/highlighted, a brief description
of the problem, and (often) a suggestion of what I may have meant. The
suggests are literally copy-paste-able code, not a prose description.

I find these to be very useful, especially as a less experienced C++ user.
The suggestions appear for things like "->" vs "." (when you've got the
wrong one), when you've mistyped a variable name (there's a variable of the
proper type in-scope, and you used a non-existant/other-type variable),
when you forgot to namespace a variable/function (you used `vector` but
have to use `std::vector`).

These error messages do a great job of "I'm not going to except your
incorrect input, but I do have a solid guess about what you meant, so I'll
tell you the answer.". They are probably my favorite thing about using C++,
and I think they are the most friendly thing you can do for new users.

-- Leah



On Mon, Jul 21, 2014 at 6:01 AM, Ivar Nesje  wrote:

> 1. It clearly isn't.
>
> 2. It will not cause any overhead in the common case (because it would be
> a separate method in Julia). The question is whether this is a case where
> we should guess what the user intended, or force the user to fix a
> potential problem.
>
> Not sure what we could do about this though, because the distinction is
> useful and it becomes much more annoying if you discover such subtle
> differences later rather than earlier.
>
> Ivar
>
> kl. 04:19:53 UTC+2 mandag 21. juli 2014 skrev Abe Schneider følgende:
>
>> It wasn't obvious to me initially why `sort` wasn't working for me
>> (strings and composite types). On further investigation it looks like that
>> it only works for single-dimension arrays -- which makes sense. However, if
>> I type:
>>
>> lst = ["a" "b" "c"]
>> sort(lst)
>>
>> I get an error. The answer is that it's of type `Array{ASCIIString, 2}`,
>> whereas `sort` wants the type to be `Array{ASCIIString, 1}`. The correct
>> solution is to write this instead:
>>
>> lst = ["a", "b", "c"]
>> sort(lst)
>>
>> The problem seems to derive from two design decisions:
>>
>>1. It is not obvious to someone new to Julia why one form gives a two
>>dimensional array whereas the other gives a one dimensional array.
>>2. `sort` doesn't try to determine if the array passed is actually
>>jeust one dimensional.
>>
>> I'm not sure there is a simple solution. I assume there's a good reason
>> for (1) and (2) involves some overhead which might be undesirable.
>>
>


Re: [julia-users] Generating optimized code for an instance of a composite type. Possible?

2014-07-20 Thread Leah Hanson
Have you considered using type parameters to indicate the symmetry of the
filter object? That would allow you to use multiple dispatch to make a
separate method for each kind of symmetry.

-- Leah


On Sun, Jul 20, 2014 at 10:03 AM, Jay Kickliter 
wrote:

> I'm writing some polyphase resampling
> 
> code. Sometimes there are symmetries that cut down on the number of
> required multiplies. I'm still learning how to use Julia's metaprogramming
> facilities, but assuming it's possible to recognize the symmetry and
> generate some optimized code for a particular instance of a filter object,
> how would I execute it? The filters will be composite types that store
> previous state, filter taps, resampling rations, and other information. Is
> it possible to store the code in the object itself, and execute it
> efficiently?
>
> This more of a curiosity. If I could get the code to actually compile to
> vectorized SIMD code, the "optimization" might be slower.
>
> Thanks!
>


Re: [julia-users] Background Knowledge needed to Start working with/learning Julia?

2014-07-18 Thread Leah Hanson
I agree with what John said.

Additionally, as you have more specific questions that you get stuck on,
please ask this mailing list. The manual is certainly incomplete; I went to
look relevant section to direct you to, but the section on Networking &
Streams is very networking focused.

I have a github repo of some tiny projects that are somewhat similar in
scale to what you're doing. The repo is here:
https://github.com/astrieanna/Projects . Here's one that uses ArgParse.jl
(a Julia package):
https://github.com/astrieanna/Projects/blob/master/palindrome.jl . Here's
one that does it's input by hand:
https://github.com/astrieanna/Projects/blob/101cb0637ee83251a8d985ff9609fef02d79f4a0/pi.jl
. (The second one is trying to take a "number of digits to output". It lets
you enter on the command line (ARGS is the automatically available array of
command-line arguments) and if you don't, it lets you enter it after the
program has started.

-- Leah




On Fri, Jul 18, 2014 at 9:09 AM, John Myles White 
wrote:

> This might seem like just a reframing of the situation, rather than an
> answer, but I personally don't think there's any background knowledge you
> need to get started using Julia. What you need is a willingness to figure
> out what's going on by doing some digging through the manual, the general
> web and the Julia codebase for the language. The manual gives you enough to
> get started using the language, but assumes that some standard Unix
> commands are familiar like STDOUT. But that sort of stuff is very well
> documented on the web, since it's a core part of computing culture outside
> of the Windows world. And when you need to get examples of how people write
> large amounts of code in Julia, you can read the source code for the core
> libraries in Base, which is a canonical example of how Julia should be
> written.
>
>  -- John
>
> On Jul 18, 2014, at 9:49 AM, Michael Bullman 
> wrote:
>
> > Hey Everyone, I'm very interested in learning Julia, but I feel like I'm
> missing some crucial background knowledge to really understand how Julia
> works. Just to give you guys my background, My first language was Java in
> high school, I got fairly good using it then, but in college I only barely
> maintained the skill. I took a couple low level programming course to stay
> somewhat fresh, and some CS 101 type courses and a data structures course.
> Other than that my knowledge is spread around a bit using some Python, but
> mainly R of late.
> >
> > Some things in the Julia notation feel familiar to me, Types remind me
> of Java objects, I can generally "read" code in examples. But many things
> feel unfamiliar. It makes me think that there is some base of knowledge is
> assumed with Julia that I do not have.
> >
> > My first Julia project is pretty silly compared to most people. I'm
> trying to write a "Lunch-roulette" Program to help me and my
> co-worker/buddies choose where to go for lunch on break. While I was
> looking for simple I/O instructions so we can enter several lunch spots,
> and times.  I realized I had no idea how to use the IOStream or STDIN/OUT
> functionality. Looks like a lot of this is based off of C++ and Unix
> command line functionality.
> >
> > Sorry if this was a long winded question, but basically, what do I need
> to know before I can start learning to use Julia?
> >
> > Thanks,
> > -Mike
>
>


Re: [julia-users] [newb] namespaces?

2014-07-17 Thread Leah Hanson
Packages are each in their own module, which are namespaces.

Because generic functions "own" all their scattered methods, there is less
of a need to hide functions with the same name inside different namespaces
in Julia.

Could you be more specific about what you're concerned could happen? (for
example, what is a specific problem that could arise from not using
namespaces heavily enough?)

Best,
  Leah


On Thu, Jul 17, 2014 at 1:13 PM, Neal Becker  wrote:

> One thing that surprises me, coming from a largely python background, is
> there
> seems to be little use of namespaces in julia.  For example, it seems that
> everything in the standard library is just part of one global namespace.
>
> If true, this does seem to go against trends in modern design, I believe.
>  I
> would think this could cause trouble down the road.
>
>


Re: [julia-users] Re: my first julia function

2014-07-16 Thread Leah Hanson
Help data is hand-written; if no one has documented a function yet, then it
just tells you how many methods there are. `methods(sumabs2)` would show
you the method signatures.

If you want to add to the help documentation, you can edit this file:
https://github.com/JuliaLang/julia/blob/master/doc/helpdb.jl (You can
either use the github interface to edit it online, or, if you have the
Julia source, edit the file locally and make a pull request.)

-- Leah


On Wed, Jul 16, 2014 at 10:36 AM, Neal Becker  wrote:

> Dahua Lin wrote:
>
> > With the latest Julia, you can do this by
> > sumabs2(x)
> >
> > Dahua
> >
> >
> > On Wednesday, July 16, 2014 9:57:54 AM UTC-5, Neal Becker wrote:
> >>
> >> As a first exercise, I wanted to code magnitude squared of a complex
> >> 1-d array.  Here is what I did:
> >>
> >> mag_sqr{T} (x::Array{Complex{T},1}) =
> >> sum(real(x).*real(x)+imag(x).*imag(x))
> >>
> >> Is this a "good" approach?  I'm wondering if it's not very efficient,
> >> since I
> >> expect it would compute matrixes of element-wise products first, rather
> >> than
> >> doing the sum as a running summation (like a loop in c++).
> >>
> >> Can you suggest something "better"?
> >>
> >>
>
> Not exactly answering my question, as I was looking for a learning
> opportunity.
> But this raises another question:
>
> In [2]:
>
> help(sumabs2)
> INFO: Loading help data...
> sumabs2 (generic function with 2 methods)
>
> Why is the help data not being shown? (this is ipython notebook interface)
>
>


Re: [julia-users] Re: websockets D3 and Julia

2014-07-14 Thread Leah Hanson
If you're looking for the server-side Julia websockets package, this is it:
https://github.com/JuliaLang/WebSockets.jl

Gadfly.jl can generate SVG files; you could probably send those across a
websock and using Javascript to insert them into the page. I'm not
especially experienced in web-stuff, so I'm just saying I think that would
be a feasible & relatively straight-forward method; I don't actually know
what a normal design pattern for that kind of thing (dynamically adding
graphs to a page) is.

-- Leah


On Mon, Jul 14, 2014 at 8:48 PM, Chris Sterritt  wrote:

> Hi Martin,
>
> Interesting idea, by all means keep us posted on what you do!
>
> Here's an interesting article titled "You might not need a WebSocket" for
> some interesting alternative ways to push to the browser:
>
> http://blog.fanout.io/2014/06/24/you-might-not-need-a-websocket/
>
> Cheers!
>
>
> On Monday, July 14, 2014 12:03:55 PM UTC-4, Martin Somers wrote:
>>
>>
>> I was wondering if there might be some means of dynamically adding graphs
>> to an open webpage using julia - thinking of starting a project using
>> existing libraries
>> Julia webstack looked interesting
>>
>> Any libraries or projects that might be of use
>>
>


Re: [julia-users] Re: essay on the history of programming languages

2014-07-13 Thread Leah Hanson
That's the first part of what I saw too. After that, it says "The public
release of this presentation will be in the next month.".



On Sun, Jul 13, 2014 at 12:13 PM, Job van der Zwan  wrote:

> I get a different message:
>
> *Thank you for attending Strange Loop 2013*
>> This is a restricted presentation that can only be viewed by Strange Loop
>> 2013 attendees!
>>
> Which is odd, because I didn't attend in the first place.
>
>
> On Sunday, 13 July 2014 17:24:22 UTC+2, Leah Hanson wrote:
>
>> Looks like it will be next month: http://www.infoq.com/
>> presentations/julia-dispatch?utm_source=infoq&utm_medium=
>> QCon_EarlyAccessVideos&utm_campaign=StrangeLoop2013
>>
>>
>> On Sun, Jul 13, 2014 at 4:57 AM, Job van der Zwan 
>> wrote:
>>
>>> By the way, is video for the Strange Loop presentation linked near the
>>> end
>>> <http://nbviewer.ipython.org/gist/StefanKarpinski/b8fe9dbb36c1427b9f22>
>>> ever going to be public?
>>>
>>>
>>> On Sunday, 13 July 2014 04:55:43 UTC+2, Stefan Karpinski wrote:
>>>>
>>>> Graydon Hoare (original author of Rust) wrote a truly lovely essay in
>>>> two parts about the history of programming languages, the predominance of
>>>> two-language systems – or "Ousterhout-dichotomy languages," as he puts it –
>>>> Lisp's historical defiance of this dichotomy, Dylan as a successor to Lisp,
>>>> and finally Julia as a modern successor to Lisp and Dylan:
>>>>
>>>> http://graydon2.dreamwidth.org/3186.html
>>>> http://graydon2.dreamwidth.org/189377.html
>>>>
>>>>
>>>> This is a great read and an edifying historical perspective, regardless
>>>> of the Julia bit at the end, but may be especially interesting to folks on
>>>> julia-users.
>>>>
>>>
>>


Re: [julia-users] Re: essay on the history of programming languages

2014-07-13 Thread Leah Hanson
Looks like it will be next month:
http://www.infoq.com/presentations/julia-dispatch?utm_source=infoq&utm_medium=QCon_EarlyAccessVideos&utm_campaign=StrangeLoop2013


On Sun, Jul 13, 2014 at 4:57 AM, Job van der Zwan 
wrote:

> By the way, is video for the Strange Loop presentation linked near the end
> 
> ever going to be public?
>
>
> On Sunday, 13 July 2014 04:55:43 UTC+2, Stefan Karpinski wrote:
>>
>> Graydon Hoare (original author of Rust) wrote a truly lovely essay in two
>> parts about the history of programming languages, the predominance of
>> two-language systems – or "Ousterhout-dichotomy languages," as he puts it –
>> Lisp's historical defiance of this dichotomy, Dylan as a successor to Lisp,
>> and finally Julia as a modern successor to Lisp and Dylan:
>>
>> http://graydon2.dreamwidth.org/3186.html
>> http://graydon2.dreamwidth.org/189377.html
>>
>>
>> This is a great read and an edifying historical perspective, regardless
>> of the Julia bit at the end, but may be especially interesting to folks on
>> julia-users.
>>
>


Re: [julia-users] Canonical way of reading STDIN

2014-07-12 Thread Leah Hanson
Those look pretty reasonable to me. :)

Thanks for contributing to the documentation.

-- Leah


On Sat, Jul 12, 2014 at 11:21 AM, Matthew Wood  wrote:

> I didn't find any examples in the docs for processing STDIN for more than
> one read. I'm happy to contribute an example, but I wanted to make sure I
> knew the best way.
>
> Reading lines from STDIN:
>
> for line = eachline(STDIN)
> print("Found: $line")
> end
>
> Reading Chars:
>
> while !eof(STDIN)
> x = read(STDIN, Char)
> println("Found: $x")
> end
>
> Does that look pretty reasonable?
>
> Thanks.
> Matt Wood
>


Re: [julia-users] how use find ?

2014-07-12 Thread Leah Hanson
The problem is that `a .> 5` is a BitArray, not a function.

~~~
julia> a = rand(10) * 10
10-element Array{Float64,1}:
 5.5408
 5.52724
 2.87541
 1.59491
 0.278013
 1.56604
 8.29388
 8.27159
 0.737642
 7.40957

julia> find(x->x>5,a)
5-element Array{Int64,1}:
  1
  2
  7
  8
 10
~~~

When you call `find(a .> 5)`, you're using a different method of find:
~~~
julia> help(find)
Base.find(A)

   Return a vector of the linear indexes of the non-zeros in "A"
   (determined by "A[i]!=0").  A common use of this is to convert a
   boolean array to an array of indexes of the "true" elements.
~~~

-- Leah



On Sat, Jul 12, 2014 at 12:00 PM,  wrote:

> Big thx.
> In documentation is :
> find(f, A)
> Return a vector of the linear indexes of A where f returns true.
> (function, OBJECT)
> What You think, s it error in documention ?
> Paul
>
>
> W dniu sobota, 12 lipca 2014 17:52:05 UTC+2 użytkownik Cameron McBride
> napisał:
>>
>> julia> find( a .> 5 )
>>
>> cheers,
>>
>> Cameron
>>
>>
>> On Sat, Jul 12, 2014 at 11:40 AM, paul analyst 
>> wrote:
>>
>>> I need all indexes where a[:] >5
>>>
>>> julia> a=rand(10)*10
>>> 10-element Array{Float64,1}:
>>>  4.84005
>>>  8.29994
>>>  8.8531
>>>  3.42319
>>>  2.60318
>>>  7.25313
>>>  0.816263
>>>  4.44463
>>>  6.71836
>>>  4.65337
>>>
>>> julia> a.>5
>>> 10-element BitArray{1}:
>>>  false
>>>   true
>>>   true
>>>  false
>>>  false
>>>   true
>>>  false
>>>  false
>>>   true
>>>  false
>>>
>>> julia> find(a.>5,a)
>>> ERROR: no method find(BitArray{1}, Array{Float64,1})
>>>
>>> julia> find([a.>5],a)
>>> ERROR: no method find(BitArray{1}, Array{Float64,1})
>>>
>>> julia>
>>>
>>>
>>


Re: [julia-users] Re: ANN: Gumbo.jl (HTML parsing library)

2014-07-09 Thread Leah Hanson
This might be what you're looking for: https://github.com/Keno/URIParser.jl

-- Leah


On Wed, Jul 9, 2014 at 10:15 AM, Yuuki Soho  wrote:

> I've used it a little bit and it's very nice, great job!
>
> Just a related question, is there something to deal with html links
> currently in Julia, parsing all the ../, //, /, #, ? madness ? That would
> certainly be useful alongside Gumbo.
>


[julia-users] The Meaning of `const`

2014-07-08 Thread Leah Hanson
The only reference I can find in the manual to the `const` keyword is in
the performance section [1]. Well, that and the `isconst` function[2].

This seems like it would be worth documenting, especially since it behaves
significantly differently than the const that I remember from Java or C++,
which prevented you from changing the value of const variable.

I think I understand now, that `const` in Julia means that the type of the
variable must remain constant. This was very surprising to me.

~~~.jl
julia> const x = 10
10

julia> x += 1
Warning: redefining constant x
11

julia> x
11

julia> const arr = Int[1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> arr[1] = 13
13

julia> arr
3-element Array{Int64,1}:
 13
  2
  3

julia> x += 0.5
ERROR: invalid redefinition of constant x
~~~

I'd be happy to add this to the manual, but I'm not sure where it belongs.
Any suggestions?


1:
http://docs.julialang.org/en/latest/manual/performance-tips/?highlight=const#avoid-global-variables
2:
http://docs.julialang.org/en/latest/stdlib/base/?highlight=const#Base.isconst


Re: [julia-users] What's the scope for includes?

2014-07-06 Thread Leah Hanson
I'm not sure why it behaves differently inside the while loop, but I'm also
not sure how you can tell, since the function foo is already defined?

Maybe you could explain what your goal is. `include` basically pastes the
included file at the call site. Why are you re-including the same file
multiple times?

-- Leah


On Sun, Jul 6, 2014 at 2:48 AM, David A.  wrote:

> For instance:
>
>  file test_func.jl:
>
> function foo()
> println("This is foo")
> end
>
>
>  file test.jl:
>
> include("test_func.jl")
> foo()
> timewait(f, 10; pollint=1.0)
> include("test_func.jl")
> foo()
>
> while true
> include("test_func.jl")
> foo()
> end
>
>
>
> Both foo() outside the while-loop work well reloading the function foo()
> from file test_func.jl , but the include inside the while-loop doesn't
> reload it. So I guess it's a matter of scopes. How to make an include
> inside a loop to reload it's contents as it does outside of loops?
>


Re: [julia-users] Re: Lowering the (mostly social/psychological) barriers to sharing packages?

2014-07-01 Thread Leah Hanson
I think the ease of `Pkg.clone` for packages that aren't yet ready for
metadata is the biggest argument against an "extra metadata" thing.
Especially since `Pkg.clone` already handles reading the REQUIRE file in
the repo.

Maybe the thing to do is to advertise the steps to have people try your
code?

I think the steps are:
1. Repo on github in Pkg format (src folder, REQUIRE file, LICENSE file)
2. README with some install & usage instructions
3. Announce to julia-users with a description of what it is, why to use it,
link to repo

The main problem is discoverability, which is also a problem with
registered packages, which means a second package listing won't solve it.
Google does a reasonable job of indexing github readmes, so encouraging
packages to start with a couple sentences describing the package for a
context-free reader might be a way to improve "searchability" at least.

-- Leah


On Tue, Jul 1, 2014 at 8:57 PM, Randy Zwitch 
wrote:

> This doesn't seem like a great idea to me. I felt a great sense of
> accomplishment when I had my first package listed on METADATA, as I felt
> like I made a tangible contribution to the community (in the same way I'm
> proud of having a CRAN package). So for me, I'd question the value of
> having a package that's "sort of ok, but I'm not confident in it, and maybe
> I'll update it if someone compliments me or submits a pull request to
> extend the package..." It just seems so passive, when the barrier is
> actually pretty low to getting a package on METADATA (compared to the
> beatings that CRAN hands out).
>
> There's going to be good code and bad code, and having the hook into
> GitHub provides a great mechanism for continuous improvement. The Julia
> community is the friendliest that I'm a part of, but maybe we just need to
> do more to have people believe in themselves.
>
> What I do think we need is a better way to discover packages. For example,
> I had no idea what Nettle was until Viral (?) clued me into it having
> crypto functions.
>
>
>
> On Tuesday, July 1, 2014 9:07:47 PM UTC-4, Iain Dunning wrote:
>>
>> Hi all,
>>
>> Something that came up in some discussions I had at *JuliaCon* is that
>> people perceive packages in METADATA as being for more "serious" packages,
>> i.e. by being there there is an implication of a certain minimum quality. A
>> lot of my efforts in the package ecosystem have been try to help package
>> developers to live up to that expectation. A consequence of this perception
>> is that some people might be averse to list their work on METADATA, for
>> fear its not good enough/not ready.
>>
>> You can currently list a package on METADATA with:
>> - a version 0.0.0, which was the preferred way originally but is now
>> discouraged. This tagged version's hash would be updated as needed (i.e. it
>> doesn't follow master)
>> - a listing with no tagged version, which allows someone to do
>> Pkg.add("YourPkg") and automatically get the most up-to-date version of
>> your package.
>>
>> Of course, you pretty much need to announce your package somewhere other
>> than METADATA to let users know it exists, and users can you
>> Pkg.clone("..") almost as easily as Pkg.add("..") with a no-version
>> listing. Currently pkg.julialang.org doesn't show packages without a
>> version, so the no-version listing is of limited utility for
>> discoverability.
>>
>> A proposal that came up a few times at the conference was for some sort
>> of METADATA-EXTRA, which only has versions of packages without version
>> numbers and is open to everyone and anyone. It'd be super easy to add
>> packages - simply add a name and URL to a list. Perhaps it could be
>> accessed through a package not in Base, e.g. PkgExtra.
>> It would have
>> PkgExtra.update_listing() - refresh local list of package names and URLs
>> PkgExtra.add(pkgname..) - git clone a package to ~/.juila/v0.x/
>> PkgExtra.update(pkgname...) - git pull the packages
>> PkgExtra.rm(pkgname...) - nuke the packages
>> So basically, super simple. User could even be responsible for satisfying
>> any dependencies of the packages installed this way. At the most, the
>> REQUIRE in the package should be used, to keep this system as light-weight
>> as possible.
>>
>> So this wouldn't be much work to get going, but I was more curious to see
>> if there is actually demand for this. I'm worried its one of those things
>> people say they want, but I'm not sure if the demand is real. This might be
>> bad just in that it "forks" METADATA sort of, which is possibly not a great
>> idea for a new package. On the plus side, it could encourage even more
>> development and sharing.
>>
>> Thoughts?
>>
>


Re: [julia-users] how to call extern c function in julia?

2014-07-01 Thread Leah Hanson
You can model your C-struct type with a Julia type. Each field of the Julia
type should have a type annotation (Cint, etc) and be in the same order as
the C-struct.

Here's an example of Julia code wrapping a C library:
https://github.com/JuliaLang/HttpParser.jl/blob/master/src/HttpParser.jl

I think this is the C code it's wrapping:
https://github.com/joyent/http-parser/blob/master/http_parser.c

-- Leah


On Tue, Jul 1, 2014 at 1:16 AM,  wrote:

> I am newer to julia. I have build shared library of C language. I want to
> call some c funtions in Julia ,but I have some problems with the params
> type and return type.
>
> For example:
> the C funtion  1:
> MyType computer(int a, int b, ..){
> //some operator
> MyType result;
> return result;
> }
>
> The C function 2:
> void computer2(MyType c){
>   ...//some operator
> }
>
> In the funciton 2, I have to pass  the result of the function 1 to
> function 2. In julia, I can use "ccall( (:computer, pathToLib),returnType,
> ( Int32, Int32), a, b);
> but the "returnType" should be "MyType" in C, but how to define in Julia?,
> and how to pass the "ccall(...)" result to function 2?
>
>


Re: [julia-users] Reflection for function argument types

2014-06-29 Thread Leah Hanson
This is the PR: https://github.com/JuliaLang/julia/pull/7287

I've been told they're waiting to release 0.3 before merging it. There are
two methods; code_typed(Function) depends on code_typed(Method), but not
the other way around.

-- Leah


On Sun, Jun 29, 2014 at 7:56 PM, Elliot Saba  wrote:

> Mauro, that's neat.  Not quite what I'm looking for, (I think Leah has a
> code snippet that should work for me) but I'm definitely filing this code
> snippet away, as I'm sure I'll find a usage for it soon!
>  -E
>


Re: [julia-users] Re: Reflection for function argument types

2014-06-29 Thread Leah Hanson
So, you can also get code_typed of a Method of a Function. I have a PR to
make code_typed walk the methods of a Function (and also accept a Method
object), rather than requiring you to write the signature. Would either of
those work for you?

-- Leah


On Sun, Jun 29, 2014 at 4:03 PM, Elliot Saba  wrote:

> Just in case someone else is interested in this kind of stuff, here's my 
> simple
> test case .  I
> create a dynamic library that has a function that expects a callback in the
> form of a block, and calls it.  My motivation for this is that I am calling
> a private Apple framework that uses blocks extensively for callbacks, and
> I've been spoiled by Julia, so I didn't want to do everything in C.  Of
> course, this will probably generate even more problems along the way, but
> at least they'll be fun problems. :)
> -E
>
>
> On Sun, Jun 29, 2014 at 1:21 PM, Elliot Saba 
> wrote:
>
>> I'm having trouble figuring out how to get a function's argument types
>> from a macro.
>>
>> Specifically, I'm playing around with calling functions that expect
>> blocks as arguments from Julia.  I've got a simple case working, (which is
>> awesome) but it hard-codes knowledge of the block's signature, and I'd like
>> to dynamically generate that.  Ideally, I'd be able to do something like:
>>
>> block_struct = @block function( arg1::Float64 )
>> ...
>> return foo::Int64
>> end
>>
>> And the @block macro would be able to figure out the types of arg1 and
>> foo.  Is such a thing possible?  I need these types so that I can construct
>> a description of this function to pass off to the objective-c runtime,
>> allowing for objective-c code (And modern apple C++ code) to callback to
>> julia.  :)
>>  -E
>>
>
>


Re: [julia-users] Reflection for function argument types

2014-06-29 Thread Leah Hanson
So, you're trying to do this before/without actually having the method
definition evaluate? (These things are readily available from code_typed's
output, but you'd (I think) need to define the method first.)

-- Leah


On Sun, Jun 29, 2014 at 3:21 PM, Elliot Saba  wrote:

> I'm having trouble figuring out how to get a function's argument types
> from a macro.
>
> Specifically, I'm playing around with calling functions that expect blocks
> as arguments from Julia.  I've got a simple case working, (which is
> awesome) but it hard-codes knowledge of the block's signature, and I'd like
> to dynamically generate that.  Ideally, I'd be able to do something like:
>
> block_struct = @block function( arg1::Float64 )
> ...
> return foo::Int64
> end
>
> And the @block macro would be able to figure out the types of arg1 and
> foo.  Is such a thing possible?  I need these types so that I can construct
> a description of this function to pass off to the objective-c runtime,
> allowing for objective-c code (And modern apple C++ code) to callback to
> julia.  :)
>  -E
>


Re: [julia-users] ANN: TermWin.jl - a basic ncurses data navigation tool

2014-06-27 Thread Leah Hanson
That looks really cool. I'm going to have to play with this next time I
work on TypeCheck! :)

-- Leah


On Thu, Jun 26, 2014 at 3:52 AM, Tony Fong  wrote:

> Well, one thing leads to another. With Lint.jl, I have been dumping Expr
> and looking up its structure.
>
> Wouldn't it be great if I can browse Expr? So I wrote this:
>
> https://github.com/tonyhffong/TermWin.jl
>
> It's an interactive tree model navigator. It's not perfect. But I think
> it's useful. Like so:
>
> Julia > using TermWin
> Julia > ex = :( f(x) = x * x + 2x + 1 )
> Julia > tshow( ex )
>
> ┌─ 7.41%──┐
> │  +Expr   |Expr   |f(x) = x * x + 2x + 1 │
> │  | +head |Symbol |= │
> │  | +args |Array{Any,1}   |Size=2│
> │  | | +[1]|Expr   |f(x)  │
> │  | | | +head |Symbol |call  │
> │  | | | +args |Array{Any,1}   |Size=2│
> │  | | | | +[1]|Symbol |f │
> │  | | | | +[2]|Symbol |x │
> │  | | | +typ  |DataType   |Any   │
> │  | | +[2]|Expr   |x * x + 2x + 1│
> │  | | | +head |Symbol |call  │
> │  | | | +args |Array{Any,1}   |Size=4│
> │  | | | | +[1]|Symbol |+ │
> │  | | | | +[2]|Expr   |x * x │
> │  | | | | | +head |Symbol |call  │
> │  | | | | | =args |Array{Any,1}   |Size=3│
> │  | | | | | +typ  |DataType   |Any   │
> │  | | | | +[3]|Expr   |2x│
> │  | | | | | +head |Symbol |call  │
> │  | | | | | +args |Array{Any,1}   |Size=3│
> │  | | | | | | +[1]|Symbol |* │
> │  | | | | | | +[2]|Int64  |2 │
> │  | | | | | | +[3]|Symbol |x │
> │  | | | | | +typ  |DataType   |Any   │
> │  | | | | +[4]|Int64  |1 │
> └──F1:Help  Spc:Expand  Esc:exit──┘
>
> I'm not a ncurses expert at all, so there're some random update issues
> that I cannot pin down.
>
> It can browse a few things besides Expr, such as Module, Dict, Array,
> large strings.
>
> As usual, any feedback/PR would be welcome.
>
> Tony
>


[julia-users] A Question About `display`

2014-06-20 Thread Leah Hanson
My code calls `display` on a bunch of values (of a type I define). Most of
these values chose not to display anything; only a few of them are meant to
print anything at all. However, running the code currently generates a lot
of extra new lines for the non-printing values.

This is the main function being run:

~~~
function checkallmodule(m::Module;test=checkreturntypes,kwargs...)
  score = 0
  for n in names(m)
f = eval(m,n)
if isgeneric(f) && typeof(f) == Function
  fm = test(f;mod=m,kwargs...)
  score += length(fm.methods)
  display(fm)
end
  end
  println("The total number of failed methods in $m is $score")
end
~~~

The variable `fm` will be a FunctionSignature. The two relevant custom
types and their `writemime` methods are below:

~~~
type MethodSignature
  typs::Vector{AType}
  returntype::Union(Type,TypeVar) # v0.2 has TypeVars as returntypes; v0.3
does not
end
MethodSignature(e::Expr) = MethodSignature(argumenttypes(e),returntype(e))
function Base.writemime(io, ::MIME"text/plain", x::MethodSignature)
  println(io,"(",join([string(t) for t in x.typs],","),")::",x.returntype)
end

type FunctionSignature
  methods::Vector{MethodSignature}
  name::Symbol
end

function Base.writemime(io, ::MIME"text/plain", x::FunctionSignature)
  for m in x.methods
print(io,string(x.name))
display(m)
  end
end
~~~

The call to `display` in `checkallmodule` should end up calling `writemime`
for `FunctionSignature`. In the case that the `FunctionSignature` has no
methods, the for-loop will not execute and nothing should be displayed.
However, there are still a lot of new lines appearing when I run the code.

Does anyone have any pointers to what might be going wrong or how I might
avoid these new lines?

Thanks,
Leah


Re: [julia-users] Test for a warning

2014-06-20 Thread Leah Hanson
~~~
errormsg = @with_out_str begin
  ... code ...
end
~~~

should put the error message into errormsg.

-- Leah


On Fri, Jun 20, 2014 at 4:29 PM, Laszlo Hars  wrote:

> I am confused: I can change all the "out"s to "err"s, but what variable
> will contain the error message to be inspected? The error messages seem to
> only appear in the console, nowhere else.
>
>
> On Friday, June 20, 2014 2:47:28 PM UTC-6, Mike Innes wrote:
>>
>> function with_out_str(f::Function)
>>   orig_stdout = STDOUT
>>   rd, wr = redirect_stdout()
>>   f()
>>   redirect_stdout(orig_stdout)
>>   return readavailable(rd)
>> end
>>
>> macro with_out_str(expr)
>>   :(with_out_str(()->$expr)) |> esc
>> end
>>
>> You can use this as
>>
>> @with_out_str begin
>>   ... code ...
>> end
>>
>> But I think you'll need to change "stdout" to "stderr" in the above
>> definition to capture warnings.
>>
>> On Friday, 20 June 2014 21:35:51 UTC+1, Laszlo Hars wrote:
>>>
>>> Could someone help with redirecting stderr? For example, the following
>>> code does not get the error message shown in the Julia console in Windows
>>> 7, Julia Version 0.3.0-prerelease+3789:
>>> ~~~
>>> stderr_orig = STDERR
>>> rd, wr = redirect_stderr()
>>> 1^-1
>>> close(wr)
>>> eof(rd)
>>> close(rd)
>>> out = readall(rd)
>>> redirect_stderr(stderr_orig)
>>> ~~~
>>>
>>> On Friday, June 20, 2014 8:36:44 AM UTC-6, Jameson wrote:

 You could redirect_stderr and test for content writte
>>>
>>>


Re: [julia-users] Call for Unicode julia source examples

2014-06-20 Thread Leah Hanson
It's a bit silly, but it does have a unicode-named macro:
https://github.com/danluu/funarg

-- Leah


On Fri, Jun 20, 2014 at 10:24 AM, Jake Bolewski 
wrote:

> Thanks Jacob.  I should note that I'm already testing all packages in
> METADATA.
>
>
> On Friday, June 20, 2014 11:17:06 AM UTC-4, Jacob Quinn wrote:
>
>> Nothing that crazy, but Distributions.jl utilizes some unicode:
>> https://github.com/JuliaStats/Distributions.jl/
>> blob/master/src/univariate/normal.jl
>>
>>
>> On Fri, Jun 20, 2014 at 11:13 AM, Jake Bolewski 
>> wrote:
>>
>>> Keno fixed a bug in JuliaParser.jl dealing utf8 character sizes.  That
>>> fix, along with line number support I have in another branch would make the
>>> port of the parser pretty much complete.  I want to make sure that there
>>> are no other outstanding unicode issues.  If you have julia source code
>>> using lots of unicode characters could you share the links in this thread?
>>> If you don't want to post a link you could email me the source as well.
>>>
>>> Thanks,
>>> Jake
>>>
>>
>>


Re: [julia-users] Re: uncurried functions are ok... if you know what you are doing

2014-06-19 Thread Leah Hanson
You could also split that into multiple lines if readability is your goal:

~~~
sum(map(first,filter(x->x[1]!=x[2] && x[2]<=n &&
d[x[2]]==x[1],enumerate(d
~~~

becomes:

~~~
filtered = filter(enumerate(d)) do x
  x[1]!=x[2] && x[2]<=n && d[x[2]]==x[1] #expand to readability as desired
end
final = sum(map(first,filtered))
~~~

I'm not sure whether you "looks as if filter took only one argument"
comment was a request for explanation, but just in case: `do` syntax makes
the expression that follows it an anonymous function and passes it in as
the first argument to the preceding function call. You could use a
begin-end block in an in-line anonymous function to get the same effect
without do syntax.

Splitting this operation out over more lines won't affect efficiency; the
code is already allocating the temporary arrays (output of filter, output
of map), so giving them names won't cause the behavior to change. Splitting
this out over more lines with more variable names might make it easier to
read.

-- Leah


On Thu, Jun 19, 2014 at 2:57 AM, gentlebeldin 
wrote:

> Ah, I see, multiple dispatch is the real cause. I'll have to live with the
> little ideosyncrasy, then.
> Peter's idea filter(p -> +(p...)%4 != 0, pairs) works fine... in my simple
> example. In real life, I wanted to filter an array d of integers, with a
> predicate
> i<=n && d[i]!=i && d[d[i]]==i, so filter((i,v)->i<=n && v!=i &&
> d[v]==i,enumerate(d)) looked like a reasonable idea, it just doesn't work.
> We can make it work, though that looks a bit strange, too:
> filter([e for e in enumerate(d)]) do x
>i,v=x
>i<=n && v!=i && d[v]==i
>end
> Here, it looks as if the function filter took only one argument. It works,
> however. In my code, I had to sum up the values of i after filtering, so I
> chose the obscure formulation
> sum(map(first,filter(x->x[1]!=x[2] && x[2]<=n &&
> d[x[2]]==x[1],enumerate(d
>
>>
>>>


Re: [julia-users] Pass Keyword Argument Dictionary

2014-06-18 Thread Leah Hanson
Using the same print_args, here's a revised arg_collector:


julia> function arg_collector(;kwargs...)

   # do some operation on args

   print_args(;kwargs...) #always print args
   end
arg_collector (generic function with 1 method)

julia> arg_collector(x=5, y=6, z=7)
x 5 y 6 z 7


You need the `...` to splice the varargs into the function call, and you
need to put them after the `;` in the call to make the keyword arguments
(rather than normal varargs).

-- Leah



On Wed, Jun 18, 2014 at 4:36 PM, Steve Kelly  wrote:

> I have the following code that takes some keywords and does some
> operations. This is for a wrapper for Gcode (talking to 3D printers), so
> I'd like to specify an arbitrary axis to control. Below is what I would
> like to do.
>
> function print_args(;args...)
>> # do some formatting
>> str = ""
>> for (key, val) in args
>> str *= string(key, " " , val, " ")
>> end
>> println(str)
>> end
>>
>> function arg_collector(;args...)
>>
>> # do some operation on args
>>
>
> print_args(args) #always print args
>> end
>>
>> arg_collector(x=5, y=6, z=7)
>>
>
>  The obvious work around seems to be to dispatch onto a
> print_args(x::Array{Any,1}) and handle the formatting there. I'm not
> inclined to do that since it creates redundant code.
>
> Is there a succinct way to re-pass the keyword arguments to another
> function expecting only keyword arguments?
>
>


Re: [julia-users] Re: Project organization and CLI

2014-06-16 Thread Leah Hanson
Could you post a gist with all the files? (https://gist.github.com/)
It would be easier to understand what's going on if I could see the whole
thing.

Have you tried switching the order of the imports? `cli.jl` won't be able
to see `ngrams.jl` if all of cli is included & run first, before ngrams is
included & run.

-- Leah


On Mon, Jun 16, 2014 at 12:31 PM, TR NS  wrote:

> On Monday, June 16, 2014 12:56:29 PM UTC-4, Leah Hanson wrote:
>>
>> `include` is like copy-pasting the code from the included file into the
>> spot where you called include.
>>
>> You shouldn't have `module Corpus` in ngrams.jl.
>>
>
> Thanks. That helps me understand include().
>
> Unfortunately it doesn't seem to bring things together though. Per your
> advice, I add a new corpus.jl file:
>
> module Corpus
>   include("cli.jl")
>   include("ngrams.jl")
> end
>
> And I removed `module Corpus` from both cli.jl and ngrams.jl. Then in
> `bin/corpus` I change the include to `include("../code/corpus.jl")`. The
> end result is the error: `Ngrams not defined`. Apparently the cli.jl code
> can't see the ngrams.jl code?
>
>
>
>
>
>


Re: [julia-users] Re: Project organization and CLI

2014-06-16 Thread Leah Hanson
`include` is like copy-pasting the code from the included file into the
spot where you called include.

You shouldn't have `module Corpus` in ngrams.jl.

-- Leah


On Mon, Jun 16, 2014 at 11:53 AM, TR NS  wrote:

> Made a modicum of progress. I am not sure why, but it stopped hanging, and
> now I get a warning. "replacing module Corpus" and then an error that is
> can't find Ngrams.
>
> My `ngrams.jl` file starts out:
>
> module Corpus
>   module Ngrams
>
> And now I am pretty sure I totally don't understand how different files
> are supposed to be included together.
>
>
>
>


Re: [julia-users] Assigning variables in other modules vs. assigning to fields of types from other modules

2014-06-10 Thread Leah Hanson
I would guess that the difference is that `MyMod.b = 7.6` changes the value
that the variable is bound to, where `MyMod.a.val = 4.5` modifies the value
of the variable. This subtle difference is similar to a function that takes
and Int and an Array being able to make externally visible modifications to
the contents of the array, but not the Int.

(I'm sorry for explaining this poorly, I don't have a good vocabulary for
doing so.)


On Tue, Jun 10, 2014 at 1:10 PM, Brian Piper  wrote:

>
>
> This seems unexpected to me:
>
> module MyMod
>
> type AType
> val
> end
>
> global a = AType(5.0)
>
> global b = 10.0
>
> end
>
> Then in the REPL...
>
> julia> MyMod.b = 7.6
> ERROR: cannot assign variables in other modules
>
> julia> MyMod.a.val = 4.5
> 4.5
>
> So, in summation, no errors when assigning to fields of a composite type
> in another module, but an error with assigning to a variable in that
> module. Any insight as to what's going on here? Is this intended behavior,
> and if so, why?
>


Re: [julia-users] Type inheritance in Julia

2014-05-30 Thread Leah Hanson
Many people follow the google group by subscribing via email. This means
that removing a post doesn't help: it's already been sent out.

-- Leah


On Fri, May 30, 2014 at 6:03 PM,  wrote:

> But I removed the first one within 5 minutes! I'm sorry about that, and
> even more because the post is long.
>


Re: [julia-users] What's with the Nothing type?

2014-05-23 Thread Leah Hanson
Functions return the value that the final expression in them evaluated to.

function foo(x)
  x +=2
  5
end # => always returns 5

function bar(x)
  # blah blah ...
  println("hello world")
end # => always returns nothing, because that's what println returns

-- Leah


On Fri, May 23, 2014 at 5:00 PM, Dom Luna  wrote:

> That cleared it up, thanks! Do functions that don't explicitly return
> anything then implicitly return Nothing?
>
> Sorry I didn't catch the FAQ section, might it be better to have that as a
> short section in types?
>
> Dom
>
>
> On Friday, May 23, 2014 3:19:35 PM UTC-4, Stefan Karpinski wrote:
>
>> This FAQ entry may answer the question:
>>
>> http://docs.julialang.org/en/latest/manual/faq/#
>> nothingness-and-missing-values
>>
>> If not, maybe we can expand it or clarify whatever's not clear.
>>
>>
>> On Fri, May 23, 2014 at 2:40 PM, Dom Luna  wrote:
>>
>>> I just have general curiosity about the Nothing type, is there anything
>>> one should particularly know about it? Is it similar to a None type that
>>> one would typically find in pattern matching, ex. an Option type where it
>>> can be either Something or None, etc.
>>>
>>> I feel like Nothing and patterns for its use aren't well documented to
>>> this point.
>>>
>>> Dom
>>>
>>
>>


Re: [julia-users] Shameless plug for DotPlot.jl - plots in your terminal

2014-05-22 Thread Leah Hanson
Maybe something like TextPlot would be a good merged name? It conveys what
the package does (text plots) rather than how it does it (Braille
characters).

Having a more complete plotting package for the terminal would move towards
having a way to make `plot` just work when you start up a Julia REPL, which
I think is a goal. I'd be happy to help merge them, but probably won't have
time for a couple weeks.

-- Leah


On Thu, May 22, 2014 at 7:49 AM, Adam Smith
wrote:

> I'm not totally opposed to it, but my initial reaction is not to:
>
>1. I don't necessarily agree about the name. I personally think "dot
>plot" has a nice ring to it, and it is a more accurate description of what
>it does (using Braille characters). This very specifically exploits Unicode
>(non-ASCII) characters, so calling it an ASCII plot would be misleading
>(for those who want the restricted character set for some reason).
>2. There's not really a single line of code they have in common, so
>there's nothing to "merge": it would just be a rename. I didn't look at the
>code of ASCIIPlots before making it, and we chose completely different
>APIs. For example, ASCIIPlots doesn't have a way to plot functions, and
>DotPlot doesn't (yet) have a way to scatterplot an array.
>3. They are both quite small and simple (dotplot is ~100 lines of
>code, ascii is ~250); merging would probably be more work than either
>originally took to create.
>
>
> On Thursday, May 22, 2014 1:31:10 AM UTC-4, Ivar Nesje wrote:
>>
>> Would it make sense to merge this functionality into ASCIIPlots? To me
>> that seems like a better name, and John Myles White is likely to be willing
>> to transfer the repository if you want to be the maintainer. That package
>> started from code posted on the mailing list, and the author thought it was
>> a joke. John packaged it for others to use.
>
>


Re: [julia-users] Re: Problem with Composite type definition

2014-05-20 Thread Leah Hanson
You don't need the {T} on the constructor; being inside the type definition
gives you access to that T.

Your call to the constructor needs to have the type parameter explicitly.
The type parameter here indicates which type you want to create.
~~~
MyType{Float64}(zeros(Float64, 5), ["param"=>2.0])
~~~

Alternately, adding an outer constructor definition will make your call
work:
~~~
MyType{T}(data::Array{Float64,1}, meta::Dict{ASCIIString,T}) =
MyType{T}(data,meta)
~~~
(this just calls the inner constructor you already wrote.)



On Tue, May 20, 2014 at 2:15 PM, Davide Lasagna wrote:

> Ok, thanks. However, in my actual problem i have to use an inner
> constructor, something like
>
> type MyType{T}
> data::Array{Float64, 1}
> meta::Dict{ASCIIString, T}
> N::Int64
>
> function MyType{T}(data::Array{Float64, 1}, meta::Dict{ASCIIString, T})
> new(data, meta, length(data))
> end
>
> end
>
> This results in the same kind of "no method" error, like:
>
> MyType(zeros(Float64, 5), ["param"=>2.0])
>
> Why this? Any solution?
>
> Thanks,
>
> Davide
>
>
>
> On Monday, May 19, 2014 11:55:24 PM UTC+1, Ethan Anderes wrote:
>>
>> Your right….
>>
>> ["param" => 2.0] is of type Dict{ASCIIString,Float64} which is not a
>> subtype of Dict{ASCIIString,Number}
>>
>> You can use parametric types to solve your problem as follows:
>>
>> type MyType{T}
>>data::Array{Float64, 1}
>>meta::Dict{ASCIIString, T}
>>N::Int64
>> end
>> MyType{T}(data::Array{Float64, 1}, meta::Dict{ASCIIString, T}) = 
>> MyType(data, meta, length(data))
>>
>> Notice, that you also had an error when passing size(data) to MyType
>> since size(data) returns a tuple rather than an Int64. I changed it to
>> length(data) in the above example.
>> On Monday, May 19, 2014 2:53:38 PM UTC-7, Davide Lasagna wrote:
>>
>> Hi,
>>>
>>> I am starting with julia and stumbled upon this issue. Say I want to
>>> define this composite type
>>>
>>> type MyType
>>>data::Array{Float64, 1}
>>> meta::Dict{ASCIIString, Number}
>>> N::Int64
>>> end
>>> where the data field will store some floats, meta will be a dict of
>>> metadata (from a simulation), and N is some other number storing the size
>>> of data (just a silly example).
>>>
>>> Say I define another constructor as:
>>> MyType(data::Array{Float64, 1}, meta::Dict{ASCIIString, Number}) =
>>> MyType(data, meta, size(data))
>>>
>>>
>>> If I then create an instance with the default constructor I get the
>>> expected behaviour:
>>> MyType(zeros(Float64, 5), ["param"=>2], 5)
>>>
>>> "MyType([0.0,0.0,0.0,0.0,0.0],["param"=>2], 5)"
>>>
>>>
>>> However, if I use the additional constructor I obtain a
>>> MyType(zeros(Float64, 5), ["param"=>2.0])
>>>
>>> "no method MyType(Array{Float64,1}, Dict{ASCIIString,Float64})
>>> while loading In[4], in expression starting on line 1"
>>>
>>>
>>>
>>> As far as I understand, by reading the documentation regarding
>>> parametric composite types, the error is raised because Dict{ASCIIString
>>> , Float64} is not a subtype of Dict{ASCIIString, Number}.
>>>
>>> What is the approach to cope with this problem?
>>>
>>> Thanks,
>>>
>>> Davide
>>>
>>>


Re: [julia-users] Converting python code to julia

2014-05-20 Thread Leah Hanson
I don't know much about Julia's math libraries, so I'll leave that for
someone else.

In Julia, types are just data and functions use multiple dispatch to select
which values they work with.

For example, a Python class A with methods foo(self, x, y) and bar(self, z)
would become:

~~~
type A
  #properties of A go here
end

function foo(self::A, x, y)
  # whatever foo does
end

function bar(self::A, z)
  # whatever bar does
end
~~~

The function operate on A rather than being a part of it. The type
declaration on self (the "::A") makes the function operate on the type A,
similar to how the member functions of the Python class A operate on A.
This also provides flexibility, in that you can later define functions on
type A in a different file/module/library, without needing the edit type A
or the file/module/library that it's in at all.

Hope this is helpful,
Leah


On Tue, May 20, 2014 at 7:49 AM,  wrote:

> I want to convert some of my python code for exponential smoothing and
> Neural networks from python over to julia.
>
> My questions are:
>
> What should I do about the classes? I have not seen classes in julia yet
> so I am guessing they are all functions.
>
> Secondly what library should they go in. Julia has tons of math libraries
> scattered all over and not very consolidated (no library like 'Julia stats'
> or something).
>


Re: [julia-users] Re: Why do macros use the @ sign?

2014-05-20 Thread Leah Hanson
A macro has different rules from function calls, which are reflected in
it's different calling syntax. Macros have more power to affect your code
in strange ways; a macro's arguments may not get run (if the macro doesn't
use them), a macro could change the value of local variables not involved
in calling it, a macro can literally see anything your context can see.

While hygienic macros generally don't do those things unexpectedly, there
is a big difference between a function and a macro, even if you don't think
macros are "weird".


On Tue, May 20, 2014 at 8:34 AM, Andreas Lobinger wrote:

> Hi,
>
>
> On Tuesday, May 20, 2014 3:13:15 PM UTC+2, Ivar Nesje wrote:
>>
>> Macros are somewhat weird and a somewhat weird syntax seems appropriate
>> in my opinion. A macro is very different from a function, and a syntax that
>> sets it clearly visually apart is a good thing.
>>
>
> In your opinion. A macro is a function that creates code (or expressions),
> so not really something wierd...
> Wierd is julia's choice for concatenating strings: * But that's my opinion.
>
>


Re: [julia-users] Re: GSOC 3D Visualizations plotting API - Make a wish!

2014-05-19 Thread Leah Hanson
I'd like an interface that would make it relatively easy to implement
something like this: http://ubietylab.net/ubigraph/

I've run into (and had friends run into) problems visualization (directed)
graphs with thousands to hundreds of thousands of nodes. Ubigraph, linked
above, tended to crash at close to a thousand nodes when I was using it a
few years ago. I'm not aware of a tool to visualize graphs with thousands
or more nodes.

-- Leah


On Mon, May 19, 2014 at 2:35 PM, Simon Danisch  wrote:

> As I already said, your point is definitely valid. And that's why it is
> certainly a good idea to implement VTK bindings for Julia.
> But that person wont be me.
> I'm doing this project for very special reasons, and among others, one is
> that I'm sick of the fact, that every good visualization/3D rendering
> package is implemented in a language, that I don't want to use. I don't
> want to start a discussion about C++ here, but I think most people would
> agree, that it has a lot slower development cycles than higher level
> languages.
> That's why I ended up with Julia, because I'm hoping it's one of the first
> languages to make it possible to implement something performance sensitive
> like a 3D rendering engine in a fun to use language.
> Which would be awesome, as the other fun packages would have direct access
> to it, and not like in most other languages, have slow performance or work
> with a black box for visualizations.
>
>


Re: [julia-users] linear algebra speed comparisons with MATLAB

2014-05-18 Thread Leah Hanson
There are instructions in the Julia README and on Intel's website for
running Julia with MKL:

https://github.com/JuliaLang/julia#intel-math-kernel-libraries
https://software.intel.com/en-us/articles/julia-with-intel-mkl-for-improved-performance

-- Leah


On Sun, May 18, 2014 at 3:59 PM, Thomas Covert wrote:

> Seems like the windows and Mac versions of Julia call different
> blas/lapack routines.  Might that be the cause?  Is it possible for me to
> ask julia to use a different blas/lapack?
>
>
> On Sunday, May 18, 2014, J Luis  wrote:
>
>> Funny, in a similar machine (but running Windows) I get the opposite
>>
>> Matlab 2012a (32 bits)
>> >> tic; inv(K); toc
>> Elapsed time is 3.837033 seconds.
>>
>>
>> julia> tic(); inv(K); toc()
>> elapsed time: 1.157727675 seconds
>> 1.157727675
>>
>> julia> versioninfo()
>> Julia Version 0.3.0-prerelease+3081
>> Commit eb4bfcc* (2014-05-16 15:12 UTC)
>> Platform Info:
>>   System: Windows (x86_64-w64-mingw32)
>>   CPU: Intel(R) Core(TM) i7 CPU   M 620  @ 2.67GHz
>>   WORD_SIZE: 64
>>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
>>   LAPACK: libopenblas
>>   LIBM: libopenlibm
>>
>> Domingo, 18 de Maio de 2014 19:16:48 UTC+1, Thomas Covert escreveu:
>>>
>>> I am finding that MATLAB is considerably faster than Julia for simple
>>> linear algebra work on my machine (mid-2009 macbook pro).  Why might this
>>> be?  Is this an OpenBLAS vs Intel MKL issue?
>>>
>>> For example, on my machine, matrix inversion of a random, symmetric
>>> matrix is more than twice as fast in MATLAB as it is in Julia:
>>>
>>> MATLAB code:
>>> K = randn(2500,2500);
>>> K = K' * K;
>>> tic; inv(K); toc
>>> Elapsed time is 2.182241 seconds.
>>>
>>> Julia code:
>>> K = convert(Array{Float32},randn(2500,2500));
>>> K = K' * K;
>>> tic(); inv(K); toc()
>>> elapsed time: 6.249259727 seconds
>>>
>>> I'm running a fairly recent MATLAB release (2014a), and versioninfo() in
>>> my Julia install reads:
>>> Julia Version 0.3.0-prerelease+2918
>>> Commit 104568c* (2014-05-06 22:29 UTC)
>>> Platform Info:
>>>   System: Darwin (x86_64-apple-darwin12.5.0)
>>>   CPU: Intel(R) Core(TM)2 Duo CPU P8700  @ 2.53GHz
>>>   WORD_SIZE: 64
>>>BLAS: libgfortblas
>>>   LAPACK: liblapack
>>>   LIBM: libopenlibm
>>>
>>> Any advice is much appreciated.
>>>
>>>


Re: [julia-users] references in sets

2014-05-12 Thread Leah Hanson
The difference between those two lines is that "x" is a variable binding,
"x.a" is a reference inside "x". If the value that the variable"x" is bound
to is shared (as when you put it in a set), then modifying "x.a" will
modify that everywhere because it modifies the value x is bound to. "x =
new" binds x to a new value; this new binding of x is completely separate
from it's previous value and does not modify the previous value.

The above is another attempt at explanation. You asked for a rule to
memorize, so I'll try to give you one, although it is likely that there are
corner cases where understanding will serve you better:
1. Anything of the form  =  will behave like your
example of "t1 = testtype(false)" (does not modify other references)
2. Anything of the form . =  will
behave like your example of "t1.v = false" (does modify other references)

* Modifying functions (sort!, etc) will follow rule 2; non-modifying
functions (sort, etc) will follow rule 1.
* Setting array values (a[5] = 2) will follow rule 2, as will setting
values in other collections (these are syntactic sugar for setindex!, which
is a modifying function)


-- Leah


On Mon, May 12, 2014 at 7:14 PM, Andrew Dabrowski wrote:

>
> So it is OO 101, thanks.
>
> Note that to a programming naif the difference between
>
> x.a = new
>
> and
>
> x = new
>
> isn't very perspicuous, but in the first the value of x is modified (old
> pointer maintained?) while in the second it is replaced (new pointer?).  Is
> there a rule of thumb I can memorize so as to able to tell when a
> variable's value will be modified and when a new value will be created?  Is
> it just the use of = as assignment?
>
>


[julia-users] Trouble with Type Parameters

2014-05-11 Thread Leah Hanson
I'm playing with defining Linked Lists in Julia. The version I'm struggling
with involves having a type parameter on the node and list, that indicates
the type of the data in the list.

These are the types:
~~~
type List{T}
   head::Union(Node{T},Nothing)
end

type Node{T}
   data::T
   next::Union(Node{T},Nothing)
end
~~~

In order to add data to List, I'm implementing unshift!. My first version
worked pretty well:
~~~
function Base.unshift!{T}(l::List{T},item::T)
 new_node = Node{T}(item,l.head)
 l.head = new_node
 return l
end
~~~

However, when I make a List{String} and try to put an ASCIIString into it,
things go poorly:
~~~
julia> ll = List{String}(nothing)
[]

julia> unshift!(ll, "hello")
ERROR: no method unshift!(List{String}, ASCIIString)

julia> super(ASCIIString)
DirectIndexString

julia> super(ans)
String
~~~

I want to make unshift! work for this case. My next attempt results in an
error, so I'm not sure what to do:
~~~
julia> function unshift!{T,I<:T}(l::List{T},item::I)
 new_node = Node{T}(item,l.head)
 l.head = new_node
 return l
   end

ERROR: T not defined
~~~

This doesn't make sense to me. T is the first type variable that I declare.
If it's complaining about "I<:T", then shouldn't T already be defined by
then?

thanks,
Leah


Re: [julia-users] difference between inside and outside constructors

2014-05-08 Thread Leah Hanson
The main thing is that an inner constructor replaces the default
constructor.

AA(1,2)  # this will work.
BB(1,2)  # this will throw an error

You should also be able to see this in the output for "methods(AA)" and
"methods(BB)".

-- Leah


On Thu, May 8, 2014 at 5:51 PM, cnbiz850  wrote:

> Would anyone explain the differences between the following two ways of
> defining a composite type?
>
> =
> type AA
> aa
> bb
>
> function AA()
> aa=1
> bb=2
> new(aa,bb)
> end
> end
>
> type BB
> aa
> bb
>
> end
>
> function BB()
> aa=1
> bb=2
> return BB(aa,bb)
> end
>
>
>


Re: [julia-users] array with different column types

2014-05-08 Thread Leah Hanson
The version without @eval is better. You shouldn't use @eval if you don't
have to; it should be faster without it.

-- Leah


On Thu, May 8, 2014 at 2:42 PM, 'Stéphane Laurent' via julia-users <
julia-users@googlegroups.com> wrote:

> Actually I'm rather using the followig function allowing to remove several
> lines.
>
> function removeLines(poly::Poly, indices::BitArray{1})
>
>  for op = (:a, :b, :x1, :y1, :x2, :y2, :typ)
>
> @eval $poly.$op = ($poly.$op)[!$indices]
>
> end
>
> end
>
>
> function removeLines2(poly::Poly, indices::BitArray{1})
>
>  for op = (:a, :b, :x1, :y1, :x2, :y2, :typ)
>
> poly.(op) = (poly.(op))[!indices]
>
> end
>
> end
>
>
> Le jeudi 8 mai 2014 21:04:52 UTC+2, Stéphane Laurent a écrit :
>
>> Cool, thank you Jameson.
>>
>> So what is the best choice between these two possibilities :
>>
>> function removeLine(poly::Poly, index::Int)
>>
>> for op = (:a, :b, :x1, :y1, :x2, :y2, :typ)
>>
>> @eval splice!($poly.$op, $index)
>>
>> end
>>
>> end
>>
>>
>> function removeLine2(poly::Poly, index::Int)
>>
>> for op = (:a, :b, :x1, :y1, :x2, :y2, :typ)
>>
>> splice!(getfield(poly, op), index)
>>
>> end
>>
>> end
>>
>>


  1   2   >