[julia-users] Why does the following give an error: p = 1; 2p+1 ??

2015-01-04 Thread Ronald L. Rivest
I'm using Julia 0.3.4 command line.
Entering
p = 1;  2p+1
gives an error:

*julia p = 1; 2p+1*

*ERROR: syntax: malformed expression*

whereas using a different variable name doesn't give an error

*julia x = 1; 2x+1*

*3*

There must be some aspect of Julia syntax I have missed??

Thanks for any light you can shed on this...

Cheers,

Ron Rivest


[julia-users] Re: Why does the following give an error: p = 1; 2p+1 ??

2015-01-04 Thread Jeff Waller
Also in 0.4.x this

*julia *
*2p+*
*(type-error double number #f)*
*unexpected error: #0 (read-number #io stream #f #f)**ERROR: syntax: 
malformed expression*




Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread elextr


On Monday, January 5, 2015 4:46:15 PM UTC+10, ivo welch wrote:

 dear tim, lex, todd (others):  thanks for responding.  I really want 
 to learn how to preprocess input from somewhere else into the 
 readcsv() function.  it's a good starting exercise for me to learn how 
 to accomplish tasks in general.  there is so much to learn.  [I did 
 not experiment with GZip.jl --- modules are new to me, and this one is 
 not included.  I could make too many errors in this process.  It will 
 probably make the specific task easier.] 

 now, the first mistake which tripped me up for a while is that I did 
 not grasp the difference between a string and a command.  that is, I 
 should not have used  for my command.  I had needed to use `.  this 
 is why open(echo hi) did not work, but open(`echo hi`) does. 


Yep correct.
 


 x=open(`gzcat myfile.csv.gz`) 

 is a good start.  I see it contains a tuple of a Pipe and a Process. 
 this is printed by default on the command line.  I learned I can make 
 this work with 

d=readcsv( x[1] ) 


Yes
 


 but I have a whole bunch of new questions, beyond question now. 
 first, try this: 

 julia x1=open(`gzcat d.csv.gz`) 
 (Pipe(closed, 35 bytes waiting),Process(`gzcat d.csv.gz`, 
 ProcessExited(0))) 

 julia x2=open(`gzcat d.csv.gz`) 
 (Pipe(active, 0 bytes waiting),Process(`gzcat d.csv.gz`, ProcessRunning)) 

 how strange---the claims are different.  


That may just be sampling effect, the gzcat is being run in another process 
so it runs at the same time as the current process.  Also see below for why 
the first call to open(command) may have been slower than the second and so 
the open has not completed until after the other process completed, but ran 
much faster the second time and beat the other process.
 

 even stranger, the first 
 readcsv(x2[1]) is very slow now (I am talking 3 seconds on a 3 by 4 
 data file!); but following it with readcsv(x1[1]) is fast.  I can't 
 imagine readcsv has intelligence built-in to cache past specific 
 conversions. 


No but the first time you do anything its possible that you are hitting 
compile delays from the JIT (of open and readcsv and all its dependents), 
subsequent runs are faster. 
 


 another strange definition from a novice perspective:  close(x1) is 
 not defined.  close(x1[1]) is.  


close() is defined for a stream, not a tuple (stream, process).
 

 julia is the first language I have 
 seen where a close(open(file)) is wrong. 


close(open(filenamestring)) is fine, close(open(command)) is not because 
open(command) returns a tuple of two things, not just the stream.  This is 
Julia's primary paradigm, multi-dispatch means that the same named function 
can have several methods that do different things depending on the *type* 
of the arguments to the call, string or command.
 

  this is esp surprising 
 because julia has the dispatch ability to understand what it could do 
 with a close(Pipe,Process) tuple. 


But only if such a close() method is defined, which it is not.  Maybe it 
should be, but open(command) is significantly less used than open(file).

Cheers
Lex

 

  the same holds true for other 
 functions that expect a part of open.  julia should be smart enough to 
 know this. 

 regards, 

 /iaw 

  
 Ivo Welch (ivo@gmail.com javascript:) 
 http://www.ivo-welch.info/ 
 J. Fred Weston Distinguished Professor of Finance 
 Anderson School at UCLA, C519 
 Director, UCLA Anderson Fink Center for Finance and Investments 
 Free Finance Textbook, http://book.ivo-welch.info/ 
 Exec Editor, Critical Finance Review, 
 http://www.critical-finance-review.org/ 
 Editor and Publisher, FAMe, http://www.fame-jagazine.com/ 


 On Sun, Jan 4, 2015 at 6:29 PM, Todd Leo sliznm...@gmail.com 
 javascript: wrote: 
  An intuitive thought is, uncompress your csv file via bash utility zcat, 
  pipe it to STDIN and use readline(STDIN) in julia. 
  
  
  
  On Monday, January 5, 2015 7:51:18 AM UTC+8, ivo welch wrote: 
  
  
  dear julia users:  beginner's question (apologies, more will be 
 coming). 
  it's probably obvious. 
  
  I am storing files in compressed csv form.  I want to use the built-in 
  julia readcsv() function.  but I also need to pipe through a 
 decompressor 
  first.  so, I tried a variety of forms, like 
  
 d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |) 
 d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`) 
  
  I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but 
  wrapping a readcsv around it does not capture it.  how does one do 
 this? 
  
  regards, 
  
  /iaw 
  
  



Re: [julia-users] printf float64 as hex/raw

2015-01-04 Thread Andreas Lobinger
I'm not sure, but if i change to gtk_version = 2 in ext.jl and run my code 
it imports and displays correctly. However, 
julia using Winston

julia plot(rand(8,8))

(julia:4874): GLib-GObject-WARNING **: /build/buildd/glib2.0-2.40.2/./
gobject/gsignal.c:2462: signal 'expose-event' is invalid for instance 
'0x719f1f0' of type 'GtkDrawingArea'

Winston.ini - gtk

On Sunday, January 4, 2015 11:55:46 AM UTC+1, Tobias Knopp wrote:

 Is Gtk2 still working for you (with Gtk.jl)? I tried this last week and 
 faced several issues until I gave up.

  

[julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread elextr
I think you need a macro, something like:

macro printvar(var)
   return :(print($(string(var))); print(=); println($var))
end

julia a=2
2

julia @printvar a
a=2

Cheers
Lex

On Sunday, January 4, 2015 8:48:27 PM UTC+10, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the 
 variable being passed to debugprint?



[julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread lapeyre . math122a
Not sure, but maybe this is what you are looking for,

https://gist.github.com/toivoh/4121122

On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr 
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm 
 probably doing things wrong.  But there are a lot of times where I end up 
 creating highly nested Expr objects, ending up with code that is 
 indecipherable.  I've found that the output from show_sexpr is sometimes 
 easier to read that that of dump or xdump (which only seems to display the 
 first couple of levels).  So I'm curious to see if the reverse 
 (s-expression - Expr) is also true.  

 If this function does not exist, would it be something that people would 
 find useful?

 Thanks and Happy New Years!

 Darwin



[julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread Arch Call
Thanks so much Lex .. That works ... Arch

On Sunday, January 4, 2015 5:48:27 AM UTC-5, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the 
 variable being passed to debugprint?



Re: [julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread Mike Innes
Have you met @show?

On 4 January 2015 at 11:10, ele...@gmail.com wrote:

 I think you need a macro, something like:

 macro printvar(var)
return :(print($(string(var))); print(=); println($var))
 end

 julia a=2
 2

 julia @printvar a
 a=2

 Cheers
 Lex

 On Sunday, January 4, 2015 8:48:27 PM UTC+10, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the
 variable being passed to debugprint?




[julia-users] Re: [ANN - SolveDSGE] A Julia package to solve DSGE models

2015-01-04 Thread Richard Dennis
Hi All,

I have added some new functionality to SolveDSGE that allows the solution 
of various linear-quadratic optimal policy problems to be computed. 
 Specifically, for various model forms, SolveDSGE can compute policies 
under:1) discretion; 2) commitment; 3) quasi-commitment; and 4) 
timeless-perspective commitment.  I hope that people find this 
functionality useful.

Richard
 


Re: [julia-users] How do I get the 'head' of a continuous stream of data?

2015-01-04 Thread Mike Innes
I'm not that familiar with HTTPClient.jl specifically, but usually if you
have a stream of data you can do

JSON.parse(io)

in a loop, and it will only block until the next JSON object is finished.

Julia doesn't do much that's Clojure-like by default but you may be
interested in Lazy.jl https://github.com/one-more-minute/Lazy.jl, which
provides Clojurey features like lazy sequences and dynamic binding. I don't
think it will solve your immediate problem, though.

On 4 January 2015 at 06:15, C. Bryan Daniels cdani...@nandor.net wrote:

 In Julia, if a function returns a continuous stream of data, is it
 possible to 'take' the head of the stream before the stream has terminated?
 I am used to Clojure which has many mechanisms to do exactly this? I assume
 this is due to the inherent laziness of Clojure.

 I made a previous post regarding a situation in which I was attempting to
 use 'HTTPClient' for a GET to a service that returns a continuous reply of
 json objects. I thought the following might work, but the fetch(r ) still
 blocks:

 rr = get(url, RequestOptions(blocking=false, ...))
 r = fetch(r ))
 readytes(r)

 Thanks.



[julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread paul analyst
How to overwrite to an existing file, only range of data?
In HDF5 can do this?
I have an array of zeros 10 x 10
I need an existing file owerwrite range rand (5x5), for example. 
Existingfile [2: 7.3: 8]
Paul


Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread Tim Holy
If I understand correctly, then yes, that's possible. See the HDF5 docs.

--Tim

On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote:
 How to overwrite to an existing file, only range of data?
 In HDF5 can do this?
 I have an array of zeros 10 x 10
 I need an existing file owerwrite range rand (5x5), for example.
 Existingfile [2: 7.3: 8]
 Paul



[julia-users] Is Julia a safe language? Including exception handling?

2015-01-04 Thread Páll Haraldsson

Hi,

First, for the intended users of Julia (and lots more), it seems to me 
exception handling is the way to go. You would much rather have your 
program stop with unhandled exception than the alternative, unchecked 
return code (as in C), and get wrong answers.

I've been thinking about how you can continue after an exception and that 
you probably can't in general.. and then saw this:

https://en.wikipedia.org/wiki/Exception_handling

Exception handling is commonly not resumable in those languages


I'm not sure what other languages, say Erlang, do. Could Julia never work 
for similiar things? Or are whole sub-systems just restarted?

If you get an exception in a function that mutates an array it seems there 
is nothing the caller can do.. But probably bad in most other languages. 
Not sure if this is one reason some other languages are pure functional.


Another issue I saw, uninitialized variables. Rust and others disallow, I 
think Julia does too (or easily could) except when constructing arrays 
(because of speed I guess). Wouldn't that be easily fixed? If similar() 
would zero-initialized. Maybe a command-line option for Julia? [Haven't 
looked to closely at pointers, at least not common to make arrays of 
pointers..]

Some languages have an unsafe subset, is that needed for Julia? I view 
ccall as an unsafe keyword, maybe the rest is safe.. except for the above?

-- 
Palli.



[julia-users] Re: Warning: imported binding for transpose overwritten in module __anon__

2015-01-04 Thread John Zuhone
Steven,

How difficult would it be to work a way to suppress this warning message? I 
general I would argue that it's best to avoid printing warnings to the 
screen unless there is something going on to be genuinely warned about, so 
as not to confuse the end-user. Since my package 
(http://github.com/jzuhone/YT.jl) depends on SymPy, this warning is shown 
every time one does using YT or import YT. It's a cosmetic issue, but 
it would still be nice to get rid of it. 

If suppressing it is doable, I'd be happy to investigate it myself and 
submit a PR. I'm not sure if this should be done in PyCall or in Julia 
itself somehow.

Best,

John Z

On Saturday, January 3, 2015 9:37:23 AM UTC-5, Steven G. Johnson wrote:

 You can safely ignore it.  @pyimport creates an module __anon__ (which is 
 assigned to plt in this case) that has definitions for the Python functions 
 in the Python module.   The warning is telling you that this module creates 
 its own transpose function instead of extending Base.transpose.  (It is a 
 warning because in many cases a module author would have intended to add a 
 new method to Base.transpose instead.)

 This is fine.  transpose in other modules still refers to Base.transpose, 
 and plt.transpose refers to the pylab one (== numpy transpose).

 --SGJ

 PS. By the way, I would normally import just pyplot and not pylab.  The 
 pylab module is useful in Python because it imports numpy too, and without 
 that you wouldn't have a lot of basic array functionality.  But in Julia 
 you already have the equivalent of numpy built in to Julia Base.   Also, I 
 would tend to recommend the Julia PyPlot module over manually importing 
 pyplot.  The PyPlot module adds some niceties like IJulia inline plots and 
 interactive GUI plots, whereas pylab is imported by default in 
 non-interactive mode.



Re: [julia-users] Is Julia a safe language? Including exception handling?

2015-01-04 Thread Tamas Papp
On Sun, Jan 04 2015, Páll Haraldsson pall.haralds...@gmail.com wrote:

 Another issue I saw, uninitialized variables. Rust and others disallow, I
 think Julia does too (or easily could) except when constructing arrays
 (because of speed I guess). Wouldn't that be easily fixed? If similar()
 would zero-initialized. Maybe a command-line option for Julia? [Haven't
 looked to closely at pointers, at least not common to make arrays of
 pointers..]

This was discussed very recently. See the thread here:

http://thread.gmane.org/gmane.comp.lang.julia.user/24227/

Best,

Tamas


Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread paul analyst
Of course, first I read :)
Is there about reading range array. I need to save a range of In analogy to.

A = reshape (1: 120, 15, 8)
h5write (/ tmp / test2.h5, mygroup2 / A, A)
data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5))

