[julia-users] Convert a string with commas into a float

2015-02-21 Thread AVF
What is the best way to convert a string such as 123,456 into a float 
123456.0? I could not find a method that would splice out a character from 
the middle of a string to feed the result to `float()`.

Thanks.


Re: [julia-users] Vectorized operation inside a function doesn't change a passed variable?

2015-01-20 Thread AVF
Thanks, Milan. Is there a way to predict a priori when the passed 
variable/object will be mutated? E.g., earlier last night I was surprised that 
my function below was mutating the passed data frame, not just the copy created 
inside the function.

function normalize(input_df::DataFrame, cols::Array{Int})
norm_df = input_df
for i in cols
norm_df[i] = (input_df[i] - minimum(input_df[i])) / 
(maximum(input_df[i]) - minimum(input_df[i]))
end
norm_df
end

[julia-users] Allowing keywords in function calls without default values

2015-01-19 Thread AVF
I want to write a function foo(x, y, z, many_more), which I could call as 
foo(1, 
2, 3, 5) or foo(1, 2, 3, many_more=5), but I don't want to have to supply a 
default value for many_more in my function's definition. I just want to 
have the option of not remembering the positions of x...many_more without 
required having default values for them.

Is that currently possible? Thanks...


[julia-users] Vectorized operation inside a function doesn't change a passed variable?

2015-01-19 Thread AVF
I just wanted to double-check that I understand it correctly: doing a 
vectorized operation to a passed variable inside a function will not change 
the variable on the outside? Does one have to resort to a `for` loop, or is 
there another way?

function foo!(x)

x += 10

end

 

function bar!(x)
[ x[i] += 10 for i in 1:size(x,1) ]
end

 

y = [1:3]

 

foo!(y)

println(y)

 

bar!(y)

println(y)


Output:

[1,2,3]

[1,2,3]

[11,12,13]


Thanks. 


[julia-users] Distances colwise issue, broadcasting question

2015-01-03 Thread AVF
On Friday afternoon, this code was working:

using Distances

a = rand(10,2)
b = rand(10,2)

colwise(Euclidean(), a', b')

Tonight it's not:

`colwise` has no method matching colwise(::Euclidean, ::Array{Float64,2}, 
::Array{Float64,2})


 I did run Pkg.update() in between, so maybe something changed?

Also, is there a way yet to do broadcasting? I.e. comparing a point pt = 
rand(1, 2) to an array a = rand(10, 2)? Thanks...


[julia-users] Re: IJulia indentation issue, custom.css question

2015-01-02 Thread AVF
Thanks. I definitely found a way how to break indentation, but couldn't 
figure out how to fix it. Or how to create a special class of highlighted 
words that follow function.

I see that if I write blah[] and press Enter after the first bracket, it 
will result in:

blah[
$
]

... with the cursor sitting where $ is (I am still in IJ notebook). The 
indentation is then respected (if I press Enter after the $ line, the next 
line is indented).

How do I make the same happen for parenthesis: ()? I want pressing Enter 
after the first parenthesis in blah() result in:

blah(
$
)


Thanks!


[julia-users] Re: Gadfly: adding plots to an existing plot

2015-01-01 Thread AVF
Thanks!