Paul


W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy 
napisał:

 If I understand correctly, then yes, that's possible. See the HDF5 docs. 

 --Tim 

 On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote: 
  How to overwrite to an existing file, only range of data? 
  In HDF5 can do this? 
  I have an array of zeros 10 x 10 
  I need an existing file owerwrite range rand (5x5), for example. 
  Existingfile [2: 7.3: 8] 
  Paul 



Re: [julia-users] Re: Disabling type instability in non-global scope

2015-01-04 Thread Ariel Keselman
Tim,

in your implementation you are assuming all possible types for x implement 
some operation performed inside the 'no do something with x' comment. Just 
making this assumption explicit allows solving the problem in a type-stable 
manner. Consider the following:

alias NumberArray union(Array{Int64,1}, etc. could use a macro to iterate 
over Number subtypes, or be defined in Base.

function read_x_in_files(filenames)
x::Numberrray
for fn in filenames
read!(x, fn, x)
# now do something with x
end
end

read_x_in_files((file1.jld, file2.jld))

The above solution is just as fast (or faster) than the type-unstable one, 
while being type stable, statically checkable before compilation. If the 
type of x actually doesn;t support any needed opertaion the runtime error 
would be raised in the 'read!' call. In the type-stable implementation it 
could be raised in the exact place where you are trying to use the 
unsupported operation, this could be anywhere inside the function. Here you 
have a version that handles all possible error at runtime:

function read_x_in_files(filenames)
x::Numberrray
for fn in filenames
try
read!(x, fn, x)
catch typeerror
message(skipping file *fn* because it contains an 
incompatible type)
continue
end
# now do something with x
end
end


Doing the same today is harder. Another solultion would be to just keep it 
type unstable inside a global scoped macro instead of a function, or inside 
a function tagged as type unstable.

Mike,

What is so special about Markdown.jl? I know of Markdown parsers 
implemented in statically typed languages (all 100% type stable) which are 
small, efficient and flexible. See for e.g. 
https://github.com/mfp/ocsiblog/blob/more-markdown-compat/simple_markup.ml 
which uses ~250 LOCs for parsing and another ~50 for rendering to HTML. Its 
said to be faster than discount which is written in C. Also how compliant 
is the Markdown.jl implementation? There are many shortcuts you can do to 
increase performance and code size/simplicity vs fully correct behavior. I 
know of a few fast parsers which seem type stable, for e.g. Python mistune, 
here: http://mistune.readthedocs.org/en/latest/
Anyway, the fastest Markdown must be sundown? (what github uses is based on 
this one) its fully compatible, and type stable, and its 2K lines but in C. 
I could simply traslate one of those, or even your implementation. I did 
skimmed it coarsely but didn't find any obvious type instabilities 
anyway... these can be hard to find even using tools

Now I guess I'll just conclude my point like this:

Type instability isn't really about speed. It's about reliably being able 
to modify your program when it gets bigger. At work (a corporate one) I was 
once promoting the use of Python, and I was always demonstrating how it is 
fast enough. I presented Numba, Cython, IO bound applications, etc. It took 
me a long time to understand that what people were really looking for is 
type-checks. its like an always sync'd documentation. It enables efficient 
refactoring, it compliments testing. 

I don't like the terms 'dynamic' and 'static' to describe languages. I much 
prefer 'interactive' and 'stable typed'. These seem more orthogonal 
concepts. In fact stable typed languages could still be interactive, and 
please don't think they are not flexible. We still have multiple dispatch, 
macros, eval at global scope, etc.

I think Julia is very good just as it is now, and it allows for many static 
checks to be performed, at least way more than other dynamic (or 
interactive) languages) like Python allow. 

Just please lets keep type instability to a minimum within the language and 
standard library. Lets also actively encourage type stability, all within 
the reasonable of course :)  Can we all agree on this?


Re: [julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Ismael VC
That's not documented:

help? dump
Base.dump(x)

   Show all user-visible structure of a value.

Are there any more options to dump?

On Sun, Jan 4, 2015 at 5:10 AM, lapeyre.math1...@gmail.com wrote:

 Not sure, but maybe this is what you are looking for,

 https://gist.github.com/toivoh/4121122


 On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm
 probably doing things wrong.  But there are a lot of times where I end up
 creating highly nested Expr objects, ending up with code that is
 indecipherable.  I've found that the output from show_sexpr is sometimes
 easier to read that that of dump or xdump (which only seems to display the
 first couple of levels).  So I'm curious to see if the reverse
 (s-expression - Expr) is also true.

 If this function does not exist, would it be something that people would
 find useful?

 Thanks and Happy New Years!

 Darwin




Re: [julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread Ismael VC
julia begin
   @show vara = 33
   @show varb = vara * 14
   @show varc = varb * 77
   end
vara = 33 = 33
varb = vara * 14 = 462
varc = varb * 77 = 35574
35574


On Sun, Jan 4, 2015 at 5:47 AM, Mike Innes mike.j.in...@gmail.com wrote:

 Have you met @show?

 On 4 January 2015 at 11:10, ele...@gmail.com wrote:

 I think you need a macro, something like:

 macro printvar(var)
return :(print($(string(var))); print(=); println($var))
 end

 julia a=2
 2

 julia @printvar a
 a=2

 Cheers
 Lex

 On Sunday, January 4, 2015 8:48:27 PM UTC+10, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the
 variable being passed to debugprint?





Re: [julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread Ismael VC
Reading the code, there is also a `indent` option, i thought it accepted a 
boolean, but not, I find it very unintuitive:

dump(io::IO, x, n::Int, indent) = xdump(dump, io, x, n, indent)


julia dump(:(1 + 1 * 3 - 4^7), 10, false)
Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol -
false2: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol +
false2: Int32 1
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol *
false2: Int32 1
false3: Int32 3
false  typ: Any
false  typ: Any
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol ^
false2: Int32 4
false3: Int32 7
false  typ: Any
false  typ: Any

And once can't use this argument, as a keyword argument:

julia dump(:(1 + 1 * 3 - 4^7), indent=---)
ERROR: function dump does not accept keyword arguments

Keyword arguments are slow? Or why are the not used that much throughout 
the API?




El domingo, 4 de enero de 2015 09:53:35 UTC-6, Ismael VC escribió:

 julia begin
@show vara = 33
@show varb = vara * 14
@show varc = varb * 77
end
 vara = 33 = 33
 varb = vara * 14 = 462
 varc = varb * 77 = 35574
 35574


 On Sun, Jan 4, 2015 at 5:47 AM, Mike Innes mike.j.in...@gmail.com wrote:

 Have you met @show?

 On 4 January 2015 at 11:10, ele...@gmail.com wrote:

 I think you need a macro, something like:

 macro printvar(var)
return :(print($(string(var))); print(=); println($var))
 end

 julia a=2
 2

 julia @printvar a
 a=2

 Cheers
 Lex

 On Sunday, January 4, 2015 8:48:27 PM UTC+10, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the 
 variable being passed to debugprint?





Re: [julia-users] Re: Disabling type instability in non-global scope

2015-01-04 Thread Mike Innes
To reiterate, static typing and type stability (in the Julia sense) are *not
the same concept*. To take an example from that ML Markdown parser:

type paragraph =
Normal of par_text
  | Pre of string * string option
  | Heading of int * par_text
  | Quote of paragraph list
  | Ulist of paragraph list * paragraph list list
  | Olist of paragraph list * paragraph list list

The paragraph type roughly corresponds to an abstract type in Julia. You
could happily have arrays of paragraphs, functions that return paragraphs,
etc., and in principle you could even type check that code to make it just
as safe as the ML version.

*But it wouldn't be type stable*, at least not in a way that gives you any
performance benefit, because you never know what concrete type (Normal, Pre
etc.) you're going to get, which means you have to fall back on dynamic
dispatch.

(Maybe what I'm calling type stability should be concrete type
stability instead. That's what I mean, anyway)

So enforcing type stability for performance would cripple the language, and
enforcing type safety wouldn't give any performance benefit.

That's not to say static typing isn't useful in many cases, but
implementing it globally for Julia would add a huge amount of complexity to
the compiler and core libraries. How do you statically type multimethods,
for example? Barring huge research breakthroughs in the near future, it's
just not really feasible.

Also; Scala is both fully type checked and interactive (though, crucially,
not type stable, since you can subclass), so that might be worth looking
into. (Julia wouldn't even be the first to do it)

On 4 January 2015 at 15:46, Ariel Keselman skar...@gmail.com wrote:

 Tim,

 in your implementation you are assuming all possible types for x implement
 some operation performed inside the 'no do something with x' comment. Just
 making this assumption explicit allows solving the problem in a type-stable
 manner. Consider the following:

 alias NumberArray union(Array{Int64,1}, etc. could use a macro to iterate
 over Number subtypes, or be defined in Base.

 function read_x_in_files(filenames)
 x::Numberrray
 for fn in filenames
 read!(x, fn, x)
 # now do something with x
 end
 end

 read_x_in_files((file1.jld, file2.jld))

 The above solution is just as fast (or faster) than the type-unstable one,
 while being type stable, statically checkable before compilation. If the
 type of x actually doesn;t support any needed opertaion the runtime error
 would be raised in the 'read!' call. In the type-stable implementation it
 could be raised in the exact place where you are trying to use the
 unsupported operation, this could be anywhere inside the function. Here you
 have a version that handles all possible error at runtime:

 function read_x_in_files(filenames)
 x::Numberrray
 for fn in filenames
 try
 read!(x, fn, x)
 catch typeerror
 message(skipping file *fn* because it contains an
 incompatible type)
 continue
 end
 # now do something with x
 end
 end


 Doing the same today is harder. Another solultion would be to just keep it
 type unstable inside a global scoped macro instead of a function, or inside
 a function tagged as type unstable.

 Mike,

 What is so special about Markdown.jl? I know of Markdown parsers
 implemented in statically typed languages (all 100% type stable) which are
 small, efficient and flexible. See for e.g.
 https://github.com/mfp/ocsiblog/blob/more-markdown-compat/simple_markup.ml
 which uses ~250 LOCs for parsing and another ~50 for rendering to HTML. Its
 said to be faster than discount which is written in C. Also how compliant
 is the Markdown.jl implementation? There are many shortcuts you can do to
 increase performance and code size/simplicity vs fully correct behavior. I
 know of a few fast parsers which seem type stable, for e.g. Python mistune,
 here: http://mistune.readthedocs.org/en/latest/
 Anyway, the fastest Markdown must be sundown? (what github uses is based
 on this one) its fully compatible, and type stable, and its 2K lines but in
 C. I could simply traslate one of those, or even your implementation. I did
 skimmed it coarsely but didn't find any obvious type instabilities
 anyway... these can be hard to find even using tools

 Now I guess I'll just conclude my point like this:

 Type instability isn't really about speed. It's about reliably being able
 to modify your program when it gets bigger. At work (a corporate one) I was
 once promoting the use of Python, and I was always demonstrating how it is
 fast enough. I presented Numba, Cython, IO bound applications, etc. It took
 me a long time to understand that what people were really looking for is
 type-checks. its like an always sync'd documentation. It enables efficient
 refactoring, it compliments testing.

 I don't like the terms 'dynamic' and 'static' to describe languages. I
 much prefer 'interactive' 

Re: [julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Ismael VC
julia begin
   @show vara = 33
   @show varb = vara * 14
   @show varc = varb * 77
   end
vara = 33 = 33
varb = vara * 14 = 462
varc = varb * 77 = 35574
35574


On Sun, Jan 4, 2015 at 5:47 AM, Mike Innes mike.j.in...@gmail.com wrote:

 Have you met @show?
 - mostrar texto citado -


   yo (Ismael VC cambiar)   
 10:22 (hace 3 minutos) 
   Re: [julia-users] Re: Debug printing a “value” and its “symbol”
 Traducir el mensaje al español   
Reading the code, there is also a `indent` option, i thought it accepted a 
boolean, but not, I find it very unintuitive:

dump(io::IO, x, n::Int, indent) = xdump(dump, io, x, n, indent)


julia dump(:(1 + 1 * 3 - 4^7), 10, false)
Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol -
false2: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol +
false2: Int32 1
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol *
false2: Int32 1
false3: Int32 3
false  typ: Any
false  typ: Any
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol ^
false2: Int32 4
false3: Int32 7
false  typ: Any
false  typ: Any

And once can't use this argument, as a keyword argument:

julia dump(:(1 + 1 * 3 - 4^7), indent=---)
ERROR: function dump does not accept keyword arguments

Keyword arguments are slow? Or why are the not used that much throughout 
the API?

El domingo, 4 de enero de 2015 09:46:21 UTC-6, Ismael VC escribió:

 That's not documented:

 help? dump
 Base.dump(x)

Show all user-visible structure of a value.

 Are there any more options to dump?

 On Sun, Jan 4, 2015 at 5:10 AM, lapeyre.math1...@gmail.com wrote:

 Not sure, but maybe this is what you are looking for,

 https://gist.github.com/toivoh/4121122


 On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr 
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm 
 probably doing things wrong.  But there are a lot of times where I end up 
 creating highly nested Expr objects, ending up with code that is 
 indecipherable.  I've found that the output from show_sexpr is sometimes 
 easier to read that that of dump or xdump (which only seems to display the 
 first couple of levels).  So I'm curious to see if the reverse 
 (s-expression - Expr) is also true.  

 If this function does not exist, would it be something that people would 
 find useful?

 Thanks and Happy New Years!

 Darwin




Re: [julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Ismael VC
Reading the code, there is also a `indent` option, i thought it accepted a 
boolean, but not, I find it very unintuitive:

dump(io::IO, x, n::Int, indent) = xdump(dump, io, x, n, indent)


julia dump(:(1 + 1 * 3 - 4^7), 10, false)
Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol -
false2: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol +
false2: Int32 1
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol *
false2: Int32 1
false3: Int32 3
false  typ: Any
false  typ: Any
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol ^
false2: Int32 4
false3: Int32 7
false  typ: Any
false  typ: Any

And once can't use this argument, as a keyword argument:

julia dump(:(1 + 1 * 3 - 4^7), indent=---)
ERROR: function dump does not accept keyword arguments

Keyword arguments are slow? Or why are the not used that much throughout 
the API?

El domingo, 4 de enero de 2015 09:46:21 UTC-6, Ismael VC escribió:

 That's not documented:

 help? dump
 Base.dump(x)

Show all user-visible structure of a value.

 Are there any more options to dump?

 On Sun, Jan 4, 2015 at 5:10 AM, lapeyre.math1...@gmail.com wrote:

 Not sure, but maybe this is what you are looking for,

 https://gist.github.com/toivoh/4121122


 On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr 
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm 
 probably doing things wrong.  But there are a lot of times where I end up 
 creating highly nested Expr objects, ending up with code that is 
 indecipherable.  I've found that the output from show_sexpr is sometimes 
 easier to read that that of dump or xdump (which only seems to display the 
 first couple of levels).  So I'm curious to see if the reverse 
 (s-expression - Expr) is also true.  

 If this function does not exist, would it be something that people would 
 find useful?

 Thanks and Happy New Years!

 Darwin




[julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Ismael VC
That's not documented:

help? dump
Base.dump(x)

   Show all user-visible structure of a value.


Reading the code, there is also a `indent` option, i thought it accepted a 
boolean, but not, I find it very unintuitive:

dump(io::IO, x, n::Int, indent) = xdump(dump, io, x, n, indent)


julia dump(:(1 + 1 * 3 - 4^7), 10, false)
Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol -
false2: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol +
false2: Int32 1
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol *
false2: Int32 1
false3: Int32 3
false  typ: Any
false  typ: Any
false3: Expr 
false  head: Symbol call
false  args: Array(Any,(3,))
false1: Symbol ^
false2: Int32 4
false3: Int32 7
false  typ: Any
That's not documented:

help? dump
Base.dump(x)

   Show all user-visible structure of a value.

Are there any more options to dump?false  typ: Any

And once can't use this argument, as a keyword argument:

julia dump(:(1 + 1 * 3 - 4^7), indent=---)
ERROR: function dump does not accept keyword arguments

Keyword arguments are slow? Or why are the not used that much throughout 
the API?

El domingo, 4 de enero de 2015 02:09:06 UTC-6, Ivar Nesje escribió:

 Not directly related to your question, but dump takes a optional parameter 
 to change the output limitation. 

 Eg: 
 dump(ex, 100) 
 prints a deeper version of the AST than 
 dump(ex)



Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread Adrian Cuthbertson
You can also work directly with the HDF5 file as an array object...

using HDF5

hfi=h5open(myfile.h5,w); # create the file
close(hfi)

 A = reshape(1: 120, 15, 8);

hfi = h5open(myfile.h5,r+) # read/write access

hfi[mygroup/A] = A
15x8 Array{Int64,2}:
  1  16  31  46  61  76   91  106
...
 14  29  44  59  74  89  104  119
 15  30  45  60  75  90  105  120

data = hfi[mygroup/A][2:3:15,3:5]
5x3 Array{Int64,2}:
 32  47  62
 35  50  65
 38  53  68
 41  56  71
 44  59  74

 hfi[mygroup/A][2:3,3:5]
2x3 Array{Int64,2}:
 32  47  62
 33  48  63

hfi[mygroup/A][2:3,3:5]=[-1 -2 -3; -4 -5 -6]
2x3 Array{Int64,2}:
 -1  -2  -3
 -4  -5  -6

hfi[mygroup/A][1:5,:]
5x8 Array{Int64,2}:
 1  16  31  46  61  76  91  106
 2  17  -1  -2  -3  77  92  107
 3  18  -4  -5  -6  78  93  108
 4  19  34  49  64  79  94  109
 5  20  35  50  65  80  95  110

foo = hfi[mygroup/A]
HDF5 dataset: /mygroup/A (file: myfile.h5)

foo[1:5,:]
5x8 Array{Int64,2}:
 1  16  31  46  61  76  91  106
 2  17  -1  -2  -3  77  92  107
 3  18  -4  -5  -6  78  93  108
 4  19  34  49  64  79  94  109
 5  20  35  50  65  80  95  110

close(hfi)

HDF5 is awesome!




On Sun, Jan 4, 2015 at 4:59 PM, paul analyst paul.anal...@mail.com wrote:

 Of course, first I read :)
 Is there about reading range array. I need to save a range of In analogy
 to.

 A = reshape (1: 120, 15, 8)
 h5write (/ tmp / test2.h5, mygroup2 / A, A)
 data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5))

 Paul


 W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy
 napisał:

 If I understand correctly, then yes, that's possible. See the HDF5 docs.

 --Tim

 On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote:
  How to overwrite to an existing file, only range of data?
  In HDF5 can do this?
  I have an array of zeros 10 x 10
  I need an existing file owerwrite range rand (5x5), for example.
  Existingfile [2: 7.3: 8]
  Paul




Re: [julia-users] Re: Disabling type instability in non-global scope

2015-01-04 Thread Tim Holy
From the standpoint of performance and memory allocation (i.e., boxing), what 
matters is whether types are concrete, because (currently) the compiler only 
generates optimized code for concrete types. Anything declared to be a Union 
type will have the same problems as something that's type-unstable (in a 
sense, this is indeed the definition of type-instability).

You can test whether a type is concrete with `isleaftype`. Here's a neat 
example:

function simplesum(A)
s = 0.0
@inbounds for a in A
s += a
end
s
end

Now compare

code_native(simplesum, (Array{Int},))

against

code_native(simplesum, (Array{Int,2},))

Also see:

julia isleaftype(Array{Int})
false

julia isleaftype(Array{Int,2})
true

In other words, simply declaring a type doesn't necessarily help matters, 
unless that type is concrete.

--Tim

On Sunday, January 04, 2015 07:46:45 AM Ariel Keselman wrote:
 Tim,
 
 in your implementation you are assuming all possible types for x implement
 some operation performed inside the 'no do something with x' comment. Just
 making this assumption explicit allows solving the problem in a type-stable
 manner. Consider the following:
 
 alias NumberArray union(Array{Int64,1}, etc. could use a macro to iterate
 over Number subtypes, or be defined in Base.
 
 function read_x_in_files(filenames)
 x::Numberrray
 for fn in filenames
 read!(x, fn, x)
 # now do something with x
 end
 end
 
 read_x_in_files((file1.jld, file2.jld))
 
 The above solution is just as fast (or faster) than the type-unstable one,
 while being type stable, statically checkable before compilation. If the
 type of x actually doesn;t support any needed opertaion the runtime error
 would be raised in the 'read!' call. In the type-stable implementation it
 could be raised in the exact place where you are trying to use the
 unsupported operation, this could be anywhere inside the function. Here you
 have a version that handles all possible error at runtime:
 
 function read_x_in_files(filenames)
 x::Numberrray
 for fn in filenames
 try
 read!(x, fn, x)
 catch typeerror
 message(skipping file *fn* because it contains an
 incompatible type)
 continue
 end
 # now do something with x
 end
 end
 
 
 Doing the same today is harder. Another solultion would be to just keep it
 type unstable inside a global scoped macro instead of a function, or inside
 a function tagged as type unstable.
 
 Mike,
 
 What is so special about Markdown.jl? I know of Markdown parsers
 implemented in statically typed languages (all 100% type stable) which are
 small, efficient and flexible. See for e.g.
 https://github.com/mfp/ocsiblog/blob/more-markdown-compat/simple_markup.ml
 which uses ~250 LOCs for parsing and another ~50 for rendering to HTML. Its
 said to be faster than discount which is written in C. Also how compliant
 is the Markdown.jl implementation? There are many shortcuts you can do to
 increase performance and code size/simplicity vs fully correct behavior. I
 know of a few fast parsers which seem type stable, for e.g. Python mistune,
 here: http://mistune.readthedocs.org/en/latest/
 Anyway, the fastest Markdown must be sundown? (what github uses is based on
 this one) its fully compatible, and type stable, and its 2K lines but in C.
 I could simply traslate one of those, or even your implementation. I did
 skimmed it coarsely but didn't find any obvious type instabilities
 anyway... these can be hard to find even using tools
 
 Now I guess I'll just conclude my point like this:
 
 Type instability isn't really about speed. It's about reliably being able
 to modify your program when it gets bigger. At work (a corporate one) I was
 once promoting the use of Python, and I was always demonstrating how it is
 fast enough. I presented Numba, Cython, IO bound applications, etc. It took
 me a long time to understand that what people were really looking for is
 type-checks. its like an always sync'd documentation. It enables efficient
 refactoring, it compliments testing.
 
 I don't like the terms 'dynamic' and 'static' to describe languages. I much
 prefer 'interactive' and 'stable typed'. These seem more orthogonal
 concepts. In fact stable typed languages could still be interactive, and
 please don't think they are not flexible. We still have multiple dispatch,
 macros, eval at global scope, etc.
 
 I think Julia is very good just as it is now, and it allows for many static
 checks to be performed, at least way more than other dynamic (or
 interactive) languages) like Python allow.
 
 Just please lets keep type instability to a minimum within the language and
 standard library. Lets also actively encourage type stability, all within
 the reasonable of course :)  Can we all agree on this?



Re: [julia-users] How do I get the 'head' of a continuous stream of data?

2015-01-04 Thread C. Bryan Daniels
Thanks for suggestion. I will check out Lazy.jl. Very nice feature to have 
built into a language. Regarding HTTPClient.jl, appears the current package 
doesn't support this feature. I was told to make a feature request, which I 
will do. Thanks for timely response.  

On Sunday, January 4, 2015 6:13:16 AM UTC-6, Mike Innes wrote:

 I'm not that familiar with HTTPClient.jl specifically, but usually if you 
 have a stream of data you can do

 JSON.parse(io)

 in a loop, and it will only block until the next JSON object is finished.

 Julia doesn't do much that's Clojure-like by default but you may be 
 interested in Lazy.jl https://github.com/one-more-minute/Lazy.jl, which 
 provides Clojurey features like lazy sequences and dynamic binding. I don't 
 think it will solve your immediate problem, though.

 On 4 January 2015 at 06:15, C. Bryan Daniels cdan...@nandor.net 
 javascript: wrote:

 In Julia, if a function returns a continuous stream of data, is it 
 possible to 'take' the head of the stream before the stream has terminated? 
 I am used to Clojure which has many mechanisms to do exactly this? I assume 
 this is due to the inherent laziness of Clojure.

 I made a previous post regarding a situation in which I was attempting to 
 use 'HTTPClient' for a GET to a service that returns a continuous reply of 
 json objects. I thought the following might work, but the fetch(r ) still 
 blocks:

 rr = get(url, RequestOptions(blocking=false, ...))
 r = fetch(r ))
 readytes(r)

 Thanks.




Re: [julia-users] printf float64 as hex/raw

2015-01-04 Thread Jameson Nash
Looks like expose-event in Gtk/cairo.jl is incorrectly declared to return
Void (should be Cint), but otherwise, that is the correct signal for Gtk2.

However, note that the BinDeps deps.jl file ignores this configuration
option and must be deleted for it to work.


On Sun Jan 04 2015 at 6:06:01 AM Andreas Lobinger lobing...@gmail.com
wrote:

 I'm not sure, but if i change to gtk_version = 2 in ext.jl and run my code
 it imports and displays correctly. However,
 julia using Winston

 julia plot(rand(8,8))

 (julia:4874): GLib-GObject-WARNING **: /build/buildd/glib2.0-2.40.2/./
 gobject/gsignal.c:2462: signal 'expose-event' is invalid for instance
 '0x719f1f0' of type 'GtkDrawingArea'

 Winston.ini - gtk


 On Sunday, January 4, 2015 11:55:46 AM UTC+1, Tobias Knopp wrote:

 Is Gtk2 still working for you (with Gtk.jl)? I tried this last week and
 faced several issues until I gave up.




Re: [julia-users] printf float64 as hex/raw

2015-01-04 Thread Jameson Nash
Gtk3 hasn't changed that much in this area -- it is still incorrect to
call gdk_window_get_device_position  friends from event handlers.

It seems that if you want or expect an integer, then you should just
truncate/round the event.x / event.y values.

On Sun Jan 04 2015 at 4:43:30 AM Andreas Lobinger lobing...@gmail.com
wrote:

 The code in Gtk/events.jl, signals.jl and cairo.jl is clearly gtk2 style
 and working correctly. However in Gtk3 the event reporting slightly
 changed, so using event-x and event-y returns (somehow) subpixel
 resolution (which makes sense for some pointer devices, maybe not for a
 mouse pointer), to get the 'regular' pixel resolution one needs to call 
 gdk_window_get_device_position
 for events with event.is_hint = true. The Gtk3 documentation is blurry in
 this case why this is needed or if it's just a side effect of some missing
 configuration.

 (and actually just truncating the subpixel resolution to integers would
 also not introduce a performance problem...)

 For code written in gtk2 style and maybe using the event coordinates to
 draw something on screen and even maybe in cairo you might run into
 problem, just using the entries in event.x and .y IF the unterlying library
 isn't gtk2 anymore, but gtk3. If i use the rubberband in ImageView (gtk
 branch) i get artifacts of the rubberband draw and redrawing. Which should
 not be there on integer coordinates.

 Gtk3 is not fully backward compatible to Gtk2 (it doesn't claim to be), so
 we have to live with workarounds here.



 https://lh5.googleusercontent.com/-hHJ9sEm9W_I/VKkKhEkXPEI/ABs/QFJBwS9wFeA/s1600/snapshot1.png



[julia-users] Julia takes 2nd place in Delacorte Numbers competition

2015-01-04 Thread Arch Robison
FYI, I won 2nd place in the recent Al Zimmerman programming contest Delacorte 
Numbers http://trdb.org/Contest/DelacorteNumbers/Standings, using only 
Julia and a quad-core MonkeyStation Pro 
http://www.blonzonics.us/odd/monkeystation-pro.   Julia worked out well 
because it had:

   - interactivity to study the problem
   - quick prototyping to try ideas
   - fast scalar code
   - fast SIMD loops 

I've working on a paper that will describe the experience in more detail.

- Arch



Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread Tim Holy
See the part about ...incrementally save to very large ...

--Tim

On Sunday, January 04, 2015 06:59:53 AM paul analyst wrote:
 Of course, first I read :)
 Is there about reading range array. I need to save a range of In analogy to.
 
 A = reshape (1: 120, 15, 8)
 h5write (/ tmp / test2.h5, mygroup2 / A, A)
 data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5))
 
 Paul
 
 
 W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy
 
 napisał:
  If I understand correctly, then yes, that's possible. See the HDF5 docs.
  
  --Tim
  
  On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote:
   How to overwrite to an existing file, only range of data?
   In HDF5 can do this?
   I have an array of zeros 10 x 10
   I need an existing file owerwrite range rand (5x5), for example.
   Existingfile [2: 7.3: 8]
   Paul



Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread Tim Holy
Do note there are two additional pages of documentation in the doc/ folder.