On Wednesday, December 31, 2014 8:25:47 PM UTC-6, Daniel Jones wrote:

 My mistake, it should work with append! instead of push!.

 For your second question, here's one option:
 a, b, c, d = [rand(10) for _ in 1:4]

 On Wednesday, December 31, 2014 5:58:15 PM UTC-8, AVF wrote:

 Sorry, doesn't seem to work:

 a = rand(10)

 b = rand(10)

 c = rand(10)

 d = rand(10)


 p = plot(x=a, y=b)

 push!(p.layers, layer(x=c, y=d))

 `convert` has no method matching convert(::Type{Layer}, ::Array{Layer,1})
 while loading In[185], in expression starting on line 9

  in push! at array.jl:457


 As an aside, is there a way to do something like:

 [a b c d] = rand(10,4)

  


 On Wednesday, December 31, 2014 11:01:36 AM UTC-6, Daniel Jones wrote:


 It's not really supported. Adding a push! function to add layers to 
 plots was proposed (https://github.com/dcjones/Gadfly.jl/issues/332), 
 but I haven't done so yet. In fact, adding layers to a plot p will usually 
 work with push!(p.layers, layer(...)), but that's kind of an unofficial 
 solution.



[julia-users] IJulia indentation issue, custom.css question

2015-01-01 Thread AVF
IJulia notebook automatically removes custom indentation if I type on the 
indented line. For example, in this code:

plot(
layer(twins, x=x, y=y, Geom.point, 
Theme(default_color=color(indianred), highlight_width=0.0mm)),
layer(points, x=x, y=y, Geom.point,
Theme(default_color=color(#4C72B0)))
)

... if I start typing on one of the indented lines, it will move the text 
all the way to the left. I am guessing it assumes the text doesn't need to 
be indented, since it's not a loop, etc., but I like sometimes indenting in 
such cases. Is there a way to turn this feature off?

Another question:

Also, if I want to change the color for the function name in IJulia, how do 
I do that? It doesn't seem to be different from variable, but is there a 
file, where I can add the function name into its own category? In IPython's 
custom.css, I was able to do this:

.cm-s-ipython span.cm-def { color: #A52A2A; font-weight: normal; }

Thanks!


[julia-users] Re: Gadfly: adding plots to an existing plot

2014-12-31 Thread AVF
So, if I created a plot in a block of code, and then want to add another 
array of data to it in another block of code, is that possible? (I.e., I 
find it inconvenient that I have only one chance to plot all the layers... 
or did I misunderstand how it works?)


[julia-users] Re: Gadfly: adding plots to an existing plot

2014-12-31 Thread AVF
Sorry, doesn't seem to work:

a = rand(10)

b = rand(10)

c = rand(10)

d = rand(10)


p = plot(x=a, y=b)

push!(p.layers, layer(x=c, y=d))

`convert` has no method matching convert(::Type{Layer}, ::Array{Layer,1})
while loading In[185], in expression starting on line 9

 in push! at array.jl:457


As an aside, is there a way to do something like:

[a b c d] = rand(10,4)

 


On Wednesday, December 31, 2014 11:01:36 AM UTC-6, Daniel Jones wrote:


 It's not really supported. Adding a push! function to add layers to 
 plots was proposed (https://github.com/dcjones/Gadfly.jl/issues/332), but 
 I haven't done so yet. In fact, adding layers to a plot p will usually work 
 with push!(p.layers, layer(...)), but that's kind of an unofficial 
 solution.



[julia-users] Kernel restaring issue, ZMQ build error

2014-12-27 Thread AVF
I have the IJulia kernel restarting issue that, based on my search, was 
supposed to have been resolved. After I start IJulia notebook, kernel keeps 
restarting every few seconds. I am running Julia on Linux Mint 17.1. The 
issue seems to be linked to ZMQ.

Error from running IJulia notebook:

2014-12-27 18:53:27.031 [NotebookApp] KernelRestarter: restarting kernel 
 (1/5)
 WARNING:root:kernel 5a345da2-dbf7-4388-b69e-1074add0e8bb restarted
 ERROR: could not open file /home/alex/.julia/v0.3/ZMQ/src/../deps/deps.jl
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in reload_path at loading.jl:152
  in _require at loading.jl:67
  in require at loading.jl:51
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in include at ./boot.jl:245
  in include_from_node1 at loading.jl:128
  in process_options at ./client.jl:285
  in _start at ./client.jl:354
 while loading /home/alex/.julia/v0.3/ZMQ/src/ZMQ.jl, in expression 
 starting on line 6
 while loading /home/alex/.julia/v0.3/IJulia/src/IJulia.jl, in expression 
 starting on line 13
 while loading /home/alex/.julia/v0.3/IJulia/src/kernel.jl, in expression 
 starting on line 4


Pkg.update() results in:

INFO: Updating METADATA...
 INFO: Computing changes...
 INFO: No packages to install, update or remove


 Finally:

julia Pkg.build(ZMQ)
INFO: Building ZMQ
INFO: Attempting to Create directory 
/home/alex/.julia/v0.3/ZMQ/deps/downloads
INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/downloads already created
INFO: Downloading file http://download.zeromq.org/zeromq-3.2.4.tar.gz
INFO: Done downloading file http://download.zeromq.org/zeromq-3.2.4.tar.gz
INFO: Attempting to Create directory /home/alex/.julia/v0.3/ZMQ/deps/src
INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/src already created
INFO: Attempting to Create directory /home/alex/.julia/v0.3/ZMQ/deps
INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps already created
INFO: Attempting to Create directory 
/home/alex/.julia/v0.3/ZMQ/deps/src/zeromq-3.2.4
INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/src/zeromq-3.2.4 already 
created
INFO: Attempting to Create directory 
/home/alex/.julia/v0.3/ZMQ/deps/builds/zmq
INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/builds/zmq already created
INFO: Changing Directory to /home/alex/.julia/v0.3/ZMQ/deps/builds/zmq
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... (cached) gawk
checking for xmlto... no
checking for asciidoc... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands +=... yes
checking how to convert x86_64-unknown-linux-gnu file names to 
x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain 
format... 

[julia-users] Re: Kernel restaring issue, ZMQ build error

2014-12-27 Thread AVF
Installing g++ solved the problem.

On Saturday, December 27, 2014 7:04:31 PM UTC-6, AVF wrote:

 I have the IJulia kernel restarting issue that, based on my search, was 
 supposed to have been resolved. After I start IJulia notebook, kernel keeps 
 restarting every few seconds. I am running Julia on Linux Mint 17.1. The 
 issue seems to be linked to ZMQ.

 Error from running IJulia notebook:

 2014-12-27 18:53:27.031 [NotebookApp] KernelRestarter: restarting kernel 
 (1/5)
 WARNING:root:kernel 5a345da2-dbf7-4388-b69e-1074add0e8bb restarted
 ERROR: could not open file /home/alex/.julia/v0.3/ZMQ/src/../deps/deps.jl
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in reload_path at loading.jl:152
  in _require at loading.jl:67
  in require at loading.jl:51
  in include at ./boot.jl:245
  in include_from_node1 at ./loading.jl:128
  in include at ./boot.jl:245
  in include_from_node1 at loading.jl:128
  in process_options at ./client.jl:285
  in _start at ./client.jl:354
 while loading /home/alex/.julia/v0.3/ZMQ/src/ZMQ.jl, in expression 
 starting on line 6
 while loading /home/alex/.julia/v0.3/IJulia/src/IJulia.jl, in expression 
 starting on line 13
 while loading /home/alex/.julia/v0.3/IJulia/src/kernel.jl, in expression 
 starting on line 4


 Pkg.update() results in:

 INFO: Updating METADATA...
 INFO: Computing changes...
 INFO: No packages to install, update or remove


  Finally:

 julia Pkg.build(ZMQ)
 INFO: Building ZMQ
 INFO: Attempting to Create directory 
 /home/alex/.julia/v0.3/ZMQ/deps/downloads
 INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/downloads already created
 INFO: Downloading file http://download.zeromq.org/zeromq-3.2.4.tar.gz
 INFO: Done downloading file http://download.zeromq.org/zeromq-3.2.4.tar.gz
 INFO: Attempting to Create directory /home/alex/.julia/v0.3/ZMQ/deps/src
 INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/src already created
 INFO: Attempting to Create directory /home/alex/.julia/v0.3/ZMQ/deps
 INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps already created
 INFO: Attempting to Create directory 
 /home/alex/.julia/v0.3/ZMQ/deps/src/zeromq-3.2.4
 INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/src/zeromq-3.2.4 already 
 created
 INFO: Attempting to Create directory 
 /home/alex/.julia/v0.3/ZMQ/deps/builds/zmq
 INFO: Directory /home/alex/.julia/v0.3/ZMQ/deps/builds/zmq already created
 INFO: Changing Directory to /home/alex/.julia/v0.3/ZMQ/deps/builds/zmq
 checking for a BSD-compatible install... /usr/bin/install -c
 checking whether build environment is sane... yes
 checking for a thread-safe mkdir -p... /bin/mkdir -p
 checking for gawk... gawk
 checking whether make sets $(MAKE)... yes
 checking how to create a ustar tar archive... gnutar
 checking whether make supports nested variables... yes
 checking for gcc... gcc
 checking whether the C compiler works... yes
 checking for C compiler default output file name... a.out
 checking for suffix of executables... 
 checking whether we are cross compiling... no
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ISO C89... none needed
 checking for style of include used by make... GNU
 checking dependency style of gcc... gcc3
 checking for gcc option to accept ISO C99... -std=gnu99
 checking for g++... no
 checking for c++... no
 checking for gpp... no
 checking for aCC... no
 checking for CC... no
 checking for cxx... no
 checking for cc++... no
 checking for cl.exe... no
 checking for FCC... no
 checking for KCC... no
 checking for RCC... no
 checking for xlC_r... no
 checking for xlC... no
 checking whether we are using the GNU C++ compiler... no
 checking whether g++ accepts -g... no
 checking dependency style of g++... none
 checking whether gcc -std=gnu99 and cc understand -c and -o together... yes
 checking for a sed that does not truncate output... /bin/sed
 checking for gawk... (cached) gawk
 checking for xmlto... no
 checking for asciidoc... no
 checking build system type... x86_64-unknown-linux-gnu
 checking host system type... x86_64-unknown-linux-gnu
 checking how to print strings... printf
 checking for a sed that does not truncate output... (cached) /bin/sed
 checking for grep that handles long lines and -e... /bin/grep
 checking for egrep... /bin/grep -E
 checking for fgrep... /bin/grep -F
 checking for ld used by gcc -std=gnu99... /usr/bin/ld
 checking if the linker (/usr/bin/ld) is GNU ld... yes
 checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
 checking the name lister (/usr/bin/nm -B) interface... BSD nm
 checking whether ln -s works... yes
 checking the maximum length of command line arguments... 1572864
 checking whether the shell understands some XSI constructs... yes
 checking whether the shell understands +=... yes
 checking how to convert x86_64-unknown