--Tim

On Sunday, January 04, 2015 06:59:53 AM paul analyst wrote:
 Of course, first I read :)
 Is there about reading range array. I need to save a range of In analogy to.
 
 A = reshape (1: 120, 15, 8)
 h5write (/ tmp / test2.h5, mygroup2 / A, A)
 data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5))
 
 Paul
 
 
 W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy
 
 napisał:
  If I understand correctly, then yes, that's possible. See the HDF5 docs.
  
  --Tim
  
  On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote:
   How to overwrite to an existing file, only range of data?
   In HDF5 can do this?
   I have an array of zeros 10 x 10
   I need an existing file owerwrite range rand (5x5), for example.
   Existingfile [2: 7.3: 8]
   Paul



Re: [julia-users] Julia takes 2nd place in Delacorte Numbers competition

2015-01-04 Thread Tim Holy
Very cool. Congratulations, and thanks for sharing the good news!

--Tim

On Sunday, January 04, 2015 09:35:46 AM Arch Robison wrote:
 FYI, I won 2nd place in the recent Al Zimmerman programming contest
 Delacorte Numbers http://trdb.org/Contest/DelacorteNumbers/Standings,
 using only Julia and a quad-core MonkeyStation Pro
 http://www.blonzonics.us/odd/monkeystation-pro.   Julia worked out well
 because it had:
 
- interactivity to study the problem
- quick prototyping to try ideas
- fast scalar code
- fast SIMD loops
 
 I've working on a paper that will describe the experience in more detail.
 
 - Arch



[julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Darwin Darakananda
Thanks! That's exactly what I was looking for.  The show_sexpr code 
actually looks basically identical to what's in Base, I wonder why 
sexpr_to_expr 
didn't make it.

On Sunday, January 4, 2015 3:10:15 AM UTC-8, lapeyre@gmail.com wrote:

 Not sure, but maybe this is what you are looking for,

 https://gist.github.com/toivoh/4121122

 On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr 
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm 
 probably doing things wrong.  But there are a lot of times where I end up 
 creating highly nested Expr objects, ending up with code that is 
 indecipherable.  I've found that the output from show_sexpr is sometimes 
 easier to read that that of dump or xdump (which only seems to display the 
 first couple of levels).  So I'm curious to see if the reverse 
 (s-expression - Expr) is also true.  

 If this function does not exist, would it be something that people would 
 find useful?

 Thanks and Happy New Years!

 Darwin



[julia-users] Re: Julia takes 2nd place in Delacorte Numbers competition

2015-01-04 Thread lapeyre . math122a
Congratulations! Awesome. Don't know if this is Arch D or Arch S. The 
scores look even closer than
track and field 
http://www.blonzonics.us/home/robison-family/2014_4x800_relay_team times.

On Sunday, January 4, 2015 6:35:46 PM UTC+1, Arch Robison wrote:

 FYI, I won 2nd place in the recent Al Zimmerman programming contest 
 Delacorte 
 Numbers http://trdb.org/Contest/DelacorteNumbers/Standings, using only 
 Julia and a quad-core MonkeyStation Pro 
 http://www.blonzonics.us/odd/monkeystation-pro.   Julia worked out well 
 because it had:

- interactivity to study the problem
- quick prototyping to try ideas
- fast scalar code
- fast SIMD loops 

 I've working on a paper that will describe the experience in more detail.

 - Arch



[julia-users] Constructing Expr from s-expressions

2015-01-04 Thread Ivar Nesje
Not directly related to your question, but dump takes a optional parameter to 
change the output limitation. 

Eg:
dump(ex, 100)
prints a deeper version of the AST than
dump(ex)

[julia-users] Re: Julia for Enterprise?

2015-01-04 Thread Eric Forgy
Thank you Viral, Keno, Tobias, and Imanuel. This has been helpful.

Here are my thoughts:

   - It is too early to introduce Julia into my conservative client's 
   corporate environments at the moment. We'll continue with Matlab with an 
   eye toward transitioning to Julia in the coming years.
   - It is not too early to build Julia into my own cloud-based 
   environment. 



Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread Amit Murthy
Does the service definition have a query parameter where you can specify
the number of objects required?

As long as the server end of the connection is open, and the server is
pushing data, the client will continue to receive it, and currently there
is no way to control the same.

Controlling the stream from the client side can be implemented - could you
file a feature request for the same on github?


On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdani...@nandor.net
wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but am
 having trouble properly configuring the output stream. Specifically, the
 API to a particular service responds to a 'get' call with a stream of json
 objects. The code snippets below work as expected by returning a continuous
 steam of json objects; I can terminate the stream with ctr-C.  What I
 really want is to be able to get a specific number of json objects. I've
 played around with options: ostream=some-file, ostream=IOBuffer() and
 blocking=false. This is probably a basic question, but any help in solving
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(
 headers=headers,content_type=application/json,ostream=STDOUT)


 function get(lb::LittleBit)


 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)


 end



Re: [julia-users] printf float64 as hex/raw

2015-01-04 Thread Andreas Lobinger
The code in Gtk/events.jl, signals.jl and cairo.jl is clearly gtk2 style 
and working correctly. However in Gtk3 the event reporting slightly 
changed, so using event-x and event-y returns (somehow) subpixel 
resolution (which makes sense for some pointer devices, maybe not for a 
mouse pointer), to get the 'regular' pixel resolution one needs to call 
gdk_window_get_device_position 
for events with event.is_hint = true. The Gtk3 documentation is blurry in 
this case why this is needed or if it's just a side effect of some missing 
configuration.

(and actually just truncating the subpixel resolution to integers would 
also not introduce a performance problem...)

For code written in gtk2 style and maybe using the event coordinates to 
draw something on screen and even maybe in cairo you might run into 
problem, just using the entries in event.x and .y IF the unterlying library 
isn't gtk2 anymore, but gtk3. If i use the rubberband in ImageView (gtk 
branch) i get artifacts of the rubberband draw and redrawing. Which should 
not be there on integer coordinates. 

Gtk3 is not fully backward compatible to Gtk2 (it doesn't claim to be), so 
we have to live with workarounds here.


 
https://lh5.googleusercontent.com/-hHJ9sEm9W_I/VKkKhEkXPEI/ABs/QFJBwS9wFeA/s1600/snapshot1.png


Re: [julia-users] Re: How quickly subtract the two large arrays ?

2015-01-04 Thread Paul Analyst
Suppose the array is located in memory. There are a lot of columns to 
count eg. Average. As a parallel process count because now 7 of 8 
processors doing nothing.

Paul

W dniu 2015-01-03 o 23:27, ele...@gmail.com pisze:



On Sunday, January 4, 2015 4:28:06 AM UTC+10, paul analyst wrote:

THX
A have not :/ but I can makes it in parts!


If the arrays won't fit in memory it probably doesn't matter what 
Julia does, the IO or paging time will dominate.


Cheers
Lex


How simply use parallel for it? I have 8 proc, is working only 1
Paul




W dniu piątek, 15 sierpnia 2014 11:53:54 UTC+2 użytkownik Billou
Bielour napisał:

This might be a bit faster:

function sub!(A,B,C)
for j=1:size(A,2)
for i=1:size(A,1)
@inbounds C[i,j] = A[i,j] - B[i,j]
end
end
end

C = zeros(size(A));
sub!(A,B,C)

Do you have enough RAM to store these matrices though ? 10^5 *
10^5 Float64 seems rather large.





Re: [julia-users] Distances colwise issue, broadcasting question

2015-01-04 Thread Tim Holy
Works for me, on both 0.3 and 0.4.

Re broadcasting, see the help for `broadcast`; also, operators with a dot in 
front of them, e.g. `.+`, broadcast.

--Tim

On Saturday, January 03, 2015 06:04:44 PM AVF wrote:
 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] Debug printing a “value” and its “symbol”

2015-01-04 Thread Arch Call


I frequently find myself writing Julia snippet scripts like this:


 vara = 33

varb = vara * 14

varc = varb * 77

println(“varb = “, varb) #--debug print

println(“varc = “, varc) #--debug print


 I would like to eliminate having to enter the variable name twice

in the debug print lines by using a function.


 I have tried all kinds of variations of a debug print function like:


 function debugprint(somevar)

println(“ = ”, somevar)

end


 What can I put in place of “” to get the actual Symbol of the variable 
being passed to debugprint?


Re: [julia-users] printf float64 as hex/raw

2015-01-04 Thread Tobias Knopp
Is Gtk2 still working for you (with Gtk.jl)? I tried this last week and 
faced several issues until I gave up.

Am Sonntag, 4. Januar 2015 10:43:29 UTC+1 schrieb Andreas Lobinger:

 The code in Gtk/events.jl, signals.jl and cairo.jl is clearly gtk2 style 
 and working correctly. However in Gtk3 the event reporting slightly 
 changed, so using event-x and event-y returns (somehow) subpixel 
 resolution (which makes sense for some pointer devices, maybe not for a 
 mouse pointer), to get the 'regular' pixel resolution one needs to call 
 gdk_window_get_device_position 
 for events with event.is_hint = true. The Gtk3 documentation is blurry in 
 this case why this is needed or if it's just a side effect of some missing 
 configuration.

 (and actually just truncating the subpixel resolution to integers would 
 also not introduce a performance problem...)

 For code written in gtk2 style and maybe using the event coordinates to 
 draw something on screen and even maybe in cairo you might run into 
 problem, just using the entries in event.x and .y IF the unterlying library 
 isn't gtk2 anymore, but gtk3. If i use the rubberband in ImageView (gtk 
 branch) i get artifacts of the rubberband draw and redrawing. Which should 
 not be there on integer coordinates. 

 Gtk3 is not fully backward compatible to Gtk2 (it doesn't claim to be), so 
 we have to live with workarounds here.


  
 https://lh5.googleusercontent.com/-hHJ9sEm9W_I/VKkKhEkXPEI/ABs/QFJBwS9wFeA/s1600/snapshot1.png



[julia-users] Test-scoped requirements

2015-01-04 Thread Andrei Zh
I have a package A that has file-based integration with package B, i.e. A 
writes files that B can read, but neither A depends on B, nor vise versa. I 
want to write a test for this integration, but don't want to include B in 
REQUIRE, since A may be used completely without it. 

I'm wondering if there's a way to specify requirement for test time only. 
If not, what are general recommendations in this case? 


[julia-users] Re: Test-scoped requirements

2015-01-04 Thread Michael Hatherly


You can put a REQUIRE file in the test directory that should do what you 
want.

— Mike
​


On Sunday, 4 January 2015 21:33:37 UTC+2, Andrei Zh wrote:

 I have a package A that has file-based integration with package B, i.e. A 
 writes files that B can read, but neither A depends on B, nor vise versa. I 
 want to write a test for this integration, but don't want to include B in 
 REQUIRE, since A may be used completely without it. 

 I'm wondering if there's a way to specify requirement for test time only. 
 If not, what are general recommendations in this case? 



Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread paul analyst
Thx, form me this moment 

*hfi[mygroup/A] = A*

was not too clear 

Paul

W dniu niedziela, 4 stycznia 2015 18:37:30 UTC+1 użytkownik Tim Holy 
napisał:

 See the part about ...incrementally save to very large ... 

 --Tim 

 On Sunday, January 04, 2015 06:59:53 AM paul analyst wrote: 
  Of course, first I read :) 
  Is there about reading range array. I need to save a range of In analogy 
 to. 
  
  A = reshape (1: 120, 15, 8) 
  h5write (/ tmp / test2.h5, mygroup2 / A, A) 
  data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5)) 
  
  Paul 
  
  
  W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy 
  
  napisał: 
   If I understand correctly, then yes, that's possible. See the HDF5 
 docs. 
   
   --Tim 
   
   On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote: 
How to overwrite to an existing file, only range of data? 
In HDF5 can do this? 
I have an array of zeros 10 x 10 
I need an existing file owerwrite range rand (5x5), for example. 
Existingfile [2: 7.3: 8] 
Paul 



Re: [julia-users] How to overwrite to an existing file, only range of data? HDF5 can do this ?

2015-01-04 Thread paul analyst
Big Thx for big lesson, is no too dark now
Paul

W dniu niedziela, 4 stycznia 2015 17:58:28 UTC+1 użytkownik Adrian 
Cuthbertson napisał:

 You can also work directly with the HDF5 file as an array object...

 using HDF5

 hfi=h5open(myfile.h5,w); # create the file
 close(hfi)

  A = reshape(1: 120, 15, 8);

 hfi = h5open(myfile.h5,r+) # read/write access

 hfi[mygroup/A] = A
 15x8 Array{Int64,2}:
   1  16  31  46  61  76   91  106
 ...
  14  29  44  59  74  89  104  119
  15  30  45  60  75  90  105  120

 data = hfi[mygroup/A][2:3:15,3:5]
 5x3 Array{Int64,2}:
  32  47  62
  35  50  65
  38  53  68
  41  56  71
  44  59  74

  hfi[mygroup/A][2:3,3:5]
 2x3 Array{Int64,2}:
  32  47  62
  33  48  63

 hfi[mygroup/A][2:3,3:5]=[-1 -2 -3; -4 -5 -6]
 2x3 Array{Int64,2}:
  -1  -2  -3
  -4  -5  -6

 hfi[mygroup/A][1:5,:]
 5x8 Array{Int64,2}:
  1  16  31  46  61  76  91  106
  2  17  -1  -2  -3  77  92  107
  3  18  -4  -5  -6  78  93  108
  4  19  34  49  64  79  94  109
  5  20  35  50  65  80  95  110

 foo = hfi[mygroup/A]
 HDF5 dataset: /mygroup/A (file: myfile.h5)

 foo[1:5,:]
 5x8 Array{Int64,2}:
  1  16  31  46  61  76  91  106
  2  17  -1  -2  -3  77  92  107
  3  18  -4  -5  -6  78  93  108
  4  19  34  49  64  79  94  109
  5  20  35  50  65  80  95  110

 close(hfi)

 HDF5 is awesome!




 On Sun, Jan 4, 2015 at 4:59 PM, paul analyst paul.a...@mail.com 
 javascript: wrote:

 Of course, first I read :)
 Is there about reading range array. I need to save a range of In analogy 
 to.

 A = reshape (1: 120, 15, 8)
 h5write (/ tmp / test2.h5, mygroup2 / A, A)
 data = h5read (/ tmp / test2.h5, mygroup2 / A (2: 3: 15: 3: 5))

 Paul


 W dniu niedziela, 4 stycznia 2015 14:14:03 UTC+1 użytkownik Tim Holy 
 napisał:

 If I understand correctly, then yes, that's possible. See the HDF5 docs. 

 --Tim 

 On Sunday, January 04, 2015 04:25:13 AM paul analyst wrote: 
  How to overwrite to an existing file, only range of data? 
  In HDF5 can do this? 
  I have an array of zeros 10 x 10 
  I need an existing file owerwrite range rand (5x5), for example. 
  Existingfile [2: 7.3: 8] 
  Paul 




Re: [julia-users] Re: Disabling type instability in non-global scope

2015-01-04 Thread Ariel Keselman

yeah, you're right about scala having a repl. and I also forgot that 
Haskell has one! but I still prefer Julia over those languages :)




Re: [julia-users] Re: Disabling type instability in non-global scope

2015-01-04 Thread Mike Innes
Oh yeah, of course – I think OCaml has one as well. Although Haskell's at
least is interpreted rather than JIT-compiled, so it's nowhere near as nice
to use as Julia's ;)

You should also check out Leah Hanson's work on TypeCheck.jl
https://github.com/astrieanna/TypeCheck.jl, if you haven't seen it
already. It's pretty cool, and I think if we can get something like that
really well integrated with editors we can solve a lot of the problems
you've mentioned without enforcing it in the compiler. Which might be a
suitable compromise :)

On 4 January 2015 at 20:56, Ariel Keselman skar...@gmail.com wrote:


 yeah, you're right about scala having a repl. and I also forgot that
 Haskell has one! but I still prefer Julia over those languages :)





Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread C. Bryan Daniels
No, the server API doesn't provide this feature. I've asked their 
developer's directly. I will post on request on gitbub repository for 
HTTPClient.jl Thanks for your feedback.

On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:

 Does the service definition have a query parameter where you can specify 
 the number of objects required?

 As long as the server end of the connection is open, and the server is 
 pushing data, the client will continue to receive it, and currently there 
 is no way to control the same.

 Controlling the stream from the client side can be implemented - could you 
 file a feature request for the same on github?


 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net 
 javascript: wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but am 
 having trouble properly configuring the output stream. Specifically, the 
 API to a particular service responds to a 'get' call with a stream of json 
 objects. The code snippets below work as expected by returning a continuous 
 steam of json objects; I can terminate the stream with ctr-C.  What I 
 really want is to be able to get a specific number of json objects. I've 
 played around with options: ostream=some-file, ostream=IOBuffer() and 
 blocking=false. This is probably a basic question, but any help in solving 
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(
 headers=headers,content_type=application/json,ostream=STDOUT) 


 function get(lb::LittleBit)  
   

 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)  
  

 end




[julia-users] Re: Debug printing a “value” and its “symbol”

2015-01-04 Thread Arch Call
Thanks Mike,  I have used show before, but not @show...Arch

On Sunday, January 4, 2015 5:48:27 AM UTC-5, Arch Call wrote:

 I frequently find myself writing Julia snippet scripts like this:


  vara = 33

 varb = vara * 14

 varc = varb * 77

 println(“varb = “, varb) #--debug print

 println(“varc = “, varc) #--debug print


  I would like to eliminate having to enter the variable name twice

 in the debug print lines by using a function.


  I have tried all kinds of variations of a debug print function like:


  function debugprint(somevar)

 println(“ = ”, somevar)

 end


  What can I put in place of “” to get the actual Symbol of the 
 variable being passed to debugprint?



Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread Kevin Squire
Hi Bryan, just FYI: Amit is one of the primary developers. :-)

Cheers,
   Kevin

On Sunday, January 4, 2015, C. Bryan Daniels cdani...@nandor.net wrote:

 No, the server API doesn't provide this feature. I've asked their
 developer's directly. I will post on request on gitbub repository for
 HTTPClient.jl Thanks for your feedback.

 On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:

 Does the service definition have a query parameter where you can specify
 the number of objects required?

 As long as the server end of the connection is open, and the server is
 pushing data, the client will continue to receive it, and currently there
 is no way to control the same.

 Controlling the stream from the client side can be implemented - could
 you file a feature request for the same on github?


 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net
 wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but am
 having trouble properly configuring the output stream. Specifically, the
 API to a particular service responds to a 'get' call with a stream of json
 objects. The code snippets below work as expected by returning a continuous
 steam of json objects; I can terminate the stream with ctr-C.  What I
 really want is to be able to get a specific number of json objects. I've
 played around with options: ostream=some-file, ostream=IOBuffer() and
 blocking=false. This is probably a basic question, but any help in solving
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(headers=headers,content_
 type=application/json,ostream=STDOUT)


 function get(lb::LittleBit)


 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)


 end





Re: [julia-users] Re: Constructing Expr from s-expressions

2015-01-04 Thread Ismael VC
Omg sorry for all that noise, I don't know what happened! :(

On Sun, Jan 4, 2015 at 11:54 AM, Darwin Darakananda darwinda...@gmail.com
wrote:

 Thanks! That's exactly what I was looking for.  The show_sexpr code
 actually looks basically identical to what's in Base, I wonder why 
 sexpr_to_expr
 didn't make it.

 On Sunday, January 4, 2015 3:10:15 AM UTC-8, lapeyre@gmail.com wrote:

 Not sure, but maybe this is what you are looking for,

 https://gist.github.com/toivoh/4121122

 On Sunday, January 4, 2015 6:49:39 AM UTC+1, Darwin Darakananda wrote:

 Hi everyone,

 Is there currently a function that converts s-expressions into Expr
 structures (basically the reverse of Base.Meta.show_sexpr)?

 I just started playing around with metaprogramming in Julia, so I'm
 probably doing things wrong.  But there are a lot of times where I end up
 creating highly nested Expr objects, ending up with code that is
 indecipherable.  I've found that the output from show_sexpr is sometimes
 easier to read that that of dump or xdump (which only seems to display the
 first couple of levels).  So I'm curious to see if the reverse
 (s-expression - Expr) is also true.

 If this function does not exist, would it be something that people would
 find useful?

 Thanks and Happy New Years!

 Darwin




[julia-users] Types now seem to print with qualified names by default - is there any way to opt out?

2015-01-04 Thread Tomas Lycken
Display of types seems to have changed recently:


module Foo
export Bar
type Bar end
end

using Foo
println(Bar)

prints Foo.Bar although I'm quite sure that until recently it only 
printed Bar. I'm sure there are lots of scenarios where this is very 
useful (error reporting, for example), but I have a use case where it's 
not. Is there any way to print the *unqualified* type name?

// Tomas


[julia-users] Re: Warning: imported binding for transpose overwritten in module __anon__

2015-01-04 Thread Simon Kornblith
https://github.com/stevengj/PyCall.jl/pull/110

On Sunday, January 4, 2015 9:34:14 AM UTC-5, John Zuhone wrote:

 Steven,

 How difficult would it be to work a way to suppress this warning message? 
 I general I would argue that it's best to avoid printing warnings to the 
 screen unless there is something going on to be genuinely warned about, so 
 as not to confuse the end-user. Since my package (
 http://github.com/jzuhone/YT.jl) depends on SymPy, this warning is shown 
 every time one does using YT or import YT. It's a cosmetic issue, but 
 it would still be nice to get rid of it. 

 If suppressing it is doable, I'd be happy to investigate it myself and 
 submit a PR. I'm not sure if this should be done in PyCall or in Julia 
 itself somehow.

 Best,

 John Z

 On Saturday, January 3, 2015 9:37:23 AM UTC-5, Steven G. Johnson wrote:

 You can safely ignore it.  @pyimport creates an module __anon__ (which is 
 assigned to plt in this case) that has definitions for the Python functions 
 in the Python module.   The warning is telling you that this module creates 
 its own transpose function instead of extending Base.transpose.  (It is a 
 warning because in many cases a module author would have intended to add a 
 new method to Base.transpose instead.)

 This is fine.  transpose in other modules still refers to Base.transpose, 
 and plt.transpose refers to the pylab one (== numpy transpose).

 --SGJ

 PS. By the way, I would normally import just pyplot and not pylab.  The 
 pylab module is useful in Python because it imports numpy too, and without 
 that you wouldn't have a lot of basic array functionality.  But in Julia 
 you already have the equivalent of numpy built in to Julia Base.   Also, I 
 would tend to recommend the Julia PyPlot module over manually importing 
 pyplot.  The PyPlot module adds some niceties like IJulia inline plots and 
 interactive GUI plots, whereas pylab is imported by default in 
 non-interactive mode.



[julia-users] reading compressed csv file?

2015-01-04 Thread ivo welch

dear julia users:  beginner's question (apologies, more will be coming). 
 it's probably obvious.

I am storing files in compressed csv form.  I want to use the built-in 
julia readcsv() function.  but I also need to pipe through a decompressor 
first.  so, I tried a variety of forms, like

   d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
   d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but 
wrapping a readcsv around it does not capture it.  how does one do this?

regards,

/iaw



[julia-users] Re: reading compressed csv file?

2015-01-04 Thread elextr


On Monday, January 5, 2015 9:51:18 AM UTC+10, ivo welch wrote:


 dear julia users:  beginner's question (apologies, more will be coming). 
  it's probably obvious.

 I am storing files in compressed csv form.  I want to use the built-in 
 julia readcsv() function.  but I also need to pipe through a decompressor 
 first.  so, I tried a variety of forms, like

d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

 I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but 
 wrapping a readcsv around it does not capture it.  how does one do this?


Can you run the command with 
open() 
http://docs.julialang.org/en/latest/stdlib/base/?highlight=spawn#Base.open 
and pass the stream it returns to readcsv?

Cheers
Lex

 


 regards,

 /iaw



Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread C. Bryan Daniels
Kevin - Thank for FYI. I am really impressed with Julia, so it's great to 
get feedback from one of it's founding members. Is the github repository 
for HTTPClient the correct place to post the feature request?

Bryan

On Sunday, January 4, 2015 4:23:30 PM UTC-6, Kevin Squire wrote:

 Hi Bryan, just FYI: Amit is one of the primary developers. :-)

 Cheers,
Kevin

 On Sunday, January 4, 2015, C. Bryan Daniels cdan...@nandor.net 
 javascript: wrote:

 No, the server API doesn't provide this feature. I've asked their 
 developer's directly. I will post on request on gitbub repository for 
 HTTPClient.jl Thanks for your feedback.

 On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:

 Does the service definition have a query parameter where you can specify 
 the number of objects required?

 As long as the server end of the connection is open, and the server is 
 pushing data, the client will continue to receive it, and currently there 
 is no way to control the same.

 Controlling the stream from the client side can be implemented - could 
 you file a feature request for the same on github?


 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net 
 wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but 
 am having trouble properly configuring the output stream. Specifically, 
 the 
 API to a particular service responds to a 'get' call with a stream of json 
 objects. The code snippets below work as expected by returning a 
 continuous 
 steam of json objects; I can terminate the stream with ctr-C.  What I 
 really want is to be able to get a specific number of json objects. I've 
 played around with options: ostream=some-file, ostream=IOBuffer() and 
 blocking=false. This is probably a basic question, but any help in solving 
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(headers=headers,content_
 type=application/json,ostream=STDOUT) 


 function get(lb::LittleBit)
 

 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)


 end


  

Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread ivo welch
still not obviois.  readcsv does have a dispatch for a stream (good),
but I really need a popen function.
  x=readcsv(open(`gzcat myfile.csv.gz`, r))
is wrong.  x=run(`gzcat myfiles.csv.gz`) doesn't send the output to x
for further piping as far as I can see, so readcsv(x) doesn't do it.

/iaw


Ivo Welch (ivo.we...@gmail.com)
http://www.ivo-welch.info/

Ivo Welch (ivo.we...@gmail.com)
http://www.ivo-welch.info/
J. Fred Weston Distinguished Professor of Finance
Anderson School at UCLA, C519
Director, UCLA Anderson Fink Center for Finance and Investments
Free Finance Textbook, http://book.ivo-welch.info/
Exec Editor, Critical Finance Review, http://www.critical-finance-review.org/
Editor and Publisher, FAMe, http://www.fame-jagazine.com/


On Sun, Jan 4, 2015 at 4:55 PM,  ele...@gmail.com wrote:


 On Monday, January 5, 2015 9:51:18 AM UTC+10, ivo welch wrote:


 dear julia users:  beginner's question (apologies, more will be coming).
 it's probably obvious.

 I am storing files in compressed csv form.  I want to use the built-in
 julia readcsv() function.  but I also need to pipe through a decompressor
 first.  so, I tried a variety of forms, like

d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

 I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but
 wrapping a readcsv around it does not capture it.  how does one do this?


 Can you run the command with open()
 http://docs.julialang.org/en/latest/stdlib/base/?highlight=spawn#Base.open
 and pass the stream it returns to readcsv?

 Cheers
 Lex




 regards,

 /iaw




Re: [julia-users] Scope of Arrays

2015-01-04 Thread Howard
Thank you.  This is very helpful.
Howard

On Saturday, January 3, 2015 11:53:12 PM UTC-5, Jiahao Chen wrote:


 On Sat, Jan 3, 2015 at 10:07 AM, Howard how...@zail.org javascript: 
 wrote:

 a = test


 You may find John Myles White's blog post on this topic helpful:


 http://www.johnmyleswhite.com/notebook/2014/09/06/values-vs-bindings-the-map-is-not-the-territory/

 Thanks,

 Jiahao Chen
 Staff Research Scientist
 MIT Computer Science and Artificial Intelligence Laboratory
  


[julia-users] Re: Is there a julia user group in New York area?

2015-01-04 Thread jgabriele382
On Saturday, January 3, 2015 11:48:48 AM UTC-5, Tony Fong wrote:

 I'm planning a trip in late Jan. It'd be nice to be able to connect.


The [Julia Community page](http://julialang.org/community/) has a meetups 
section, which leads to http://www.meetup.com/julia-nyc/.



Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread Tim Holy
I wonder if the GZip.jl package would help?

--Tim

On Sunday, January 04, 2015 05:11:50 PM ivo welch wrote:
 still not obviois.  readcsv does have a dispatch for a stream (good),
 but I really need a popen function.
   x=readcsv(open(`gzcat myfile.csv.gz`, r))
 is wrong.  x=run(`gzcat myfiles.csv.gz`) doesn't send the output to x
 for further piping as far as I can see, so readcsv(x) doesn't do it.
 
 /iaw
 
 
 Ivo Welch (ivo.we...@gmail.com)
 http://www.ivo-welch.info/
 
 Ivo Welch (ivo.we...@gmail.com)
 http://www.ivo-welch.info/
 J. Fred Weston Distinguished Professor of Finance
 Anderson School at UCLA, C519
 Director, UCLA Anderson Fink Center for Finance and Investments
 Free Finance Textbook, http://book.ivo-welch.info/
 Exec Editor, Critical Finance Review,
 http://www.critical-finance-review.org/ Editor and Publisher, FAMe,
 http://www.fame-jagazine.com/
 
 On Sun, Jan 4, 2015 at 4:55 PM,  ele...@gmail.com wrote:
  On Monday, January 5, 2015 9:51:18 AM UTC+10, ivo welch wrote:
  dear julia users:  beginner's question (apologies, more will be coming).
  it's probably obvious.
  
  I am storing files in compressed csv form.  I want to use the built-in
  julia readcsv() function.  but I also need to pipe through a decompressor
  first.  so, I tried a variety of forms, like
  
 d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
 d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)
  
  I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but
  wrapping a readcsv around it does not capture it.  how does one do this?
  
  Can you run the command with open()
  http://docs.julialang.org/en/latest/stdlib/base/?highlight=spawn#Base.open
  and pass the stream it returns to readcsv?
  
  Cheers
  Lex
  
  regards,
  
  /iaw



Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread elextr


On Monday, January 5, 2015 11:12:13 AM UTC+10, ivo welch wrote:

 still not obviois.  readcsv does have a dispatch for a stream (good), 
 but I really need a popen function. 
   x=readcsv(open(`gzcat myfile.csv.gz`, r)) 
 is wrong.  x=run(`gzcat myfiles.csv.gz`) doesn't send the output to x 
 for further piping as far as I can see, so readcsv(x) doesn't do it. 


The documentation I linked said:

open(*command*, *mode::AbstractString=r*, *stdio=DevNull*)

Start running command asynchronously, and return a tuple (stream,process)
 you need to pass the stream element of the tuple to readcsv()

Cheers
Lex


 /iaw 

  
 Ivo Welch (ivo@gmail.com javascript:) 
 http://www.ivo-welch.info/ 
  
 Ivo Welch (ivo@gmail.com javascript:) 
 http://www.ivo-welch.info/ 
 J. Fred Weston Distinguished Professor of Finance 
 Anderson School at UCLA, C519 
 Director, UCLA Anderson Fink Center for Finance and Investments 
 Free Finance Textbook, http://book.ivo-welch.info/ 
 Exec Editor, Critical Finance Review, 
 http://www.critical-finance-review.org/ 
 Editor and Publisher, FAMe, http://www.fame-jagazine.com/ 


 On Sun, Jan 4, 2015 at 4:55 PM,  ele...@gmail.com javascript: wrote: 
  
  
  On Monday, January 5, 2015 9:51:18 AM UTC+10, ivo welch wrote: 
  
  
  dear julia users:  beginner's question (apologies, more will be 
 coming). 
  it's probably obvious. 
  
  I am storing files in compressed csv form.  I want to use the built-in 
  julia readcsv() function.  but I also need to pipe through a 
 decompressor 
  first.  so, I tried a variety of forms, like 
  
 d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |) 
 d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`) 
  
  I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but 
  wrapping a readcsv around it does not capture it.  how does one do 
 this? 
  
  
  Can you run the command with open() 
  
 http://docs.julialang.org/en/latest/stdlib/base/?highlight=spawn#Base.open 
  and pass the stream it returns to readcsv? 
  
  Cheers 
  Lex 
  
  
  
  
  regards, 
  
  /iaw 
  
  



Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread Kevin Squire
Bryan, to be a little clearer: Amit has contributed a great deal to the
HTTPClient.jl package (and might have been its original author--I'm not
sure).  He's not a founder of Julia itself, although he does have a number
of significant contributions there as well.

Either way, he was probably the best person to answer your post, and yes,
the github repo for HTTPClient.jl was the correct place to post the feature
request.

Cheers!
   Kevin

On Sun, Jan 4, 2015 at 5:10 PM, C. Bryan Daniels cdani...@nandor.net
wrote:

 Kevin - Thank for FYI. I am really impressed with Julia, so it's great to
 get feedback from one of it's founding members. Is the github repository
 for HTTPClient the correct place to post the feature request?

 Bryan

 On Sunday, January 4, 2015 4:23:30 PM UTC-6, Kevin Squire wrote:

 Hi Bryan, just FYI: Amit is one of the primary developers. :-)

 Cheers,
Kevin


 On Sunday, January 4, 2015, C. Bryan Daniels cdan...@nandor.net wrote:

 No, the server API doesn't provide this feature. I've asked their
 developer's directly. I will post on request on gitbub repository for
 HTTPClient.jl Thanks for your feedback.

 On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:

 Does the service definition have a query parameter where you can
 specify the number of objects required?

 As long as the server end of the connection is open, and the server is
 pushing data, the client will continue to receive it, and currently there
 is no way to control the same.

 Controlling the stream from the client side can be implemented - could
 you file a feature request for the same on github?


 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net
 wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but
 am having trouble properly configuring the output stream. Specifically, 
 the
 API to a particular service responds to a 'get' call with a stream of json
 objects. The code snippets below work as expected by returning a 
 continuous
 steam of json objects; I can terminate the stream with ctr-C.  What I
 really want is to be able to get a specific number of json objects. I've
 played around with options: ostream=some-file, ostream=IOBuffer() and
 blocking=false. This is probably a basic question, but any help in solving
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(headers=headers,content_
 type=application/json,ostream=STDOUT)


 function get(lb::LittleBit)


 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)


 end





Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread cdani...@nandor.net
Kevin,

Thanks for clarification. Great language, whomever is responsible.

In any case, I’m having fun with Julia. Others are changing the world, but I’ve 
been playing around with LittleBits (http://littlebits.cc), which is basically 
electrical circuits brought to Lego®. I’ve been ‘wrapping’ Julia around the 
LittleBits API that speaks to their 'Internet of Things' device. Ironically, 
setting values on their CloudBit device is easy, reading is not. The choices 
are either a tortured sub/pub model or a GET call that provides a continuous 
reading of voltages. It was the later that brought me to the Julia forum.

Bryan


 On Jan 4, 2015, at 8:07 PM, Kevin Squire kevin.squ...@gmail.com wrote:
 
 Bryan, to be a little clearer: Amit has contributed a great deal to the 
 HTTPClient.jl package (and might have been its original author--I'm not 
 sure).  He's not a founder of Julia itself, although he does have a number of 
 significant contributions there as well.
 
 Either way, he was probably the best person to answer your post, and yes, the 
 github repo for HTTPClient.jl was the correct place to post the feature 
 request.
 
 Cheers!
Kevin
 
 On Sun, Jan 4, 2015 at 5:10 PM, C. Bryan Daniels cdani...@nandor.net 
 mailto:cdani...@nandor.net wrote:
 Kevin - Thank for FYI. I am really impressed with Julia, so it's great to get 
 feedback from one of it's founding members. Is the github repository for 
 HTTPClient the correct place to post the feature request?
 
 Bryan
 
 On Sunday, January 4, 2015 4:23:30 PM UTC-6, Kevin Squire wrote:
 Hi Bryan, just FYI: Amit is one of the primary developers. :-)
 
 Cheers,
Kevin
 
 
 On Sunday, January 4, 2015, C. Bryan Daniels cdan...@nandor.net  wrote:
 No, the server API doesn't provide this feature. I've asked their developer's 
 directly. I will post on request on gitbub repository for HTTPClient.jl 
 Thanks for your feedback.
 
 On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:
 Does the service definition have a query parameter where you can specify the 
 number of objects required?
 
 As long as the server end of the connection is open, and the server is 
 pushing data, the client will continue to receive it, and currently there is 
 no way to control the same.
 
 Controlling the stream from the client side can be implemented - could you 
 file a feature request for the same on github?
 
 
 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net  
 wrote:
 I am using the 'HTTPClient' package. I am using the 'get' method, but am 
 having trouble properly configuring the output stream. Specifically, the API 
 to a particular service responds to a 'get' call with a stream of json 
 objects. The code snippets below work as expected by returning a continuous 
 steam of json objects; I can terminate the stream with ctr-C.  What I really 
 want is to be able to get a specific number of json objects. I've played 
 around with options: ostream=some-file, ostream=IOBuffer() and 
 blocking=false. This is probably a basic question, but any help in solving 
 this would be appreciated. Thanks for any advice.
 
 
 options_get = 
 HTTPClient.HTTPC.RequestOptions(headers=headers,content_type=application/json,ostream=STDOUT)
  
 
 function get(lb::LittleBit)   
  
 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)   
 
 
 end
 
 



Re: [julia-users] Package HTTPClient 'get' method ostream issue

2015-01-04 Thread Kevin Squire
I agree, it is a great language, and I'm glad you're having fun!  You're
littlebits project looks interesting--keep us updated!

Cheers,
   Kevin

On Sunday, January 4, 2015, cdani...@nandor.net cdani...@nandor.net wrote:

 Kevin,

 Thanks for clarification. Great language, whomever is responsible.

 In any case, I’m having fun with Julia. Others are changing the world, but
 I’ve been playing around with LittleBits (http://littlebits.cc), which is
 basically electrical circuits brought to Lego®. I’ve been ‘wrapping’ Julia
 around the LittleBits API that speaks to their 'Internet of Things' device.
 Ironically, setting values on their CloudBit device is easy, reading is
 not. The choices are either a tortured sub/pub model or a GET call that
 provides a continuous reading of voltages. It was the later that brought me
 to the Julia forum.

 Bryan


 On Jan 4, 2015, at 8:07 PM, Kevin Squire kevin.squ...@gmail.com
 javascript:_e(%7B%7D,'cvml','kevin.squ...@gmail.com'); wrote:

 Bryan, to be a little clearer: Amit has contributed a great deal to the
 HTTPClient.jl package (and might have been its original author--I'm not
 sure).  He's not a founder of Julia itself, although he does have a number
 of significant contributions there as well.

 Either way, he was probably the best person to answer your post, and yes,
 the github repo for HTTPClient.jl was the correct place to post the feature
 request.

 Cheers!
Kevin

 On Sun, Jan 4, 2015 at 5:10 PM, C. Bryan Daniels cdani...@nandor.net
 javascript:_e(%7B%7D,'cvml','cdani...@nandor.net'); wrote:

 Kevin - Thank for FYI. I am really impressed with Julia, so it's great to
 get feedback from one of it's founding members. Is the github repository
 for HTTPClient the correct place to post the feature request?

 Bryan

 On Sunday, January 4, 2015 4:23:30 PM UTC-6, Kevin Squire wrote:

 Hi Bryan, just FYI: Amit is one of the primary developers. :-)

 Cheers,
Kevin


 On Sunday, January 4, 2015, C. Bryan Daniels cdan...@nandor.net wrote:

 No, the server API doesn't provide this feature. I've asked their
 developer's directly. I will post on request on gitbub repository for
 HTTPClient.jl Thanks for your feedback.

 On Sunday, January 4, 2015 2:50:25 AM UTC-6, Amit Murthy wrote:

 Does the service definition have a query parameter where you can
 specify the number of objects required?

 As long as the server end of the connection is open, and the server is
 pushing data, the client will continue to receive it, and currently there
 is no way to control the same.

 Controlling the stream from the client side can be implemented - could
 you file a feature request for the same on github?


 On Sat, Jan 3, 2015 at 10:50 AM, C. Bryan Daniels cdan...@nandor.net
 wrote:

 I am using the 'HTTPClient' package. I am using the 'get' method, but
 am having trouble properly configuring the output stream. Specifically, 
 the
 API to a particular service responds to a 'get' call with a stream of 
 json
 objects. The code snippets below work as expected by returning a 
 continuous
 steam of json objects; I can terminate the stream with ctr-C.  What I
 really want is to be able to get a specific number of json objects. I've
 played around with options: ostream=some-file, ostream=IOBuffer() and
 blocking=false. This is probably a basic question, but any help in 
 solving
 this would be appreciated. Thanks for any advice.



 options_get = HTTPClient.HTTPC.RequestOptions(
 headers=headers,content_type=application/json,ostream=STDOUT)


 function get(lb::LittleBit)


 HTTPClient.HTTPC.get(lb.url_get,lb.options_get)


 end







Re: [julia-users] Re: DArrays performance

2015-01-04 Thread Amuthan
Hi Amit: yes, the idea is to have just two DArrays, one each for the
previous and current iterations. I had some trouble assigning values
directly to a DArray (a setindex! error) and so had to write it like this.
Do you know any means around this?

Btw, the parallel code runs slower than the serial version even for just
one iteration.

On Sun, Jan 4, 2015 at 10:27 PM, Amit Murthy amit.mur...@gmail.com wrote:

 As written, this is creating a 1000 DArrays. I think you intended to have
 only 2 of them and swap values in each iteration?


 On Sunday, 4 January 2015 11:07:47 UTC+5:30, Amuthan A. Ramabathiran wrote:

 Hello: I recently started exploring the parallel capabilities of Julia
 and I need some help in understanding and improving the performance a very
 elementary parallel code using DArrays (I use Julia
 version 0.4.0-dev+2431). The code pasted below (based essentially on
 plife.jl) solves u''(x) = 0, x \in [0,1] with u(0) and u(1) specified,
 using the 2nd order central difference approximation. The parallel version
 of the code runs significantly slower than the serial version. It would be
 nice if someone could point out ways to improve this and/or suggest an
 alternative efficient version.

 function laplace_1D_serial(u::Array{Float64})
N = length(u) - 2
u_new = zeros(N)

for i = 1:N
   u_new[i] = 0.5(u[i] + u[i + 2])
end

u_new
 end

 function serial_iterate(u::Array{Float64})
u_new = laplace_1D_serial(u)

for i = 1:length(u_new)
   u[i + 1] = u_new[i]
end
 end

 function parallel_iterate(u::DArray)
DArray(size(u), procs(u)) do I
   J = I[1]

   if myid() == 2
  local_array = zeros(length(J) + 1)
  for i = J[1] : J[end] + 1
 local_array[i - J[1] + 1] = u[i]
  end
  append!([float(u[1])], laplace_1D_serial(local_array))

   elseif myid() == length(procs(u)) + 1
  local_array = zeros(length(J) + 1)
  for i = J[1] - 1 : J[end]
 local_array[i - J[1] + 2] = u[i]
  end
  append!(laplace_1D_serial(local_array), [float(u[end])])

   else
  local_array = zeros(length(J) + 2)
  for i = J[1] - 1 : J[end] + 1
 local_array[i - J[1] + 2] = u[i]
  end
  laplace_1D_serial(local_array)

   end
end
 end

 A sample run on my laptop with 4 processors:
 julia u = zeros(1000); u[end] = 1.0; u_distributed = distribute(u);

 julia @time for i = 1:1000
  serial_iterate(u)
end
 elapsed time: 0.011452192 seconds (8300112 bytes allocated)

 julia @time for i = 1:1000
  u_distributed = parallel_iterate(u_distributed)
end
 elapsed time: 4.461922218 seconds (190565036 bytes allocated, 10.17% gc
 time)

 Thanks for your help!

 Cheers,
 Amuthan





[julia-users] Re: DArrays performance

2015-01-04 Thread Amit Murthy
As written, this is creating a 1000 DArrays. I think you intended to have 
only 2 of them and swap values in each iteration? 

On Sunday, 4 January 2015 11:07:47 UTC+5:30, Amuthan A. Ramabathiran wrote:

 Hello: I recently started exploring the parallel capabilities of Julia and 
 I need some help in understanding and improving the performance a very 
 elementary parallel code using DArrays (I use Julia 
 version 0.4.0-dev+2431). The code pasted below (based essentially on 
 plife.jl) solves u''(x) = 0, x \in [0,1] with u(0) and u(1) specified, 
 using the 2nd order central difference approximation. The parallel version 
 of the code runs significantly slower than the serial version. It would be 
 nice if someone could point out ways to improve this and/or suggest an 
 alternative efficient version.

 function laplace_1D_serial(u::Array{Float64})
N = length(u) - 2
u_new = zeros(N)

for i = 1:N
   u_new[i] = 0.5(u[i] + u[i + 2])
end

u_new
 end

 function serial_iterate(u::Array{Float64})
u_new = laplace_1D_serial(u)

for i = 1:length(u_new)
   u[i + 1] = u_new[i]
end
 end

 function parallel_iterate(u::DArray)
DArray(size(u), procs(u)) do I
   J = I[1]

   if myid() == 2
  local_array = zeros(length(J) + 1)
  for i = J[1] : J[end] + 1
 local_array[i - J[1] + 1] = u[i]
  end
  append!([float(u[1])], laplace_1D_serial(local_array))
   
   elseif myid() == length(procs(u)) + 1
  local_array = zeros(length(J) + 1)
  for i = J[1] - 1 : J[end]
 local_array[i - J[1] + 2] = u[i]
  end
  append!(laplace_1D_serial(local_array), [float(u[end])])
   
   else
  local_array = zeros(length(J) + 2)
  for i = J[1] - 1 : J[end] + 1
 local_array[i - J[1] + 2] = u[i]
  end
  laplace_1D_serial(local_array)

   end
end
 end

 A sample run on my laptop with 4 processors:
 julia u = zeros(1000); u[end] = 1.0; u_distributed = distribute(u);

 julia @time for i = 1:1000
  serial_iterate(u)
end
 elapsed time: 0.011452192 seconds (8300112 bytes allocated)

 julia @time for i = 1:1000
  u_distributed = parallel_iterate(u_distributed)
end
 elapsed time: 4.461922218 seconds (190565036 bytes allocated, 10.17% gc 
 time)

 Thanks for your help!

 Cheers,
 Amuthan
  



[julia-users] Re: reading compressed csv file?

2015-01-04 Thread Todd Leo
An intuitive thought is, uncompress your csv file via bash utility *zcat*, 
pipe it to STDIN and use* readline(STDIN) *in julia.


On Monday, January 5, 2015 7:51:18 AM UTC+8, ivo welch wrote:


 dear julia users:  beginner's question (apologies, more will be coming). 
  it's probably obvious.

 I am storing files in compressed csv form.  I want to use the built-in 
 julia readcsv() function.  but I also need to pipe through a decompressor 
 first.  so, I tried a variety of forms, like

d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

 I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but 
 wrapping a readcsv around it does not capture it.  how does one do this?

 regards,

 /iaw



[julia-users] sum of 1-element array of composite type returns reference

2015-01-04 Thread Greg Plowman
I'm not sure how general this behaviour is with respect to other types, but 
I have observed the following with a simple composite type:
 
When summing a 1-element array of a simple composite type, the return is a 
reference to the single element, rather than a copy of the single element.
This seems at odds with the return value of summing an array of any other 
size (even 0-element array if zero is defined)
Is this the desired behaviour?
 
 
type MyType
   x::Int
end
+(a::MyType, b::MyType) = MyType(a.x + b.x)
A = [ MyType(i) for i = 1:5 ]
sumA = sum(A)
A[1].x = 77
sumA # MyType(15), seems reasonable
 
B = [ MyType(i) for i = 1 ]
sumB = sum(B)
B[1].x = 88
sumB # MyType(88), is this reasonable?
sum(B) === B[1] # true
 
 
I guess for a copy  to be returned (rather than a reference) would need to 
define how to copy. Perhaps require on of the following?  

   - copy constructor
   - copy() function
   - zero() and return A[1] + zero()

 
Would this be preferable to returning a reference?
 
If I want to return a copy of single element, do I need to define my own 
sum() function instead?
 


Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread Jiahao Chen
This is how I used GZip.jl in the tests for the MatrixMarket package

https://github.com/JuliaSparse/MatrixMarket.jl/blob/ba60e447f24938952509bb42c6d6bf9223562ef8/test/dl-matrixmarket.jl#L7

Perhaps it might be useful for you.

Thanks,

Jiahao Chen
Staff Research Scientist
MIT Computer Science and Artificial Intelligence Laboratory

On Sun, Jan 4, 2015 at 9:29 PM, Todd Leo sliznmail...@gmail.com wrote:

 An intuitive thought is, uncompress your csv file via bash utility *zcat*,
 pipe it to STDIN and use* readline(STDIN) *in julia.



 On Monday, January 5, 2015 7:51:18 AM UTC+8, ivo welch wrote:


 dear julia users:  beginner's question (apologies, more will be coming).
  it's probably obvious.

 I am storing files in compressed csv form.  I want to use the built-in
 julia readcsv() function.  but I also need to pipe through a decompressor
 first.  so, I tried a variety of forms, like

d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

 I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but
 wrapping a readcsv around it does not capture it.  how does one do this?

 regards,

 /iaw




Re: [julia-users] Re: reading compressed csv file?

2015-01-04 Thread ivo welch
dear tim, lex, todd (others):  thanks for responding.  I really want
to learn how to preprocess input from somewhere else into the
readcsv() function.  it's a good starting exercise for me to learn how
to accomplish tasks in general.  there is so much to learn.  [I did
not experiment with GZip.jl --- modules are new to me, and this one is
not included.  I could make too many errors in this process.  It will
probably make the specific task easier.]

now, the first mistake which tripped me up for a while is that I did
not grasp the difference between a string and a command.  that is, I
should not have used  for my command.  I had needed to use `.  this
is why open(echo hi) did not work, but open(`echo hi`) does.

x=open(`gzcat myfile.csv.gz`)

is a good start.  I see it contains a tuple of a Pipe and a Process.
this is printed by default on the command line.  I learned I can make
this work with

   d=readcsv( x[1] )

but I have a whole bunch of new questions, beyond question now.
first, try this:

julia x1=open(`gzcat d.csv.gz`)
(Pipe(closed, 35 bytes waiting),Process(`gzcat d.csv.gz`, ProcessExited(0)))

julia x2=open(`gzcat d.csv.gz`)
(Pipe(active, 0 bytes waiting),Process(`gzcat d.csv.gz`, ProcessRunning))

how strange---the claims are different.  even stranger, the first
readcsv(x2[1]) is very slow now (I am talking 3 seconds on a 3 by 4
data file!); but following it with readcsv(x1[1]) is fast.  I can't
imagine readcsv has intelligence built-in to cache past specific
conversions.

another strange definition from a novice perspective:  close(x1) is
not defined.  close(x1[1]) is.  julia is the first language I have
seen where a close(open(file)) is wrong.  this is esp surprising
because julia has the dispatch ability to understand what it could do
with a close(Pipe,Process) tuple.  the same holds true for other
functions that expect a part of open.  julia should be smart enough to
know this.

regards,

/iaw


Ivo Welch (ivo.we...@gmail.com)
http://www.ivo-welch.info/
J. Fred Weston Distinguished Professor of Finance
Anderson School at UCLA, C519
Director, UCLA Anderson Fink Center for Finance and Investments
Free Finance Textbook, http://book.ivo-welch.info/
Exec Editor, Critical Finance Review, http://www.critical-finance-review.org/
Editor and Publisher, FAMe, http://www.fame-jagazine.com/


On Sun, Jan 4, 2015 at 6:29 PM, Todd Leo sliznmail...@gmail.com wrote:
 An intuitive thought is, uncompress your csv file via bash utility zcat,
 pipe it to STDIN and use readline(STDIN) in julia.



 On Monday, January 5, 2015 7:51:18 AM UTC+8, ivo welch wrote:


 dear julia users:  beginner's question (apologies, more will be coming).
 it's probably obvious.

 I am storing files in compressed csv form.  I want to use the built-in
 julia readcsv() function.  but I also need to pipe through a decompressor
 first.  so, I tried a variety of forms, like

d= readcsv(/usr/bin/gzcat ./myfile.csv.gz |)
d= readcsv(`/usr/bin/gzcat ./myfile.csv.gz`)

 I can type the file with run(`/usr/bin/gzcat ./crsp90.csv.gz), but
 wrapping a readcsv around it does not capture it.  how does one do this?

 regards,

 /iaw




[julia-users] Suggestion for tuple types explanation in manual

2015-01-04 Thread ivo welch

I am reading again about the type system, esp in 
http://julia.readthedocs.org/en/latest/manual/types/ .  I am a good guinea 
pig for a manual, because I don't know too much.

a tuple is like function arguments without the functions.  so,

mytuple=(1,ab,(3,4),5)

is a tuple.  good.

what can I do with a typle?  the manual tells me right upfront that I can 
do a typeof(mytuple) function call to see its types.  good.

alas, then it goes into intricacies of how types sort-of inherit.  I need 
a few more basics first.

I would suggest adding to the docs right after the typeof function that, 
e.g., mytuple[2] shows the contents of the second parameter.  the julia cli 
prints the contents.  the examples would be a little clearer, perhaps, if 
one used a nested tuple, like (1,2,(foo,3),bar).

before getting into type relations, I would also add how one creates a 
named tuple.  since open() does exactly this.  well, maybe I am wrong.  the 
docs say it returns a (stream,process), but typeof( open(`gzcat d.csv.gz`) 
tells me I have a (Pipe,Process).

I know how to extract the n-th component of the open() returned tuple (with 
the [] index operator), but I don't know how to get its name.  x.Pipe does 
not work for open().

well, my point is that it would be useful to add a few more examples and 
explanations here.

regards,

/iaw