Re: [julia-users] Weird behavior of median

2016-10-03 Thread Miguel Bazdresch
I can't reproduce the problem.

julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, ivybridge)

-- mb

On Mon, Oct 3, 2016 at 12:46 PM, Fabrice Collard 
wrote:

> Hello everyone,
>
> I recently upgraded to Julia 5.0, and experienced something really weird.
> Assume I generate a matrix X of random numbers, such that
>
> X=randn(10,100,4);
>
> and let me build the median of, say, the first element of the table along
> its first dimension
>
> tmp=median(X[1,:,:],1)
>
> This works w/o any problem, and i can similarly build
>
> tmp=median(X[2,:,:],1) or tmp=median(X[5,:,:],1)
>
> But now let's use a loop to do it for each element
>
> for i in 1:10
> tmp=median(X[i,:,:],1)
> println(tmp)
> end
>
> Then I get the following message
>
> LoadError: AssertionError: frame.inferred
> while loading In[187], in expression starting on line 2
>
>  in typeinf_ext(::LambdaInfo) at ./inference.jl:1645
>
>
>
> where line 2 actually refers to the line starting by for. I must do something 
> wrong, but I cannot see it. Any help would be greatly appreciated.
>
>
> Thanks a lot
>
>
> Fabrice
>
>


Re: [julia-users] Tasks and STDIN

2016-07-26 Thread Miguel Bazdresch
This gets close to what you want, and works in a script (on Julia v0.4.6):

exitflag = [false]

@async while true
g = utf8(readavailable(STDIN))
println(g)
if g[1] == 'q'
println("Exiting task...")
exitflag[1] = true
break
end
end

while true
yield()
if exitflag[1]
break
end
end


This code prints what you type, and both the task and main loop exit when
you press 'q'. It's less than ideal, though, because it needs a newline
("enter") before it reads STDIN, and what you type is echoed to the screen
before it's read by `readavailable()`. These issues should be fixable. HTH,

-- mb

On Mon, Jul 25, 2016 at 9:37 PM,  wrote:

> I am trying to write a simple program that prints a message every time the
> user presses a key. The trick is that I would like this to happen
> *regardless* of what the program is doing otherwise. Eventually, I would
> like to use this method to interrupt a long running process, and allow me
> to check it's progress and modify parameters before restarting it, however
> I am struggling to get even this basic example to work. The following code
> snippet works in the REPL:
>
> function myTask()
> wait(STDIN.readnotify)
> println("Key Pressed!")
> end
>
> @async myTask()
>
> However it doesn't work when run as a script (because it exits before
> myTask completes). Adding an @sync begin ... end block around the @async
> call doesn't fix the problem in the script, and actually breaks the REPL
> version as well. How should I check for user input without actually
> stopping to wait if there is none?
>
> Thanks in advance for your help,
> Luke
>


Re: [julia-users] How to make a Matrix of Matrix's?

2016-06-23 Thread Miguel Bazdresch
You can simplify the declaration as follows:

MM = Matrix(Matrix(1,2))

You can use comprehensions too:

MM = [ randn(5,5) for x=1:2, y=1 ]

Here, MM has two rows and one column, and each of its elements is a 5x5
matrix.

-- mb


On Thu, Jun 23, 2016 at 9:28 PM, Sheehan Olver 
wrote:

> This caught me by surprise:
>
>
> *julia> **M=rand(5,5)*
>
> *5x5 Array{Float64,2}:*
>
> * 0.621195  0.301080.611089  0.880044  0.779199*
>
> * 0.100477  0.0581337  0.198601  0.639252  0.400357*
>
> * 0.716917  0.179181   0.548913  0.787072  0.157769*
>
> * 0.971473  0.981921   0.307854  0.201917  0.290429*
>
> * 0.43822   0.362467   0.160296  0.725931  0.850726*
>
>
> *julia> **Matrix{Float64}[M M]*
>
> *ERROR: MethodError: `convert` has no method matching
> convert(::Type{Array{Float64,2}}, ::Float64)*
>
> *This may have arisen from a call to the constructor
> Array{Float64,2}(...),*
>
> *since type constructors fall back to convert methods.*
>
> Closest candidates are:
>
>   call{T}(::Type{T}, ::Any)
>
>   convert{T,S,N}(::Type{Array{T,N}},
> *::SubArray{S,N,P<:AbstractArray{T,N},I<:Tuple{Vararg{Union{AbstractArray{T,1},Colon,Int64}}},LD}*
> )
>
>   convert{T,n}(::Type{Array{T,n}}, *::Array{T,n}*)
>
>   ...
>
>  in copy! at abstractarray.jl:344
>
>  in typed_hcat at abstractarray.jl:784
>
>
> What's the correct way to do this?  The following works but is not ideal:
>
> *julia> **MM=Matrix{Matrix{Float64}}(1,2)*
>
> *1x2 Array{Array{Float64,2},2}:*
>
> * #undef  #undef*
>
>
> *julia> **MM[1,1]=M;MM[1,2]=M*
>
>
>
>
>


Re: [julia-users] readdlm throws error for empty line

2016-06-05 Thread Miguel Bazdresch
This may be related: https://github.com/JuliaLang/julia/issues/16248

On Sun, Jun 5, 2016 at 6:16 PM, Anonymous  wrote:

> So I have a BysteString vector A, containing a bunch of byte strings of
> varying lengths of the form:
>
> "1,2,\n"
> "\n"
> "5,2,4\n"
>
> etc.
>
> What I have set up is to do
>
> [vec(readdlm(IOBuffer(line), ',', Float64)) for line in A]
>
> However because as you see above the second line is empty except for the
> newline escape character, it throws an error.  What I would like it to do
> instead is simply return an empty array Float64[] for that line.  That
> seems like what it *should* do, and I'm not sure why it doesn't.  Is
> there any way I can make it behave like I want it to?
>


Re: [julia-users] Re: Lack of an explicit return in Julia, heartache or happiness?

2016-05-25 Thread Miguel Bazdresch
I think this is similar to the distinction between 'function' and
'procedure' in languages like Pascal. Maybe we could leave functions as
they are (which I'd prefer), and add procedures that are like functions but
with an implicit 'return nothing' at the end.

-- mb

On Wed, May 25, 2016 at 6:40 PM, Stefan Karpinski 
wrote:

> An argument for `nothing` being a good default return value is that it's
> very unlikely to accidentally work. Here's a scenario that illustrates the
> problem. Suppose you call a function that's supposed to return an integer –
> maybe the write function, which has many methods and returns the number of
> bytes written to the I/O stream. But someone implementing a write method
> (maybe a custom one) forgot to end the method definition with an expression
> giving the number of bytes written – this is easy to do since the primary
> purpose of `write` is to output data, not compute how much data is output.
> However, the function is written so that the last expression happens to
> evaluate to an integer – but not the number of bytes output. This is also
> pretty easy to do – IIRC, we had a bug in Base where exactly this happened.
> The caller gets no hint that there's a problem, they just get a subtle and
> hard-to-find bug. If, on the other hand, the function just returned
> `nothing` because there's no explicit return, then they would immediately
> get an error when they tried to use the return value where an integer is
> expected. In short, `nothing` is a good default return value precisely
> *because* it is useless.
>
> On Wed, May 25, 2016 at 6:17 PM, 'Tobias Knopp' via julia-users <
> julia-users@googlegroups.com> wrote:
>
>> No return statement is kind of an explicit indication that the function
>> does not return anything. This is at least how we know it from a lot of
>> other languages. Thus at least for me as a previous C++ programmer it
>> seemed pretty natural.
>>
>>
>> Am Mittwoch, 25. Mai 2016 23:50:50 UTC+2 schrieb Jeff Bezanson:
>>>
>>> If we want to change this, I also like the simplicity of Stefan's
>>> proposal. However, on the whole I agree with Didier and prefer keeping
>>> things as they are. Automatically adding `return nothing` can be seen
>>> as making `nothing` the "default return value", which implies that
>>> returning nothing is a good thing. I also don't feel it answers the
>>> "explicit is better than implicit" objection that started this thread,
>>> since the value being returned would not be evident in the code.
>>>
>>> On Wed, May 25, 2016 at 3:09 PM, 'Tobias Knopp' via julia-users
>>>  wrote:
>>> > I like Stefans idea. Would be great to open an issue for that on
>>> github.
>>> >
>>> > Tobi
>>> >
>>> >
>>> > Am Mittwoch, 25. Mai 2016 15:23:22 UTC+2 schrieb Michael Borregaard:
>>> >>
>>> >> To me, the suggested change seems to conflict intuitively with julia
>>> >> syntax. When using Julia at the REPL all expressions return a value,
>>> which
>>> >> is confusing at first when coming from othe languages but quickly
>>> becomes a
>>> >> feature. That a function also returns the value of the last statement
>>> seems
>>> >> consistent with this.
>>> >> Also, a common use of multiple dispatch is to have methods that
>>> modify
>>> >> arguments then call another method of the same name defining the
>>> basic
>>> >> functionality. Eg.
>>> >>
>>> >> function foo(x::SomeType)
>>> >> ...
>>> >> end
>>> >>
>>> >> function foo(x::SomeOtherType)
>>> >>   y = dostufftogetsometype(x)
>>> >>   foo(y)
>>> >> end
>>> >>
>>> >> where this syntax seems intuitive.
>>>
>>
>


Re: [julia-users] beginner with Julia graphs

2016-05-19 Thread Miguel Bazdresch
You seem to be missing graphviz: http://www.graphviz.org/

-- mb

On Thu, May 19, 2016 at 12:21 PM, Andrea Vigliotti <
andrea.viglio...@gmail.com> wrote:

> Hi all!
>
> I'm trying to run this example (taken from here :
> https://github.com/JuliaLang/Graphs.jl/blob/master/doc/source/examples.rst
> )
>
> using Graphs
> g = simple_graph(3)
> add_edge!(g, 1, 2)
> add_edge!(g, 3, 2)
> add_edge!(g, 3, 1)
> plot(g)
>
>
> but I get this error
> ERROR: could not spawn `neato -Tx11`: no such file or directory (ENOENT)
>  in _jl_spawn at process.jl:262
>  in anonymous at process.jl:415
>  in setup_stdio at process.jl:403
>  in spawn at process.jl:414
>  in open at process.jl:483
>  in plot at /home/andrea/.julia/v0.4/Graphs/src/dot.jl:91
>
>
> I must be missing some library, can anybody help?
>
> many thanks in advance!
>
> Andrea
>
>


Re: [julia-users] Re: how long until vectorized code runs fast?

2016-05-12 Thread Miguel Bazdresch
The easiest way to write slow for loops is to make them row-major instead
of column-major.

-- mb

On Thu, May 12, 2016 at 8:46 AM, Anonymous  wrote:

> So I guess the consensus is not that Julia's devectorized code is so much
> faster than its vectorized code (in fact I keep getting slow downs when I
> test out different devectorizations of my algorithms), but that R's
> devectorized code just sucks, either that or I really suck at writing for
> loops.
>
> honestly I've been testing out different devectorizations of my algorithms
> and I keep getting slower results, not faster, so either I really suck at
> writing for loops or Julia is doing a good job with my vectorized code.
>
> On Thursday, May 12, 2016 at 4:49:42 AM UTC-7, Stefan Karpinski wrote:
>>
>> On Thu, May 12, 2016 at 7:41 AM, Keno Fischer <
>> kfis...@college.harvard.edu> wrote:
>>
>>> There seems to be a myth going around that vectorized code in Julia is
>>> slow. That's not really the case. Often times it's just that
>>> devectorized code is faster because one can manually perform
>>> operations such as loop fusion, which the compiler cannot currently
>>> reason about (and most C compilers can't either). In some other
>>> languages those benefits get drowned out by language overhead, but in
>>> julia those kinds of constructs are generally fast. The cases where
>>> julia can be slower is when there is excessive memory allocation in a
>>> tight inner loop, but those cases can usually be rewritten fairly
>>> easily without losing the vectorized look of the code.
>>
>>
>> This. JMW's blog post on the subject is as relevant as when he wrote it:
>>
>>
>> http://www.johnmyleswhite.com/notebook/2013/12/22/the-relationship-between-vectorized-and-devectorized-code/
>>
>> Conclusion:
>>
>>- *Julia’s vectorized code is 2x faster than R’s vectorized code*
>>- Julia’s devectorized code is 140x faster than R’s vectorized code
>>- Julia’s devectorized code is 1350x faster than R’s devectorized code
>>
>> Julia's vectorized code is not slow – it's faster than other languages.
>> It's just that Julia allows you to write even faster code when it matters.
>>
>


Re: [julia-users] Hopefully simple plotting question (for my 9 yr old son's science project!)

2016-05-09 Thread Miguel Bazdresch
>  a line segment from the low_range to the high_range (with the top and
bottom marked off with small horizontal lines),

Gaston has support for plotting with error bars, which is exactly this type
of plot. Current documentation is here:
https://bitbucket.org/mbaz/gaston/downloads/gastondoc-0.5.5.pdf See also
the gaston_demo() for examples of many types of plots.

If you decide to use it, be sure to checkout the Master branch -- there's
lots of bug fixes not in the current release (there's a few last features I
need to complete before I put a new release out).

-- mb

On Mon, May 9, 2016 at 10:24 AM, Scott Jones 
wrote:

> My son Alex is building on what he did last year for his science project,
> where he used Julia to help do the calculations on the data he'd collected
> (basically, he's lazy [in a good way], he'd rather work with his dad to
> learn how to program something rather than do all all the basic arithmetic
> to calculate things like the averages for his plots, and Julia made it
> trivial).
> This year, in math class, he's learned about calculating also the median,
> mode(s), and the ranges, and he'd like to be able to plot the results
> directly in Julia (last year, since I didn't know how, he ended up doing
> the plotting by hand).
>
> He's written a program (with a little help from me) that inputs the data
> from a CSV file (thanks, Jacob Quinn, for the CSV.jl package!) that he's
> entered with Excel.
> The data is simply a value, integer 0 - 7 (for the number of digits
> remembered correctly after seeing a card with 7 digits for 30 seconds, and
> reciting the alphabet).
>
> The program first makes of sorted vector of the unique ages in the data
> set, and then creates a Vector of Vector of Int, each element having all of
> the results for that age.
> Then it uses that to create 4 vectors, mean_by_age, median_by_age,
> low_range, and high_range.
>
> What we want to do, is to plot the ages on the X axis, with the results on
> the Y axis, as a line segment from the low_range to the high_range (with
> the top and bottom marked off with small horizontal lines),
> and also have plotted mean_by_age, and median_by_age with different
> colored lines with different markers (maybe diamonds and squares).
> He might also want to display the mode(s) for each age (might be nice to
> have those done as circles of different radius depending on how many
> samples at that mode value)
>
> I haven't ever needed to plot, so I haven't been able to help him very
> much, so far I'll I've been able to do is just call `plot(ages,
> mean_by_age, linewidth=3)` and `plot(ages, median_by_age, linewidth= 3)` do
> display two of the things he wants.
>
> Any help will be greatly appreciated!
>
> Thanks,
> Scott (proud father of a beginning Julia ;-) )
>
>
>


Re: [julia-users] How to suppress output from interactive session

2016-03-26 Thread Miguel Bazdresch
That I don't know, sorry.

-- mb

On Sat, Mar 26, 2016 at 6:44 PM, feza <mohamad...@gmail.com> wrote:

> Sorry I meant without using  ;
>
> I.e. to have it permanently without  ;
>
> On Saturday, March 26, 2016 at 6:40:16 PM UTC-4, Miguel Bazdresch wrote:
>>
>> 3;
>>
>> On the REPL the ; acts just like it does in Matlab, suppressing the
>> output.
>>
>> -- mb
>>
>> On Sat, Mar 26, 2016 at 6:34 PM, feza <moham...@gmail.com> wrote:
>>
>>> julia> 3
>>> 3
>>>
>>>
>>> How can I suppress this during an interactive julia session
>>>
>>> Thanks
>>>
>>
>>


Re: [julia-users] How to suppress output from interactive session

2016-03-26 Thread Miguel Bazdresch
3;

On the REPL the ; acts just like it does in Matlab, suppressing the output.

-- mb

On Sat, Mar 26, 2016 at 6:34 PM, feza  wrote:

> julia> 3
> 3
>
>
> How can I suppress this during an interactive julia session
>
> Thanks
>


Re: [julia-users] Performance of rand() vs rand(1)

2016-03-13 Thread Miguel Bazdresch
Yichao,

Thanks for the response. I'm going to keep using rand() and not worry about
it. The main downside I see that is that, when analyzing code with
@code_warntype and similar, each use of rand() "pollutes" the result and
makes it harder to understand.

-- mb

On Sun, Mar 13, 2016 at 9:55 PM, Yichao Yu <yyc1...@gmail.com> wrote:

> On Sun, Mar 13, 2016 at 9:47 PM, Miguel Bazdresch <eorli...@gmail.com>
> wrote:
> > While trying to optimize some code for performance, I noticed that rand()
> > and randn() generate much more code than rand(1) and randn(1). In
> addition,
>
> It generate more code since there are more inlining.
>
> > rand() and randn() have type instabilities, easily seen with
> @code_warntype.
>
> These type instability actually doesn't matter since the result is
> never used and IIRC it is also only in the slow path.
>
> >
> > It seems to me than rand() should be faster and generate less code than
> > rand(1), because rand(1) basically means "run rand() and put the result
> in
> > an array".
> >
> > Is this a bug, or at least a place where Julia's performance could be
> > improved?
>
> The type stability could be fixed (although last time I tried it
> there's no performance impact at all).
>
> >
> > -- mb
>


[julia-users] Performance of rand() vs rand(1)

2016-03-13 Thread Miguel Bazdresch
While trying to optimize some code for performance, I noticed that rand()
and randn() generate much more code than rand(1) and randn(1). In addition,
rand() and randn() have type instabilities, easily seen with @code_warntype.

It seems to me than rand() should be faster and generate less code than
rand(1), because rand(1) basically means "run rand() and put the result in
an array".

Is this a bug, or at least a place where Julia's performance could be
improved?

-- mb


Re: [julia-users] Interested in GSoC idea "Random number generation"

2016-03-02 Thread Miguel Bazdresch
I think it'd be great to use this PRNG in julia: http://www.pcg-random.org/

-- mb

On Tue, Mar 1, 2016 at 6:28 AM, Upekshe Jayasekera <
upekshej...@cse.mrt.ac.lk> wrote:

> Hi All,
> I am an final year CSE undergraduate in University of Moratuwa. I am new
> to julia. But I have heard about julia since I have interest to data
> science and I am a Kaggle user. I would like to contribute to this idea of
> creating a efficient RNG for julia. I would like to no more details about
> the project idea. Thanks and Regards.
> Upekshe Jayasekera
>


Re: [julia-users] GIF 3D plot

2016-02-18 Thread Miguel Bazdresch
Gaston has support for 3D plots and can save them to GIF files. Take a look
at the documentation here:
https://bitbucket.org/mbaz/gaston/downloads/gastondoc-0.5.5.pdf

I recommend using Gaston "master" instead of the latest release; it has a
lot of bugfixes and improvements. The docs for 3-d plotting and saving a
file are still current, though.

-- mb

On Mon, Feb 15, 2016 at 10:28 AM,  wrote:

> Does anyone know how can I have a 3D plot as a GIF?
> I'm not sure if I can use PyPlot or Gaston to do that. If someone has an
> example I appreciate if you could share.
>
> Thanks!
>


Re: [julia-users] Read from a PipeEndpoint in a non-blocking way?

2016-02-03 Thread Miguel Bazdresch
> What I did is that I have a Task that reads from the Pipe and puts the
data in an IOBuffer, then read from that in the loop instead, it seems to
work.

That is what I do, with strings instead of IOBuffers. It does seem to work.

-- mb

On Wed, Feb 3, 2016 at 11:04 AM, STAR0SS  wrote:

> I have something of the sort:
>
> #some loop
>
> ...
>
> s = get_data_from_pipe()
> do_something_with(s)
>
>
> I need do_something_with to happen synchronously within the loop, so I
> cannot run that in a Task, and if get_data_from_pipe blocks then it kills
> my loop.
>
> What I did is that I have a Task that reads from the Pipe and puts the
> data in an IOBuffer, then read from that in the loop instead, it seems to
> work.
>


Re: [julia-users] ANN: new blog post on array indexing, iteration, and multidimensional algorithms

2016-02-01 Thread Miguel Bazdresch
Tim,

Thanks for putting this tutorial together, it was an interesting read.

-- mb

On Mon, Feb 1, 2016 at 1:54 PM, Tim Holy  wrote:

> It's come to my attention that some of the exciting capabilities of julia
> 0.4
> for indexing, iteration, and writing generic multidimensional algorithms
> may
> be under-documented. This new blog post
>
> http://julialang.org/blog/2016/02/iteration/
>
> aims to provide a "gentle tutorial" illustrating how to use these
> capabilities.
>
> Best,
> --Tim
>
>


Re: [julia-users] Re: recommended graphics packages for multiple curves on a single canvas

2016-02-01 Thread Miguel Bazdresch
Gaston can do that, too. Just be sure to use master instead of the latest
release; there's tons of bug fixes and improvements. The PDF documentation
is here: https://bitbucket.org/mbaz/gaston/downloads/gastondoc-0.5.5.pdf.

-- mb

On Mon, Feb 1, 2016 at 9:45 AM, Tom Breloff  wrote:

> Michael: If you have a specific plot-type in mind let me know... I'm
> usually pretty quick to whip up an example or point you in the right
> direction.  Not all features are documented well (yet) so it might be
> faster to ask for help.
>
> On Mon, Feb 1, 2016 at 4:48 AM, Michael Landis 
> wrote:
>
>> Gadfly already working.  I will look at Breloff's Plots too. Thanks.
>>
>>
>>
>


Re: [julia-users] Interrupting script gives constant error

2016-01-22 Thread Miguel Bazdresch
I tend to just run Jupyter by itself from a command line, not from Julia.
Interrupting Julia's notebook() doesn't work reliably.

-- mb

On Fri, Jan 22, 2016 at 7:32 AM, Lutfullah Tomak 
wrote:

> I have a julia script that runs IJulia
> as
>
> #!/bin/sh
> julia -e "using IJulia; notebook()"
>
> Interrupting this script gives recurring error reading
>
> jl_uv_writecb() ERROR: bad file descripter EBADF
>
> and cannot be stopped. I needed to cancel because IJulia freezes giving
> warning lots of depreciation warning because of recent change in read* and
> write* function. I'm on 0.5-dev+2238 Commit 8e036b4. Debian Sid armc7-a.
> How can I stop that errors and how I can I stop depreciation warnings.


Re: [julia-users] Re: Code review request: interacting with another program via stdin, stdout, stderr.

2016-01-20 Thread Miguel Bazdresch
Tom,

Interesting thoughts; I'll consider putting a package together. For the
time being, I've implemented these ideas in Gaston, and after some testing
it looks like the implementation is solid.

Thanks,

-- mb

On Tue, Jan 12, 2016 at 2:36 AM, Tomas Lycken <tomas.lyc...@gmail.com>
wrote:

> The other global variables actually hold data, which changes according to
> the values read from the different streams. Inspired by the wrapper idea, I
> wrapped them in a type so that it becomes clear that they are always
> strings; hopefully this will help with performance.
>
> You won’t see any performance difference from just wrapping them. However,
> since you can now rebind the fields of the wrappers (which have strictly
> specified types) instead of rebinding the variables themselves, all those
> variables can now be marked const. This should give you some additional
> speed gain.
>
> Another thing to consider, is that you probably want to be able to do this
> with several commands in parallel. (Consider, for example, running multiple
> echo programs and passing stuff between them) For that, you would need to
> wrap all of this in a function anyway. I would consider the following API:
>
> function popen3(f::Function, cmd::Cmd)
> # setup all streams, like your current popen3 function does
>
> # also, create all state handling for the different streams
>
> # finally, pass suitable arguments to f to let the user provide the 
> actual action
> f(pin.in, out.out, err.out) # for example, maybe something else makes 
> more sense
> end
>
> The caller can then use a do block to consume this:
>
> popen3(`./inout`) do pin, pout, perr
> # use the streams here
> end
>
> Since it’s all now wrapped in a function, “globals” won’t be a performance
> problem anymore. As a bonus, you can work with several, parallel,
> invocations without conflict between them. You might still see some
> slowness due to passing anonymous functions, but it’s a) probably
> negligible compared to the IO cost, and b) it’s actively being worked on
> <https://github.com/JuliaLang/julia/pull/13412> and will eventually be
> fast.
>
> // T
>
> On Tuesday, January 12, 2016 at 3:50:04 AM UTC+1, Miguel Bazdresch wrote:
>
> Tomas,
>>
>> Thanks for your feedback! I couldn't find a package that handles this
>> already. If this technique proves to work reliably in Gaston, I'll be happy
>> to put it in a package.
>>
>> Regarding `readnow`, I never rebind it. It doesn't hold any actual value;
>> it is just a `Condition()`, which can be used to notify asynchronous tasks.
>> I followed your advice and made it a `const`.
>>
>> The other global variables actually hold data, which changes according to
>> the values read from the different streams. Inspired by the wrapper idea, I
>> wrapped them in a type so that it becomes clear that they are always
>> strings; hopefully this will help with performance.
>>
>> The latest version of the code is at
>> https://gist.github.com/mbaz/bb7e2cbaaecc031b1d88
>>
>> -- mb
>>
>> On Mon, Jan 11, 2016 at 9:05 AM, Tomas Lycken <tomas@gmail.com>
>> wrote:
>>
>>> Interesting question! If you find a good approach to do this, wrapping
>>> it in a package is certainly interesting (have you checked that there
>>> aren’t any packages that handle this already?).
>>>
>>> I can’t help much with the threading stuff, but regarding your global
>>> variable it should be possible to work around the slowness of that. I don’t
>>> know how, or when, you re-bind readnow, but there are two ways to fix
>>> it depending on the specifics:
>>>
>>>1.
>>>
>>>You never rebind readnow, just mutate it. Mark it const, and it’s
>>>fast. (const means *impossible to rebind*, not *impossible to mutate*
>>>)
>>>2.
>>>
>>>You rebind readnow, and Condition() is mutable: Mark it const and
>>>mutate it instead of rebinding.
>>>3.
>>>
>>>You rebind readnow and Condition() is immutable: Wrap the Condition
>>>in a mutable type, which you assign to const readnow instead, and
>>>then rebind the field in this mutable type. Something like this:
>>>
>>> type ConditionWrapper
>>> c::Condition
>>> end
>>>
>>> const readnow = ConditionWrapper(Condition())
>>>
>>> # where you update:
>>> readnow.c = Condition(args...)
>>>
>>> This all assumes that Condition is an immutable concrete type, and you
>>> just want to switc

Re: [julia-users] Simultaneous audio playback / recording.

2016-01-18 Thread Miguel Bazdresch
An alternative would be to interact with the sound card using sox (
http://sox.sourceforge.net/). In the past, I used sox from Octave to record
and play audio simultaneously. Let me know if you'd like to see the code; I
can probably dig it out of my old backups.

-- mb

On Sun, Jan 17, 2016 at 1:30 PM, CrocoDuck O'Ducks <
crocoduck.odu...@gmail.com> wrote:

> Hi there!
>
> I have a number MATLAB scripts that I use for electro-acoustic
> measurements (mainly impulse responses) and I would like to port them to
> JULIA. I also written the data acquisition in MATLAB. It works by streaming
> the test signal to the soundcard outputs while recording from the soundcard
> inputs. I would like to implement that as well. I was looking at AudioIO
> but there are few issues:
>
>
>- I cannot find documentation/examples on how to record from soundcard
>input.
>- I cannot find documentation/examples on selecting the audio device
>to use.
>- I cannot find documentation/examples on setting sampling variables
>(it is in my best interest to use the highest sample rate available).
>
> Are these things possible with JULIA? I think I can use aplayer and
> arecord through JULIA (I am on Linux), but I was wishing to have all the
> code contained within JULIA.
>
> Many thanks, I hope you can point me in the right direction.
>


Re: [julia-users] Re: Code review request: interacting with another program via stdin, stdout, stderr.

2016-01-11 Thread Miguel Bazdresch
Tomas,

Thanks for your feedback! I couldn't find a package that handles this
already. If this technique proves to work reliably in Gaston, I'll be happy
to put it in a package.

Regarding `readnow`, I never rebind it. It doesn't hold any actual value;
it is just a `Condition()`, which can be used to notify asynchronous tasks.
I followed your advice and made it a `const`.

The other global variables actually hold data, which changes according to
the values read from the different streams. Inspired by the wrapper idea, I
wrapped them in a type so that it becomes clear that they are always
strings; hopefully this will help with performance.

The latest version of the code is at
https://gist.github.com/mbaz/bb7e2cbaaecc031b1d88

-- mb

On Mon, Jan 11, 2016 at 9:05 AM, Tomas Lycken <tomas.lyc...@gmail.com>
wrote:

> Interesting question! If you find a good approach to do this, wrapping it
> in a package is certainly interesting (have you checked that there aren’t
> any packages that handle this already?).
>
> I can’t help much with the threading stuff, but regarding your global
> variable it should be possible to work around the slowness of that. I don’t
> know how, or when, you re-bind readnow, but there are two ways to fix it
> depending on the specifics:
>
>1.
>
>You never rebind readnow, just mutate it. Mark it const, and it’s
>fast. (const means *impossible to rebind*, not *impossible to mutate*)
>2.
>
>You rebind readnow, and Condition() is mutable: Mark it const and
>mutate it instead of rebinding.
>3.
>
>You rebind readnow and Condition() is immutable: Wrap the Condition in
>a mutable type, which you assign to const readnow instead, and then
>rebind the field in this mutable type. Something like this:
>
> type ConditionWrapper
> c::Condition
> end
>
> const readnow = ConditionWrapper(Condition())
>
> # where you update:
> readnow.c = Condition(args...)
>
> This all assumes that Condition is an immutable concrete type, and you
> just want to switch it out for an instance with other field values. If you
> actually need to change the *type* of readnow, all bets are off and this
> trick won’t work.
>
> // T
>
> On Friday, January 8, 2016 at 9:28:02 PM UTC+1, Miguel Bazdresch wrote:
>
> Hello,
>>
>> I'd be grateful if you could take a look at some code and suggest
>> improvements.
>>
>> I'm trying to interact with a long-lived process (gnuplot). This process
>> reads commands from its STDIN; after each command is executed, it produces
>> output on either its STDOUT or STDERR. It's impossible to predict ahead of
>> time which of the two streams will be used.
>>
>> To simplify my tests, I wrote an "echo server" in C, which reads a
>> character from its STDIN and outputs it again over either STDOUT or STDERR.
>> The code is here: https://gist.github.com/mbaz/1e242694a9c4f1eca576
>>
>> Then I wrote a julia program that reads a character from its own STDIN,
>> sends it to the C echo server, and then tries to read the server's STDOUT
>> and STDERR until it finds a character. The code is here:
>> https://gist.github.com/mbaz/bb7e2cbaaecc031b1d88
>>
>> This code works, but I don't know if it is the best approach. Two
>> specific questions I have:
>>
>> * Is my `popen3()` function necessary? This closed issue seems to suggest
>> it's not, but I can't figure out how to accomplish what I need in a more
>> simple manner: https://github.com/JuliaLang/julia/issues/11824
>>
>> * Are global variables required to share data with asynchronous tasks?
>> Since global variables are slow, this approach may produce undesired code
>> slowdowns.
>>
>> Thanks,
>>
>> -- mb
>>
> ​
>


[julia-users] Code review request: interacting with another program via stdin, stdout, stderr.

2016-01-08 Thread Miguel Bazdresch
Hello,

I'd be grateful if you could take a look at some code and suggest
improvements.

I'm trying to interact with a long-lived process (gnuplot). This process
reads commands from its STDIN; after each command is executed, it produces
output on either its STDOUT or STDERR. It's impossible to predict ahead of
time which of the two streams will be used.

To simplify my tests, I wrote an "echo server" in C, which reads a
character from its STDIN and outputs it again over either STDOUT or STDERR.
The code is here: https://gist.github.com/mbaz/1e242694a9c4f1eca576

Then I wrote a julia program that reads a character from its own STDIN,
sends it to the C echo server, and then tries to read the server's STDOUT
and STDERR until it finds a character. The code is here:
https://gist.github.com/mbaz/bb7e2cbaaecc031b1d88

This code works, but I don't know if it is the best approach. Two specific
questions I have:

* Is my `popen3()` function necessary? This closed issue seems to suggest
it's not, but I can't figure out how to accomplish what I need in a more
simple manner: https://github.com/JuliaLang/julia/issues/11824

* Are global variables required to share data with asynchronous tasks?
Since global variables are slow, this approach may produce undesired code
slowdowns.

Thanks,

-- mb


Re: [julia-users] Reading from open()-ed process produces silence

2015-12-09 Thread Miguel Bazdresch
Do you get different results using readavailable()? Maybe there isn't a
newline on the stream and readline() blocks waiting for it.

On Tue, Dec 8, 2015 at 2:51 PM, Colin Beckingham 
wrote:

> I'm trying to launch a process from a Julia script. The process is a
> socket server.
> If I start the socket server outside Julia, then use Julia to connect to
> the socket, I can read from and write to the connected stream.
>
> Now if I use open() inside Julia to launch the socket server, wait a few
> seconds for it to set up and listen
> then connect() is good, the process starts, I give it some input and it
> acts on that input correctly, then my task
> is to collect text output from the socket server. But the readline()
> request waits and waits, hearing nothing.
>
> I guess I am confused by all the handles: stream and process are returned
> from open(), but I have the connect() handle as well.
> Perhaps something is blocking the output on open()?
>


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
I didn't think that section applied to my case, since I have two processes,
each reading/writing to a different pipe.

I've also tried to use IOBuffer() and IOStream(), but without any success.

Thanks,

-- mb

On Mon, Dec 7, 2015 at 8:34 AM, James Gilbert  wrote:

> I think the answer to your problem might be in the "Avoiding Deadlock in
> Pipelines" section in the "Running External Programs" page:
>
>
> http://docs.julialang.org/en/release-0.4/manual/running-external-programs/#avoiding-deadlock-in-pipelines
>
> I've been experimenting to try to get something to work without success.
> The *writeall()* function used in that section of the documentation
> doesn't exist.
>
> I was hoping to be able to use *IOBuffer()* or *IOStream() *variables to
> provide input and capture output and stderr for external programs.
>


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
Eventually I wish to capture both stdout and stderr; first I want to learn
to capture stdin using open(). And, you did mention stderr in your first
reply :)

Thanks for the link; I'm keeping an eye out on it, but in its current state
its not useful.

-- mb

On Mon, Dec 7, 2015 at 4:01 PM, James Gilbert  wrote:

> This is more recent, and is probably what you need!
>
>   Issue 14042: Document capture of stdout/stderr from external command
> 
>
>


Re: [julia-users] Re: How to read an external program's STDOUT using open()

2015-12-07 Thread Miguel Bazdresch
Yes, but the problem is that readandwrite() does not provide access to
stderr (see https://github.com/JuliaLang/julia/issues/11824). That's why
I've been trying alternative solutions.

On Mon, Dec 7, 2015 at 1:17 PM, James Gilbert  wrote:

> Turns out that there is a function *readandwrite()
> * 
> which
> does exactly what we need:
>
> function main()
> letters = ["v", "w", "x", "y", "z"]
> str = join(["$a$b\n" for a in letters, b in letters])
> print("\nBefore grep:\n", str)
>
> (grepout, grepin, grep) = readandwrite(`grep y`)
> print(grepin, str)
> close(grepin)
> filtered_str = readall(grepout)
> print("\nAfter grep:\n", filtered_str)
> end
>
>
> main()
>
>
>


[julia-users] How to read an external program's STDOUT using open()

2015-12-05 Thread Miguel Bazdresch
I need to run an external program and write to its STDIN, and read from its
STDOUT. I'm trying to do this using open(). Writing to its STDIN works fine
with the method below, but I cannot read from its STDOUT.

To simplify my tests, I wrote a simple C program called 'stdo' that
constantly generates data on its STDOUT:

#include 
#include 

int main(int argc, char** argv) {
 while (1) {
printf("Hello\n");
fflush(stdout);
  sleep(1);
  }
  return 0;
}

In Julia (0.4.1, Linux) I run this program like this:

julia> si=STDIN;
julia> (r,w)=redirect_stdin();

julia> (s,p)=open(`./stdo`,"w",w)
(Pipe(open => closed, 0 bytes waiting),Process(`./stdo`, ProcessRunning))

julia> r
Base.PipeEndpoint(open, 0 bytes waiting)

My understanding is that the C program's output is redirected to pipe 'w',
and it can be read from pipe 'r'. However, the pipe 'r' is always empty.
Obviously I'm doing something wrong, but I can't figure out what it is. Any
pointers appreciated.

-- mb


Re: [julia-users] Re: Code runs 500 times slower under 0.4.0

2015-10-23 Thread Miguel Bazdresch
These are my thoughts exactly. I used Matlab because it was a convenient,
easy way to get results, but the warts in the design are real. Julia,
besides being convenient and easy, is a pleasure to program in.

-- mb

On Fri, Oct 23, 2015 at 5:41 PM, Andrew  wrote:

> I don't think performance is the only thing Julia has going for it over
> Matlab. Julia has multiple dispatch, a sophisticated type system, macros,
> and functions can modify arrays and other mutable objects. I'm unaware of
> any plan for Matlab to add these things--they would be major changes and
> possibly very confusing for long-time users.
>
> On Friday, October 23, 2015 at 7:18:43 AM UTC-4, Kris De Meyer wrote:
>>
>> On a slightly different note, in 2 or 3 release cycles, Matlab will have
>> caught up on any performance gains Julia may have introduced (by using the
>> same LLVM compiler procedures Julia uses) and then the only thing Julia
>> will have going for it is that it's free. But my cost to my employers is
>> such that if I lose as little as 3 days a year on compatibility issues,
>> they would be better off paying for a Matlab license...
>>
>> Best.
>>
>> Kris
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, October 22, 2015 at 10:58:30 PM UTC+1, Stefan Karpinski
>> wrote:
>>>
>>> You can try using @code_warntype to see if there are type instabilities.
>>>
>>> On Thu, Oct 22, 2015 at 5:50 PM, Gunnar Farnebäck >> > wrote:
>>>
 If you don't have deprecation warnings I would suspect some change in
 0.4 has introduced type instabilities. If you are using typed
 concatenations you could be hit by
 https://github.com/JuliaLang/julia/issues/13254.


 Den torsdag 22 oktober 2015 kl. 23:03:00 UTC+2 skrev Kris De Meyer:
>
> Are there any general style guidelines for moving code from 0.3.11 to
> 0.4.0? Running the unit and functionality tests for a module that I
> developed under 0.3.11 in 0.4, I experience a 500 times slowdown of blocks
> of code that I time with @time.
>
> Can't even imagine where I have to start looking, and find it
> flabbergasting that perfectly valid julia code under 0.3.11 (not 
> generating
> a single warning) can show such a performance degradation under 0.4.0.
>
> Anyone seen anything similar? Is there some fundamental difference in
> how code is JIT-compiled under 0.4.0?
>
> Thanks,
>
> Kris
>
>
>
>
>>>


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

2015-09-24 Thread Miguel Bazdresch
With this Julia code:

x = -2.34e-12;
for i in 1:5
  x=-x*5000.
  println("$i $x")
end

I get this output:

1 1.17e-8
2 -5.8506e-5
3 0.29254
4 -1462.50002
5 7.3125001e6

I don't think this is too bad. True, the output is a bit longer, but I
actually prefer it, because you can copy/paste the numbers back into Julia
and be sure you're getting the exact number that was used in the code.

-- mb

On Thu, Sep 24, 2015 at 2:39 PM, lawrence dworsky 
wrote:

> Hi Tom
>
> Sorry to take so long to get back to you, I had to go away for a couple of
> days. Thanks for the installation information, @fmt is working fine now.
> It's still not as useful as the Fortran print * formatting however because
> it ​requires the user to know what's coming. For example, the Fortran code
>
> x = -2.34e-12
> do i = 1, 5
>   x = -x*5000.
>   print *, i, x
> end do
>
> produces
>
> 1 1.17E-08
> 2-5.85E-05
> 3 0.292500
> 4 -1462.5
> 5 7.312501e+06
>
> As you can see, print * figured out when exponential notation is necessary
> and automatically used it.
>
> I'm retired now, but when I was working I spent a lot of time writing
> numerical analysis programs for various engineering issues (elastic
> material deformation, electron trajectories, etc.) While a  program was
> being developed I didn't care about the aesthetics of my printout, I just
> needed useful information - and early on, numerical or algebraic or
> programming errors could easily produce results off by 10 order of
> magnitude!
>
> I think a capability such as this in Julia would be heavily used. I wish I
> had the expertise to write it.
>
> Larry
>
>
>
> On Tue, Sep 22, 2015 at 4:59 PM, Tom Breloff  wrote:
>
>> Sorry I wasn't expecting you to run it... just comment.  You'll have to
>> do:
>>
>> Pkg.rm("Formatting")
>> Pkg.clone("https://github.com/tbreloff/Formatting.jl.git;)
>> Pkg.checkout("Formatting", "tom-fmt")
>>
>> Let me know if that works.
>>
>> On Tue, Sep 22, 2015 at 5:52 PM, lawrence dworsky <
>> m...@lawrencedworsky.com> wrote:
>>
>>> I'm afraid my beginner status with Julia is showing:
>>>
>>> I ran Pkg.add("Formatting"), and then   using Formatting   came back
>>> with a whole bunch of warnings, most about  Union(args...) being
>>> depricated, use Union(args) instead.
>>>
>>> When all is said and done,   fmt_default!  gives me a  UndefVarError.
>>>
>>> Help!
>>>
>>>
>>>
>>> On Tue, Sep 22, 2015 at 2:45 PM, Tom Breloff  wrote:
>>>
 Thanks Larry, that's helpful.  Just for discussions sake, here's a
 quick macro that calls my proposed `fmt` method under the hood, and does
 something similar to what you showed.  What do you think about this style
 (and what would you do differently)?

 using Formatting

 macro fmt(args...)
  expr = Expr(:block)
  expr.args = [:(print(fmt($(esc(arg))), "\t\t")) for arg in args]
  push!(expr.args, :(println()))
  expr
 end


 And then an example usage:

 In:

 x = 1010101
 y = 55.5
 fmt_default!(width=15)

 @fmt x y

 fmt_default!(Int, :commas)
 fmt_default!(Float64, prec=2)

 @fmt x y


 Out:

 1010101  55.56
   1,010,101  55.56



 On Tuesday, September 22, 2015 at 3:08:35 PM UTC-4, lawrence dworsky
 wrote:
>
> Hi Tom
>
> What I like about it is that you can just use print *, dumbly and it
> always provides useful, albeit not beautiful, results. When I'm writing a
> program, I use print statements very liberally to observe what's going on 
> -
> I find this more convenient than an in-line debugger.
>
> As the last line in my program below shows, it's easy to switch to
> formatted output when you want to. The formatting capability is pretty
> thorough, I'm just showing a simple example.
>
> This Fortran program doesn't do anything, it just illustrates what the
> print statement produces:
>
>
> real x, y
> integer i, j
> complex z
> character*6  name
>
> x = 2.6
> y = -4.
> i = 36
> j = -40
> z = cmplx(17., 19.)
> name = 'Larry'
>
> print *, x, y, i, j, z
> print *, 'x = ', x, ' and j = ', j
> print *, 'Hello, ', name, j
> print '(2f8.3, i5)', x, y, j
>
> stop
> end
>
>
> The output is:
>
> 2.6 -4.0   36
> -40  (17., 19.)
> x = 2.6   and j =-40
> Hello, Larry -40
>   2.600   -4.000  -40
>
>
> Is this what you are looking for?
>
> Larry
>
>
>
> On Tue, Sep 22, 2015 at 11:57 AM, Tom Breloff 
> wrote:
>
>> Larry: can you provide details on exactly what you like about

Re: [julia-users] [ANN] Plots.jl, a plotting interface

2015-09-14 Thread Miguel Bazdresch
> The priority for me is to be able to fiddle with the details of the plot:
change the font, define a new colour, remove the tick marks, have two
y-axes, change the aspect ratio, insert formulas in LaTeX, etc. So the plot
itself is usually very simple, but I need to be able to make any change
requested by my supervisor, or the journal editor, or the referee.

Personally, I long gave up on trying to use a single program to achieve
both on-screen, interactive, exploratory plotting and figure preparation
for publication. This is reflected in Gaston.jl, which is focused on fast,
simple on-screen plotting. Once the data looks good, I prepare a
for-publication figure using something like pgfplots, which is (IMHO)
unsurpassed at doing that.

-- mb

On Mon, Sep 14, 2015 at 9:03 AM, Daniel Carrera <dcarr...@gmail.com> wrote:

> On Friday, 11 September 2015 03:48:44 UTC+2, Tom Breloff wrote:
>>
>> Hi Miguel... Looking forward to your comments. The short answer is that
>> it depends on the situation. For functionality that just isn't possible for
>> a backend, I'll probably just throw an error (ideally with a message
>> describing other backends that can do what you're looking for). For some
>> cases, I might automatically replace the call with something similar. For
>> an example, I couldn't figure out how to make a "sticks" plot in Gadfly, so
>> I made a bar plot instead. I hope that the package authors can help me with
>> this process though... Sometimes there's undocumented functionality that
>> does what I need, and it would be a big help to have package authors
>> contribute.
>>
>> I also want to hear from people on visualizations that aren't possible
>> with this API, as this all falls apart if you only cover some of your needs
>> through Plots.jl. Look at the TODO at the bottom of the readme for an idea
>> of my roadmap, and let me know if you want me to add to or prioritize
>> something.
>>
>
>
> Overwhelmingly, I do relatively simple scatter plots and line plots; with
> the occasional "heat map" plot. The priority for me is to be able to fiddle
> with the details of the plot: change the font, define a new colour, remove
> the tick marks, have two y-axes, change the aspect ratio, insert formulas
> in LaTeX, etc. So the plot itself is usually very simple, but I need to be
> able to make any change requested by my supervisor, or the journal editor,
> or the referee.
>
> Cheers,
> Daniel.
>
>
>
>
>>
>>
>> On Thursday, September 10, 2015, Miguel Bazdresch <eorl...@gmail.com>
>> wrote:
>>
>>> Hi Tom,
>>>
>>> I'm the author of Gaston.jl. This looks interesting, and I'll take a
>>> closer look. I'm wondering, how do you plan to handle the different
>>> capabilities of each backend? Say, for example, that the user specifies a
>>> plot that Gaston can't handle -- maybe the marker type is not supported by
>>> Gnuplot, or something like that.
>>>
>>> -- mb
>>>
>>> On Thu, Sep 10, 2015 at 4:26 PM, Tom Breloff <t...@breloff.com> wrote:
>>>
>>>> This may be a slightly premature announcement, but I wanted to put it
>>>> out there so that people that have strong opinions have a chance to give
>>>> their thoughts.  Here's the link:
>>>>
>>>> https://github.com/tbreloff/Plots.jl
>>>>
>>>> Plots.jl is intended to be an API/interface that sits above other
>>>> plotting packages (backends) and gives the user simple, consistent, and
>>>> flexible plotting commands.  It's a problem when someone is used to a
>>>> package which is great for interactive plots, but then has to re-learn and
>>>> re-code new plots in another package when producing publication-quality
>>>> plots (or vice versa).  The same goes for switching between desktop GUIs
>>>> and javascript technologies... sometimes one package is better than another
>>>> for a specific task, and it's a shame to be forced to choose.
>>>>
>>>> I've implemented a bunch of functionality for both Gadfly.jl and Qwt.jl
>>>> backends.  See the examples to get a sense of how they differ.  I think
>>>> Vega.jl and UnicodePlots.jl might be next on my priority list, but please
>>>> let me know if I should prioritize differently.  Note: This is still a work
>>>> in progress, and I will probably change parts of the API, and not every
>>>> plot type is implemented yet.
>>>>
>>>> Please let me know comments, wish lists, etc.  Issues are great for
>>>> actionable items, comments can go here.  This effort was partially inspired
>>>> by various discussions here and on github, which prompted the forming of
>>>> https://github.com/JuliaPlot, and an effort to improve the plotting
>>>> landscape with tutorials and documentation.  If you're interested:
>>>> https://github.com/JuliaPlot/juliaplot_docs/issues
>>>>
>>>> Tom
>>>>
>>>
>>>


Re: [julia-users] Re: How to capture the output of a system command?

2015-09-12 Thread Miguel Bazdresch
See this PR: https://github.com/JuliaLang/julia/pull/12807/files

This is a change to `open` that would allow capturing STDERR the way you
want. This change won't make it into v0.4, but the code in there could
point you towards a solution. I hope to have some time soon to dive into
this (I need to implement the same thing in Gaston).

-- mb

On Sat, Sep 12, 2015 at 10:47 AM, J Luis <jmfl...@gmail.com> wrote:

> Right, that's indeed what is (very sadly) happening. It turned out that
> the stderr output is the part that I really need in this case.
> The only working solution I found was to do
>
> run(pipeline(ignorestatus(cmd), stdout=DevNull, stderr="errs.txt"))
> t = readall("errs.txt");
>
> but it's annoying having to write a disk file and read its contents.
>
> Had some hope on this one, but no way too
>
> julia> readall(run(pipeline(ignorestatus(cm), STDOUT, STDOUT)))
> Image Difference (RootMeanSquaredError):
>NormalizedAbsolute
>     ==
>  Red: 0.370961869024311.0
>Green: 0.361139119723667.3
> Blue: 0.263868247017292.6
>Total: 0.335490001721986.3
> C:/programs/GraphicsMagick/gm.exe compare: image difference exceeds limit
> (0.33549 > 0.001).
> ERROR: MethodError: `readall` has no method matching readall(::Void)
>
> and this one completely hangs the REPL giviing me no choice but killing
> the shell window
>
> rd,wr=redirect_stderr();
> run(pipeline(ignorestatus(cmd), stdout=DevNull, stderr=rd))
>
> now if try to read from 'rd'
>
> readall(rd)# ---> IceAge
>
>
> sábado, 12 de Setembro de 2015 às 15:35:39 UTC+1, Miguel Bazdresch
> escreveu:
>>
>> What could be happening is that `gm.exe` is printing that message to
>> STDERR, which is not captured by `readall()`. In theory, the new pipeline
>> infrastructure should let you capture STDERR, but I haven't had the time to
>> figure out exactly how. Maybe somebody who knows will chime in.
>>
>> -- mb
>>
>> On Fri, Sep 11, 2015 at 9:17 PM, J Luis <jmf...@gmail.com> wrote:
>>
>>> Found a ignorestatus function. Better, but not yet good enough. It still
>>> prints a message even if using a suppression ';'
>>>
>>> julia> readall(ignorestatus(cm));
>>> C:/programs/GraphicsMagick/gm.exe compare: image difference exceeds
>>> limit (0.336711 > 0.001).
>>>
>>>
>>> sábado, 12 de Setembro de 2015 às 02:00:25 UTC+1, J Luis escreveu:
>>>>
>>>> Thanks. It turned out my main error was that I was build the Cmd object
>>>> by first creating the command as a string and after wrapping it in back
>>>> ticks.
>>>>
>>>> But I continue in troubles. Right, I can run the command, a
>>>> GraphicsMagic image comparison command, but when that comparison say the
>>>> two images are different gm.exe returns an error code != 0 and Julia
>>>> interprets it a command error. But it isn't, it only means the two images
>>>> are different. As a consequence the julia function where this happens
>>>> aborts (an example in REPL bellow).
>>>>
>>>> I tried with a try catch but not even that prevented the function
>>>> abortion. How can I get out of this one?
>>>>
>>>> julia> readall(cm)
>>>> C:/programs/GraphicsMagick/gm.exe compare: image difference exceeds
>>>> limit (0.33549 > 0.001).
>>>> ERROR: failed process: Process(`C:/programs/GraphicsMagick/gm.exe
>>>> compare -density 200 -maximum-error 0.001 -highlight-color magenta
>>>> -highlight-style assign -metric rmse -file V:/example_02.png
>>>> C:/progs_cygw/GMTdev/gmt5/branches/5.2.0/doc/examples/ex02/
>>>> example_02.ps V:/example_02.ps`, ProcessExited(1)) [1]
>>>>  in pipeline_error at process.jl:548
>>>>
>>>> sábado, 12 de Setembro de 2015 às 01:17:57 UTC+1, Simon Kornblith
>>>> escreveu:
>>>>>
>>>>> readall(`cat test`) or similar
>>>>>
>>>>> On Friday, September 11, 2015 at 7:56:43 PM UTC-4, J Luis wrote:
>>>>>>
>>>>>> Ok, I've spend about an hour around "run" "open", "run(pipeline(..."
>>>>>> but no way.
>>>>>> In Matlab I would do
>>>>>>
>>>>>> [status, cmdout] = system(cmd);
>>>>>>
>>>>>> but in Julia the most a can reach is to run the command
>>>>>>
>>>>>> com = "C:/programs/GraphicsMagick/gm.exe compare -density 200 ...
>>>>>>
>>>>>>run(`com')
>>>>>>
>>>>>> but I need the result of that execution.
>>>>>> How to?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>


Re: [julia-users] META: What are the chances of moving this forum?

2015-09-10 Thread Miguel Bazdresch
Personally, I'd prefer to just have an old-fashioned, LISTERV-type mailing
list. Yes, I'm old.

-- mb

On Wed, Sep 9, 2015 at 7:34 AM, Nils Gudat  wrote:

> Was just thinking about this as first I had to try opening a thread here a
> couple of times before any posts were actually displayed, and then read
> through this
> 
> thread on Mike's Juno Discuss forum, where a user had a question which was
> almost answered by the nice auto-suggestion feature that pops up when you
> ask a question.
>
> I feel that Google Groups has mostly downsides - the system is slow, with
> posts frequently not loading, double posts because of this, no proper code
> formatting or Markdown support etc.
>
> Is there a chance this could be moved to something like Discuss or is
> there too much inertia in having an "established" forum on Google Groups?
>


Re: [julia-users] Help for 'mean' (version 0.4)

2015-09-01 Thread Miguel Bazdresch
The Segmentation Fault strongly suggests a glitch, not an Easter egg,
unfortunately... :)

On Tue, Sep 1, 2015 at 1:12 PM,  wrote:

> Using 0.4:
>
> help?> mean
> search: mean mean! median median! SegmentationFault macroexpand
> module_parent Meta enumerate Enumerate timedwait primes mask
> remotecall remotecall_wait remotecall_fetch MethodTable
>
>   0 (zero; BrE: /ˈzɪərəʊ/ or AmE: /ˈziːroʊ/) is both a number and the
> numerical digit used to represent that number in numerals. It fulfills a
> central role in
>   mathematics as the additive identity of the integers, real numbers,
> and many other algebraic structures. As a digit, 0 is used as a placeholder
> in
>   place value systems. Names for the number 0 in English include zero,
> nought or (US) naught (/ˈnɔːt/), nil, or — in contexts where at least one
>   adjacent digit distinguishes it from the letter "O" — oh or o
> (/ˈoʊ/). Informal or slang terms for zero include zilch and zip. Ought and
> aught (/ˈɔːt/),
>   as well as cipher, have also been used historically.
>
> I like this, but was expecting information about the `mean` function... :)
>
> I tried a few other words, but couldn't get their definitions.
> Disappointed not to find `zilch`:
>
> Couldn't find zilch
> Perhaps you meant zip
>
> True enough.
>
> Or perhaps this is just a nice Easter egg, rather than an interesting
> glitch in the software matrix...
>
>


Re: [julia-users] Re: Too many packages?

2015-07-12 Thread Miguel Bazdresch
In terms of dependencies and size, Gaston is probably minimal; it depends
on gnuplot only, which is a small binary and readily distributed on Linux,
OS X and windows. It offers basic features only (but has 3-D plotting), but
this may be an advantage for a default package. It is also well documented
(at least, I like to think so :)

-- mb

On Sun, Jul 12, 2015 at 5:17 PM, Tony Kelman t...@kelman.net wrote:

 We can probably pick a default, and it'll probably be Gadfly, but last I
 checked Gadfly's support for running outside of IJulia is still a bit
 lacking. To distribute a working version of IJulia you have to get into the
 business of redistributing an entire Python installation, which could be
 quite a rabbit hole.


 On Sunday, July 12, 2015 at 1:59:21 PM UTC-7, Cedric St-Jean wrote:



 On Sunday, July 12, 2015 at 4:47:42 PM UTC-4, Tony Kelman wrote:

  The only thing I really would like to have
  included by default it plotting tools, because they are so essential
 for a lot of things.

 I don't think you're going to find a single plotting tool that satisfies
 everyone, unfortunately. Not everyone likes grammar-of-graphics style
 plotting, or dependencies on Tk or IPython/Jupyter or OpenGL or a web
 browser to have a usable plotting package. Once we figure out the right way
 to bundle packages and make larger distribution versions of Julia we can
 include a few different choices.


 I'm a Julia beginner who is still using pyplot to avoid making a
 decision. Choice is overwhelming when starting out with a new language,
 having a basic distribution that includes sensible defaults (eg.
 Enthought's scipy distribution) will help a lot.




Re: [julia-users] IJulia not working on 0.3.10

2015-06-30 Thread Miguel Bazdresch
Works for me on Linux, with julia v0.3.10, and IJulia master.

-- mb

On Tue, Jun 30, 2015 at 9:00 PM, Gabriel Goh gabgo...@gmail.com wrote:

 Hey everyone,

 I've upgraded to Julia v0.3.10 and did the requisite Pkg.build(IJulia)
 commands. After launching an IJulia notebook, the kernel keeps timing out
 (reported as dead in IPython).

 Downgrading to Julia v0.3.9 and re-running build(IJulia) fixes the
 problem. Any suggestions?

 Gabe



Re: [julia-users] readandwrite: how can I read a line as soon as it's written by the process?

2015-06-27 Thread Miguel Bazdresch
You can make sure that there is data in `so` by looking at its 'bytes
waiting' field. If there is indeed data in the pipe, maybe there is no
newline character in it? Have you tried `readall` instead of `readline`?

-- mb

On Sat, Jun 27, 2015 at 8:45 AM, Laurent Bartholdi 
laurent.bartho...@gmail.com wrote:

 I'm trying to interact with an exterior program, and can't get it to work
 as I want. Let's say the program is od for example. I try:

 julia (so,si,pr) = readandwrite(`od`)
 (Pipe(open, 0 bytes waiting),Pipe(open, 0 bytes waiting),Process(`od`,
 ProcessRunning))

 julia write(si,repeat(test\n,100))
 500
 julia flush(si)
 Pipe(open, 0 bytes waiting)

 julia readline(so)
 ^C # nothing happens, the process is blocking output

 How do I manage to get Julia to give me the output of od? A line was
 already ready after the first 16 characters of input.

 This is related to buffering: if I stuff the buffer, then I do get lines
 asynchronously:
 julia (so,si,pr) = readandwrite(`od`);
 julia write(si,repeat(test\n,1));
 julia readline(so)
 000062564  072163  072012  071545  005164  062564  072163
  072012\n

 However, there also seems to be a bug in Julia here:
 julia (so,si,pr) = readandwrite(`od`);
 julia write(si,repeat(test\n,10));
 # and Julia is stuck
 ^CERROR: InterruptException:
 ERROR (unhandled task failure): write: broken pipe (EPIPE)
  in yieldto at ./task.jl:21
  in wait at ./task.jl:309
  in wait at ./task.jl:225
  in wait_full at ./multi.jl:573
  in take! at ./multi.jl:744
  in take_ref at ./multi.jl:752
  in call_on_owner at ./multi.jl:718
  in anonymous at task.jl:86

 julia pr # hmmm... I wonder in which state the process is
 ^CERROR: InterruptException:

 bash$ # Julia crashed



Re: [julia-users] readandwrite: how can I read a line as soon as it's written by the process?

2015-06-27 Thread Miguel Bazdresch
To answer your question about Gaston first, when I wrote that code nearly 3
years ago, there was no infrastructure in julia to create pipes to external
processes. That's why I went with popen from the C standard library. I will
update that code, but I want to read from both Gnuplot's STDOUT and STDERR
while writing to STDIN, which is not supported by Julia at the moment. I'm
trying to come up with a solution to that.

Are you sure that your process `od` is printing to STDOUT and not STDERR?

The crashes you're seeing look like worth opening an issue for, especially
if they're easy to reproduce.

-- mb

On Sat, Jun 27, 2015 at 11:49 AM, Laurent Bartholdi 
laurent.bartho...@gmail.com wrote:

 Dear Miguel:
 Indeed, data is not made available to the pipe; though it should be there,
 because od prints lines as soon as they're available. I tried readall,
 but it also blocks. I should have added that I tested this with the latest,
 0.4 release from github.

 I also tried just reading one character, with read(so,UInt8), and this
 also blocks.

 I notice that you are the author of the gnuplot package Gaston; so you
 are certainly familiar with the issue. Looking at Gaston's code, I see that
 you directly called :popen from the C library. Is there a reason not to use
 the higher-level interface of Julia?

 I got more crashes by feeding large amounts of data to a pipe:

 julia (so,si,pr) = readandwrite(`od`);

 julia write(si,repeat(test\n,10));
 ^CERROR: InterruptException:Assertion failed: (req-handle == stream),
 function uv__write, file src/unix/stream.c, line 741.

 signal (6): Abort trap: 6
 __pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
 Abort trap: 6
 bash$

 Thanks in advance! Laurent



Re: [julia-users] Re: Problem with ZMQ and Ijulia

2015-06-26 Thread Miguel Bazdresch
I'm sorry for the confusion. I somehow thought they were related.

-- mb

On Thu, Jun 25, 2015 at 11:07 PM, Tony Kelman t...@kelman.net wrote:

 These are two different problems, sorry. The issues you pointed to appear
 to be Linux-only, and due to a version upgrade of libzmq - probably little
 or nothing to do with Julia base. And also not yet completely identified or
 solved.

 The original post here was on Windows, Provider PackageManager failed to
 satisfy dependency zmq, which arose from C++ ABI mismatches due to the
 openSUSE build service (which we use for many binary package dependencies
 on Windows) fixing a typo in a configure flag which changed the way
 libstdc++ deals with strings. C++ is filled with this nonsense, and even
 ZMQ's author regrets writing ZMQ in C++ instead of C.


 On Thursday, June 25, 2015 at 8:13:11 PM UTC-4, Miguel Bazdresch wrote:

 It doesn't, at least for me. ZMQ tests still segfault.

 -- mb

 On Thu, Jun 25, 2015 at 5:36 PM, Tony Kelman to...@kelman.net wrote:

 0.3.10 (released yesterday) should fix this error.


 On Thursday, June 25, 2015 at 10:02:09 AM UTC-4, Miguel Bazdresch wrote:

 These issues may be relevant:

 https://github.com/JuliaLang/ZMQ.jl/issues/83

 https://github.com/JuliaLang/IJulia.jl/issues/323


 -- mb

 On Thu, Jun 25, 2015 at 9:37 AM, Grigoriy Isaev grigoriy...@gmail.com
 wrote:

 It seems that there is unfixed bug somewhere in Juno distribution.
 Latest 64 bit Juno is version 0.3.7 and it has this bug. If i install
 latest Julia 0.4.0 - zero MQ builds correctly and everything is fine with
 Ijulia notebooks using 0.4.0 version



 четверг, 25 июня 2015 г., 16:32:33 UTC+3 пользователь Grigoriy Isaev
 написал:

 Hi!  I am trying to set up  Ijulia. I've cleand my PC from all
 previuos versions of Julia/Ipython and installed fresh 64 bit Anaconda 3
 python distribution + downloaded Juno 64 bit.

 After i launch Ipython i can see Ijulia option, but trying to create
 notebooks i get kernell has died message and a ZMQ error reference.

 I can not re-build ZMQ on my PC, i get the following errors:

 =[ ERROR: ZMQ
 ]=

 Provider PackageManager failed to satisfy dependency zmq
 while loading C:\Users\Gisaev\.julia\v0.3\ZMQ\deps\build.jl, in
 expression starting on line 23

 [ BUILD ERRORS
 ]

 WARNING: ZMQ had build errors.

  - packages with build errors remain installed in
 C:\Users\Gisaev\.julia\v0.3
  - build the package(s) and all dependencies with `Pkg.build(ZMQ)`
  - build a single package by running its `deps/build.jl` script


 I tried Pkg.checkout on both ZMQ and Ijulia but to no avail. Ipython
 notebooks work just fine.

 Any thoughts on what might be the problem?






Re: [julia-users] Re: Problem with ZMQ and Ijulia

2015-06-25 Thread Miguel Bazdresch
These issues may be relevant:

https://github.com/JuliaLang/ZMQ.jl/issues/83

https://github.com/JuliaLang/IJulia.jl/issues/323


-- mb

On Thu, Jun 25, 2015 at 9:37 AM, Grigoriy Isaev grigoriy.v.is...@gmail.com
wrote:

 It seems that there is unfixed bug somewhere in Juno distribution. Latest
 64 bit Juno is version 0.3.7 and it has this bug. If i install latest Julia
 0.4.0 - zero MQ builds correctly and everything is fine with Ijulia
 notebooks using 0.4.0 version



 четверг, 25 июня 2015 г., 16:32:33 UTC+3 пользователь Grigoriy Isaev
 написал:

 Hi!  I am trying to set up  Ijulia. I've cleand my PC from all previuos
 versions of Julia/Ipython and installed fresh 64 bit Anaconda 3 python
 distribution + downloaded Juno 64 bit.

 After i launch Ipython i can see Ijulia option, but trying to create
 notebooks i get kernell has died message and a ZMQ error reference.

 I can not re-build ZMQ on my PC, i get the following errors:

 =[ ERROR: ZMQ
 ]=

 Provider PackageManager failed to satisfy dependency zmq
 while loading C:\Users\Gisaev\.julia\v0.3\ZMQ\deps\build.jl, in
 expression starting on line 23

 [ BUILD ERRORS
 ]

 WARNING: ZMQ had build errors.

  - packages with build errors remain installed in
 C:\Users\Gisaev\.julia\v0.3
  - build the package(s) and all dependencies with `Pkg.build(ZMQ)`
  - build a single package by running its `deps/build.jl` script


 I tried Pkg.checkout on both ZMQ and Ijulia but to no avail. Ipython
 notebooks work just fine.

 Any thoughts on what might be the problem?




Re: [julia-users] Re: Problem with ZMQ and Ijulia

2015-06-25 Thread Miguel Bazdresch
It doesn't, at least for me. ZMQ tests still segfault.

-- mb

On Thu, Jun 25, 2015 at 5:36 PM, Tony Kelman t...@kelman.net wrote:

 0.3.10 (released yesterday) should fix this error.


 On Thursday, June 25, 2015 at 10:02:09 AM UTC-4, Miguel Bazdresch wrote:

 These issues may be relevant:

 https://github.com/JuliaLang/ZMQ.jl/issues/83

 https://github.com/JuliaLang/IJulia.jl/issues/323


 -- mb

 On Thu, Jun 25, 2015 at 9:37 AM, Grigoriy Isaev grigoriy...@gmail.com
 wrote:

 It seems that there is unfixed bug somewhere in Juno distribution.
 Latest 64 bit Juno is version 0.3.7 and it has this bug. If i install
 latest Julia 0.4.0 - zero MQ builds correctly and everything is fine with
 Ijulia notebooks using 0.4.0 version



 четверг, 25 июня 2015 г., 16:32:33 UTC+3 пользователь Grigoriy Isaev
 написал:

 Hi!  I am trying to set up  Ijulia. I've cleand my PC from all previuos
 versions of Julia/Ipython and installed fresh 64 bit Anaconda 3 python
 distribution + downloaded Juno 64 bit.

 After i launch Ipython i can see Ijulia option, but trying to create
 notebooks i get kernell has died message and a ZMQ error reference.

 I can not re-build ZMQ on my PC, i get the following errors:

 =[ ERROR: ZMQ
 ]=

 Provider PackageManager failed to satisfy dependency zmq
 while loading C:\Users\Gisaev\.julia\v0.3\ZMQ\deps\build.jl, in
 expression starting on line 23

 [ BUILD ERRORS
 ]

 WARNING: ZMQ had build errors.

  - packages with build errors remain installed in
 C:\Users\Gisaev\.julia\v0.3
  - build the package(s) and all dependencies with `Pkg.build(ZMQ)`
  - build a single package by running its `deps/build.jl` script


 I tried Pkg.checkout on both ZMQ and Ijulia but to no avail. Ipython
 notebooks work just fine.

 Any thoughts on what might be the problem?





Re: [julia-users] Reading from and writing to a process using a pipe

2015-06-22 Thread Miguel Bazdresch
Kevin, I tried to use your code, but I also need a pipe to gnuplot's stdin. If
I understand correctly, `open_stdout_stderr` connects the commands' stdin
to DevNul; this causes gnuplot to exit immediately after calling the
function, since there is no way to send it any commands.

I tried modifying your function by just adding `in` and `cmd_in` pipes,
linking them, and calling spawn as

r = spawn(false, ignorestatus(cmd), (cmd_in, cmd_out, cmd_err))

but I am missing something: gnuplot keeps dying just after I call the
function. Can you tell what I'm missing?

My complete code is:

function open_stdin_stdout_stderr(cmd::Cmd)
   in = Base.Pipe(C_NULL)
   out = Base.Pipe(C_NULL)
   err = Base.Pipe(C_NULL)
   cmd_in = Base.Pipe(C_NULL)
   cmd_out = Base.Pipe(C_NULL)
   cmd_err = Base.Pipe(C_NULL)
   Base.link_pipe(in, true, cmd_in, false)
   Base.link_pipe(out, true, cmd_out, false)
   Base.link_pipe(err, true, cmd_err, false)

   r = spawn(false, ignorestatus(cmd), (cmd_in, cmd_out, cmd_err))
   Base.close_pipe_sync(cmd_out)
   Base.close_pipe_sync(cmd_err)
   Base.close_pipe_sync(cmd_in)

   # NOTE: these are not necessary on v0.4 (although they don't seem
   #   to hurt). Remove when we drop support for v0.3.
   Base.start_reading(out)
   Base.start_reading(err)

   return (in, out, err, r)
   end


On Thu, Jun 18, 2015 at 12:11 PM, Kevin Squire kevin.squ...@gmail.com
wrote:

 I don't think there's a standard way--at least, I couldn't find it when I
 looked. I ended up rolling my own--see
 https://github.com/kmsquire/VideoIO.jl/blob/master/src/util.jl.

 This functionality should probably be part of readandwrite.

 Cheers,
Kevin


 On Thursday, June 18, 2015, Miguel Bazdresch eorli...@gmail.com wrote:

 Is there a way to read the spawned process' STDERR? Gnuplot likes to
 write most output to it. I've tried

 readandwrite(`gnuplot 21`)

 but gnuplot interprets 21 as a filename and fails.

 This, however, works:

 readandwrite(`gnuplot` . /tmp/gnuplot.err)

 but I'd like to avoid having to create a file.

 Thanks!

 On Wed, Jun 17, 2015 at 1:05 PM, Kevin Squire kevin.squ...@gmail.com
 wrote:

 `open(cmd, w)` gives back a tuple.  Try using

 f, p = open(`gnuplot`,w)
 write(f, plot sin(x))

 There was a bit of discussion when this change was made (I couldn't find
 it with a quick search), about this returning a tuple--it's a little
 unintuitive, and could be `fixed` in a few different ways (easiest:
 returning a complex type that can be written to and read from), but it's
 probably been off most people's radar.  If you're up for it, why don't you
 open an issue (if one doesn't exist).

 Anyway, for your particular application, you probably want
 `readandwrite`:

 help? readandwrite
 search: readandwrite

 Base.readandwrite(command)

Starts running a command asynchronously, and returns a tuple
(stdout,stdin,process) of the output stream and input stream of the
process, and the process object itself.

 Which *also* returns a tuple (but at least now you know).

 See also
 http://blog.leahhanson.us/running-shell-commands-from-julia.html, which
 has a full rundown of reading and writing from processes.

 Cheers!
Kevin

 On Wed, Jun 17, 2015 at 9:03 AM, Miguel Bazdresch eorli...@gmail.com
 wrote:

 Hello,

 Gaston.jl is a plotting package based on gnuplot. Gnuplot is
 command-line tool, so I send commands to it via a pipe. I open the pipe (on
 Linux) with a ccall to popen, and write gnuplot commands to the pipe
 using a ccall to fputs.

 This works fine, but I'm trying to see if Julia's native pipe and
 stream functionality can make this process more Julian and, in the process,
 more cross-platform. The documentation is encouraging:

 You can use [a Cmd] object to connect the command to others via pipes,
 run it, and read or write to it. and Julia provides a rich interface to
 deal with streaming I/O objects such as terminals, pipes and TCP sockets.
 Unfortunately, I just can't figure out how to use Julia's functionality for
 this purpose. This is what I've tried (I am on Julia 0.3.9):

 First, I tried using `open` with read and write:

 julia f=open(`gnuplot`,r+)
 ERROR: ArgumentError(mode must be \r\ or \w\, not \r+\)

 So I tried with write only:

 julia f=open(`gnuplot`,w)
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))

 So far, this looks good. I can see a gnuplot process running.

 Then I try to `write` to the pipe:

 julia write(f,plot sin(x))
 ERROR: `write` has no method matching write(::(Pipe,Process),
 ::ASCIIString)

 OK, so let's try with `println`:

 julia println(f,plot sin(x))
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`,
 ProcessRunning))plot sin(x)

 and no plot is produced.

 I can't figure out how to read from the pipe, either:

 julia readbytes(f)
 ERROR

Re: [julia-users] Reading from and writing to a process using a pipe

2015-06-18 Thread Miguel Bazdresch
Is there a way to read the spawned process' STDERR? Gnuplot likes to write
most output to it. I've tried

readandwrite(`gnuplot 21`)

but gnuplot interprets 21 as a filename and fails.

This, however, works:

readandwrite(`gnuplot` . /tmp/gnuplot.err)

but I'd like to avoid having to create a file.

Thanks!

On Wed, Jun 17, 2015 at 1:05 PM, Kevin Squire kevin.squ...@gmail.com
wrote:

 `open(cmd, w)` gives back a tuple.  Try using

 f, p = open(`gnuplot`,w)
 write(f, plot sin(x))

 There was a bit of discussion when this change was made (I couldn't find
 it with a quick search), about this returning a tuple--it's a little
 unintuitive, and could be `fixed` in a few different ways (easiest:
 returning a complex type that can be written to and read from), but it's
 probably been off most people's radar.  If you're up for it, why don't you
 open an issue (if one doesn't exist).

 Anyway, for your particular application, you probably want `readandwrite`:

 help? readandwrite
 search: readandwrite

 Base.readandwrite(command)

Starts running a command asynchronously, and returns a tuple
(stdout,stdin,process) of the output stream and input stream of the
process, and the process object itself.

 Which *also* returns a tuple (but at least now you know).

 See also http://blog.leahhanson.us/running-shell-commands-from-julia.html,
 which has a full rundown of reading and writing from processes.

 Cheers!
Kevin

 On Wed, Jun 17, 2015 at 9:03 AM, Miguel Bazdresch eorli...@gmail.com
 wrote:

 Hello,

 Gaston.jl is a plotting package based on gnuplot. Gnuplot is command-line
 tool, so I send commands to it via a pipe. I open the pipe (on Linux) with
 a ccall to popen, and write gnuplot commands to the pipe using a ccall to
 fputs.

 This works fine, but I'm trying to see if Julia's native pipe and stream
 functionality can make this process more Julian and, in the process, more
 cross-platform. The documentation is encouraging:

 You can use [a Cmd] object to connect the command to others via pipes,
 run it, and read or write to it. and Julia provides a rich interface to
 deal with streaming I/O objects such as terminals, pipes and TCP sockets.
 Unfortunately, I just can't figure out how to use Julia's functionality for
 this purpose. This is what I've tried (I am on Julia 0.3.9):

 First, I tried using `open` with read and write:

 julia f=open(`gnuplot`,r+)
 ERROR: ArgumentError(mode must be \r\ or \w\, not \r+\)

 So I tried with write only:

 julia f=open(`gnuplot`,w)
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))

 So far, this looks good. I can see a gnuplot process running.

 Then I try to `write` to the pipe:

 julia write(f,plot sin(x))
 ERROR: `write` has no method matching write(::(Pipe,Process),
 ::ASCIIString)

 OK, so let's try with `println`:

 julia println(f,plot sin(x))
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))plot
 sin(x)

 and no plot is produced.

 I can't figure out how to read from the pipe, either:

 julia readbytes(f)
 ERROR: `readbytes` has no method matching readbytes(::(Pipe,Process))

 julia readall(f)
 ERROR: `readall` has no method matching readall(::(Pipe,Process))

 I'd appreciate any pointers. Thanks!

 -- mb





Re: [julia-users] Reading from and writing to a process using a pipe

2015-06-17 Thread Miguel Bazdresch
Thanks! `readandwrite` looks exactly like what I need. I'll try it out.

I don't mind too much that this (and related) commands return a tuple,
although I'd prefer the alternative discussed in issue 9659. What I'd much
prefer is for them to be documented under Running external programs, and
not under Essentials, where I never thought to look for them. Once I get
a better handle for how they work, I'll try to improve the docs in this
respect.

-- mb

On Wed, Jun 17, 2015 at 1:05 PM, Kevin Squire kevin.squ...@gmail.com
wrote:

 `open(cmd, w)` gives back a tuple.  Try using

 f, p = open(`gnuplot`,w)
 write(f, plot sin(x))

 There was a bit of discussion when this change was made (I couldn't find
 it with a quick search), about this returning a tuple--it's a little
 unintuitive, and could be `fixed` in a few different ways (easiest:
 returning a complex type that can be written to and read from), but it's
 probably been off most people's radar.  If you're up for it, why don't you
 open an issue (if one doesn't exist).

 Anyway, for your particular application, you probably want `readandwrite`:

 help? readandwrite
 search: readandwrite

 Base.readandwrite(command)

Starts running a command asynchronously, and returns a tuple
(stdout,stdin,process) of the output stream and input stream of the
process, and the process object itself.

 Which *also* returns a tuple (but at least now you know).

 See also http://blog.leahhanson.us/running-shell-commands-from-julia.html,
 which has a full rundown of reading and writing from processes.

 Cheers!
Kevin

 On Wed, Jun 17, 2015 at 9:03 AM, Miguel Bazdresch eorli...@gmail.com
 wrote:

 Hello,

 Gaston.jl is a plotting package based on gnuplot. Gnuplot is command-line
 tool, so I send commands to it via a pipe. I open the pipe (on Linux) with
 a ccall to popen, and write gnuplot commands to the pipe using a ccall to
 fputs.

 This works fine, but I'm trying to see if Julia's native pipe and stream
 functionality can make this process more Julian and, in the process, more
 cross-platform. The documentation is encouraging:

 You can use [a Cmd] object to connect the command to others via pipes,
 run it, and read or write to it. and Julia provides a rich interface to
 deal with streaming I/O objects such as terminals, pipes and TCP sockets.
 Unfortunately, I just can't figure out how to use Julia's functionality for
 this purpose. This is what I've tried (I am on Julia 0.3.9):

 First, I tried using `open` with read and write:

 julia f=open(`gnuplot`,r+)
 ERROR: ArgumentError(mode must be \r\ or \w\, not \r+\)

 So I tried with write only:

 julia f=open(`gnuplot`,w)
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))

 So far, this looks good. I can see a gnuplot process running.

 Then I try to `write` to the pipe:

 julia write(f,plot sin(x))
 ERROR: `write` has no method matching write(::(Pipe,Process),
 ::ASCIIString)

 OK, so let's try with `println`:

 julia println(f,plot sin(x))
 (Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))plot
 sin(x)

 and no plot is produced.

 I can't figure out how to read from the pipe, either:

 julia readbytes(f)
 ERROR: `readbytes` has no method matching readbytes(::(Pipe,Process))

 julia readall(f)
 ERROR: `readall` has no method matching readall(::(Pipe,Process))

 I'd appreciate any pointers. Thanks!

 -- mb





Re: [julia-users] Help: My parallel code 8300x slower than the serial.

2015-06-17 Thread Miguel Bazdresch
Can you arrange the problem so that you send each CPU a few seconds of
work? The overhead would become negligible.

-- mb

On Wed, Jun 17, 2015 at 4:38 PM, Daniel Carrera dcarr...@gmail.com wrote:

 Sadly, this function is pretty close to the real workload. I do n-body
 simulations of planetary systems. In this problem, the value of n is
 small, but the simulation runs for a very long time. So this nested for
 loop will be called maybe 10 billion times in the course of one simulation,
 and that's where all the CPU time goes.

 I already have simulation software that works well enough for this. I just
 wanted to experiment with Julia to see if this could be made parallel. An
 irritating problem with all the codes that solve planetary systems is that
 they are all serial -- this problem is apparently hard to parallelize.


 Cheers,
 Daniel.



 On 17 June 2015 at 17:02, Tim Holy tim.h...@gmail.com wrote:

 You're copying a lot of data between processes. Check out SharedArrays.
 But I
 still fear that if each job is tiny, you may not get as much benefit
 without
 further restructuring.

 I trust that your real workload will take more than 1ms. Otherwise, it's
 very unlikely that your experiments in parallel programming will end up
 saving
 you time :-).

 --Tim

 On Wednesday, June 17, 2015 06:37:28 AM Daniel Carrera wrote:
  Hi everyone,
 
  My adventures with parallel programming with Julia continue. Here is a
  different issue from other threads: My parallel function is 8300x slower
  than my serial function even though I am running on 4 processes on a
  multi-core machine.
 
  julia nprocs()
  4
 
  I have Julia 0.3.8. Here is my program in its entirety (not very long).
 
  function main()
 
  nbig::Int16 = 7
  nbod::Int16 = nbig
  bod  = Float64[
  0   1  2  3  4  5  6  # x position
  0   0  0  0  0  0  0  # y position
  0   0  0  0  0  0  0  # z position
  0   0  0  0  0  0  0  # x velocity
  0   0  0  0  0  0  0  # y velocity
  0   0  0  0  0  0  0  # z velocity
  1   1  1  1  1  1  1  # Mass
  ]
 
  a = zeros(3,nbod)
 
  @time for k = 1:1000
  gravity_1!(bod, nbig, nbod, a)
  end
  println(a[1,:])
 
  @time for k = 1:1000
  gravity_2!(bod, nbig, nbod, a)
  end
  println(a[1,:])
  end
 
  function gravity_1!(bod, nbig, nbod, a)
 
  for i = 1:nbod
  a[1,i] = 0.0
  a[2,i] = 0.0
  a[3,i] = 0.0
  end
 
  @inbounds for i = 1:nbig
  for j = (i + 1):nbod
 
  dx = bod[1,j] - bod[1,i]
  dy = bod[2,j] - bod[2,i]
  dz = bod[3,j] - bod[3,i]
 
  s_1 = 1.0 / sqrt(dx*dx+dy*dy+dz*dz)
  s_3 = s_1 * s_1 * s_1
 
  tmp1 = s_3 * bod[7,i]
  tmp2 = s_3 * bod[7,j]
 
  a[1,j] = a[1,j] - tmp1*dx
  a[2,j] = a[2,j] - tmp1*dy
  a[3,j] = a[3,j] - tmp1*dz
 
  a[1,i] = a[1,i] + tmp2*dx
  a[2,i] = a[2,i] + tmp2*dy
  a[3,i] = a[3,i] + tmp2*dz
  end
  end
  return a
  end
 
  function gravity_2!(bod, nbig, nbod, a)
 
  for i = 1:nbod
  a[1,i] = 0.0
  a[2,i] = 0.0
  a[3,i] = 0.0
  end
 
  @inbounds @sync @parallel for i = 1:nbig
  for j = (i + 1):nbod
 
  dx = bod[1,j] - bod[1,i]
  dy = bod[2,j] - bod[2,i]
  dz = bod[3,j] - bod[3,i]
 
  s_1 = 1.0 / sqrt(dx*dx+dy*dy+dz*dz)
  s_3 = s_1 * s_1 * s_1
 
  tmp1 = s_3 * bod[7,i]
  tmp2 = s_3 * bod[7,j]
 
  a[1,j] = a[1,j] - tmp1*dx
  a[2,j] = a[2,j] - tmp1*dy
  a[3,j] = a[3,j] - tmp1*dz
 
  a[1,i] = a[1,i] + tmp2*dx
  a[2,i] = a[2,i] + tmp2*dy
  a[3,i] = a[3,i] + tmp2*dz
  end
  end
  return a
  end
 
 
 
  So this is a straight forward N-body gravity calculation. Yes, I realize
  that gravity_2!() is wrong, but that's fine. Right now I'm just talking
  about the CPU time. When I run this on my computer I get:
 
  julia main()
  elapsed time: 0.000475294 seconds (0 bytes allocated)
  [1.49138889 0.4636 0.1736
  -5.551115123125783e-17 -0.17366 -0.46361112
  -1.49138889]
  elapsed time: 3.953546654 seconds (126156320 bytes allocated, 13.49% gc
  time)
  [0.0 0.0 0.0 0.0 0.0 0.0 0.0]
 
 
  So, the serial version takes 0.000475 seconds and the parallel takes
 3.95
  seconds. Furthermore, the parallel version is calling the garbage
  collector. I suspect that the problem has something to do with the
 memory
  access. Maybe the parallel code is wasting a lot of time copying
 variables
  in memory. But whatever the reason, this is bad. The documentation 

Re: [julia-users] Please sdvise how to plot the matrix (10x1000) with different color

2015-06-17 Thread Miguel Bazdresch
Note that in most plotting packages, `plot(vec)` is interpreted as 1000
functions of 10 elements each. That is, when given a matrix as argument,
they plot the columns.

-- mb

On Tue, Jun 16, 2015 at 8:10 PM, Nelson Mok laishun@gmail.com wrote:

 HI,

 Please comment, how to plot the matrix (10x1000) with different color,
 thank you

 ==
 using Gadfly

 ## number of vectors
 n = 10

 ## number of elements
 n_elm = 1000

 vec = randn(n, n_elm)
 plot(vec)   # it doesn't work

 Regards,
 Nelson.



[julia-users] Reading from and writing to a process using a pipe

2015-06-17 Thread Miguel Bazdresch
Hello,

Gaston.jl is a plotting package based on gnuplot. Gnuplot is command-line
tool, so I send commands to it via a pipe. I open the pipe (on Linux) with
a ccall to popen, and write gnuplot commands to the pipe using a ccall to
fputs.

This works fine, but I'm trying to see if Julia's native pipe and stream
functionality can make this process more Julian and, in the process, more
cross-platform. The documentation is encouraging:

You can use [a Cmd] object to connect the command to others via pipes, run
it, and read or write to it. and Julia provides a rich interface to deal
with streaming I/O objects such as terminals, pipes and TCP sockets.
Unfortunately, I just can't figure out how to use Julia's functionality for
this purpose. This is what I've tried (I am on Julia 0.3.9):

First, I tried using `open` with read and write:

julia f=open(`gnuplot`,r+)
ERROR: ArgumentError(mode must be \r\ or \w\, not \r+\)

So I tried with write only:

julia f=open(`gnuplot`,w)
(Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))

So far, this looks good. I can see a gnuplot process running.

Then I try to `write` to the pipe:

julia write(f,plot sin(x))
ERROR: `write` has no method matching write(::(Pipe,Process),
::ASCIIString)

OK, so let's try with `println`:

julia println(f,plot sin(x))
(Pipe(open, 0 bytes waiting),Process(`gnuplot`, ProcessRunning))plot
sin(x)

and no plot is produced.

I can't figure out how to read from the pipe, either:

julia readbytes(f)
ERROR: `readbytes` has no method matching readbytes(::(Pipe,Process))

julia readall(f)
ERROR: `readall` has no method matching readall(::(Pipe,Process))

I'd appreciate any pointers. Thanks!

-- mb


Re: [julia-users] Is there a plotting package that works for a current 0.4 build?

2015-04-24 Thread Miguel Bazdresch
I haven't tried Gaston on master, but it _may_ work, if you're on Linux or
MacOS.

-- mb

On Fri, Apr 24, 2015 at 6:58 AM, Tomas Lycken tomas.lyc...@gmail.com
wrote:

 I git pull-ed and built Julia this morning, and I can't get any of PyPlot,
 Winston or Gadfly or TextPlots to show me anything (either loading the
 package, or running something equivalent to plot(rand(15)), borked).

 Is there any plotting tool that's had time to adjust to the tuplocalypse
 and other recent breaking changes?

 // T



Re: [julia-users] Write your GNU Radio blocks in Julia

2015-04-20 Thread Miguel Bazdresch
This is great, and something I wanted to do but hadn't had time for. I'll
give it a try when I have a chance.

On Mon, Apr 20, 2015 at 10:22 AM, Jay Kickliter jay.kickli...@gmail.com
wrote:

 I just pushed a rough draft gr-juliaffi
 https://github.com/JayKickliter/gr-juliaffi to GitHub. It is not a
 Julia package, but a GNU Radio module (C++/Python) that calls your Julia
 code to do the actual signal processing.

 If you're not familiar with GNU Radio, it is a software defined radio
 (SDR) framework. SDR is really cool. Traditional radio hardware is
 dedicated  to certain kind of signal (like a satellite modem or FM
 receiver). SDR lets you use generic hardware that does little more than
 digitize the raw radio waves and send them to a computer. From there, all
 the signal processing is performed in software. There are real world
 applications
 http://www.fsf.org/blogs/community/free-software-in-space-gnu-radio-and-the-isee-3-spacecraft
 of SDR. I use it almost every day.

 The motivation for this block came recently when I needed something GNU
 Radio didn't have yet. At my job, we're developing new 802.15.4 hardware.
 There is an 802.15.4 https://github.com/bastibl/gr-ieee802-15-4.git
 out-of-tree module for GNU Radio, but it's not complete and doesn't have
 the capability of de-spreading
 http://en.wikipedia.org/wiki/Direct-sequence_spread_spectrum 802.15.4 900
 MHz BPSK signals. I wrote code to de-spread the signal in Julia, and piped
 from/to GNU Radio using ZeroMQ. That works fine, but it's cumbersome. Why
 not just have GNU Radio call the Julia code directly?

 If you do want to use the module, please let me know what issues you run
 into when building/using it. I spent two solid days just trying to get
 cmake to find and properly set up linking to libjulia. I'm using OS X, and
 @rpath was causing the biggest problem for me. It only built when I finally
 stopped trying to tell cmake where to find libjulia and switched to
 find_library. Also I had to do an actual `make install release` in the
 Julia repo for all the headers and libraries to be in predictable
 locations. That's because the FindJulia cmake  module I added calls julia
 on the command line to figure out where stuff is. The code still crashes if
 I try to run it with `jl_init(NULL)
 https://github.com/JayKickliter/gr-juliaffi/blob/master/lib/juliablock_ff_impl.cc#L47
 '.

  There's still more c++ work to be done, and I don't know c++. I just
 infinite monkey it 'till it works. I just hope I or someone else can figure
 out how to make the c++ configure itself dynamically, so it isn't necessary
 to define blocks for every combo of input/output type. Most of the repo was
 automatically created with gr_modtool. This file
 https://github.com/JayKickliter/gr-juliaffi/blob/master/lib/juliablock_ff_impl.cc
 is pretty much the whole project. It's definitely possible to change the
 number of inputs/outputs to block at runtime. Looking at the code, I think
 it may be possible to change the type as well.

 I was hoping have this done with some good examples in time to give a
 JuliaCon talk. Maybe next year. I'll be there anyway, if anyone's
 interested I'll give an informal demo.



Re: [julia-users] Write your GNU Radio blocks in Julia

2015-04-20 Thread Miguel Bazdresch
I'm using GnuRadio on Ubuntu mainly. I may not have a chance to try it out
until the summer, though. On a somewhat related note, something that I also
want to tackle when I have some time is a julia interface to  the UHD, so
that we can control the radios directly from Julia.

-- mb

On Mon, Apr 20, 2015 at 11:37 AM, Jay Kickliter jay.kickli...@gmail.com
wrote:

 Thanks. What OS are you using, and how did you install Julia/GNU Radio?
 I'll attempt to fix any major problems before you try it out.

 On Monday, April 20, 2015 at 9:33:18 AM UTC-6, Miguel Bazdresch wrote:

 This is great, and something I wanted to do but hadn't had time for. I'll
 give it a try when I have a chance.

 On Mon, Apr 20, 2015 at 10:22 AM, Jay Kickliter jay.ki...@gmail.com
 wrote:

 I just pushed a rough draft gr-juliaffi
 https://github.com/JayKickliter/gr-juliaffi to GitHub. It is not a
 Julia package, but a GNU Radio module (C++/Python) that calls your Julia
 code to do the actual signal processing.

 If you're not familiar with GNU Radio, it is a software defined radio
 (SDR) framework. SDR is really cool. Traditional radio hardware is
 dedicated  to certain kind of signal (like a satellite modem or FM
 receiver). SDR lets you use generic hardware that does little more than
 digitize the raw radio waves and send them to a computer. From there, all
 the signal processing is performed in software. There are real world
 applications
 http://www.fsf.org/blogs/community/free-software-in-space-gnu-radio-and-the-isee-3-spacecraft
 of SDR. I use it almost every day.

 The motivation for this block came recently when I needed something GNU
 Radio didn't have yet. At my job, we're developing new 802.15.4 hardware.
 There is an 802.15.4 https://github.com/bastibl/gr-ieee802-15-4.git
 out-of-tree module for GNU Radio, but it's not complete and doesn't have
 the capability of de-spreading
 http://en.wikipedia.org/wiki/Direct-sequence_spread_spectrum 802.15.4 900
 MHz BPSK signals. I wrote code to de-spread the signal in Julia, and piped
 from/to GNU Radio using ZeroMQ. That works fine, but it's cumbersome. Why
 not just have GNU Radio call the Julia code directly?

 If you do want to use the module, please let me know what issues you run
 into when building/using it. I spent two solid days just trying to get
 cmake to find and properly set up linking to libjulia. I'm using OS X, and
 @rpath was causing the biggest problem for me. It only built when I finally
 stopped trying to tell cmake where to find libjulia and switched to
 find_library. Also I had to do an actual `make install release` in the
 Julia repo for all the headers and libraries to be in predictable
 locations. That's because the FindJulia cmake  module I added calls julia
 on the command line to figure out where stuff is. The code still crashes if
 I try to run it with `jl_init(NULL)
 https://github.com/JayKickliter/gr-juliaffi/blob/master/lib/juliablock_ff_impl.cc#L47
 '.

  There's still more c++ work to be done, and I don't know c++. I just
 infinite monkey it 'till it works. I just hope I or someone else can figure
 out how to make the c++ configure itself dynamically, so it isn't necessary
 to define blocks for every combo of input/output type. Most of the repo was
 automatically created with gr_modtool. This file
 https://github.com/JayKickliter/gr-juliaffi/blob/master/lib/juliablock_ff_impl.cc
 is pretty much the whole project. It's definitely possible to change the
 number of inputs/outputs to block at runtime. Looking at the code, I think
 it may be possible to change the type as well.

 I was hoping have this done with some good examples in time to give a
 JuliaCon talk. Maybe next year. I'll be there anyway, if anyone's
 interested I'll give an informal demo.





Re: [julia-users] 3D interactive plots in IJulia

2015-03-03 Thread Miguel Bazdresch
You can do 3-D plots with Gaston.jl, and rotate them with the mouse. I
haven't added the required interface to make it compatible with IJulia,
though. Even doing that, I doubt that the plot would still be interactive,
since that functionality is provided by Gnuplot.

-- mb

On Tue, Mar 3, 2015 at 10:38 AM, Andrei Berceanu andreiberce...@gmail.com
wrote:

 Is there some Julia library that allows one to do create 3D (surface
 plots) in the IJulia notebook and then rotate them interactively, using the
 mouse?

 //A



Re: [julia-users] How Julia do math operations

2014-11-04 Thread Miguel Bazdresch
On Matlab R2013b:

 2*10.97 + 23.9985
ans =
   45.9385
 2*10.97 + 23.9985 == 45.9385
ans =
 0


-- mb

On Tue, Nov 4, 2014 at 7:48 PM, Stefan Karpinski ste...@karpinski.org
wrote:

 Some systems round their answers as John said but it's easy to check that
 it's a lie:

 R version 3.1.0 (2014-04-10) -- Spring Dance
  2*10.97 + 23.9985
 [1] 45.9385
  2*10.97 + 23.9985 == 45.9385
 [1] FALSE

 This is perl 5, version 16, subversion 2 (v5.16.2)
   DB1 x 2*10.97 + 23.9985
 0  45.9385
   DB2 x 2*10.97 + 23.9985 == 45.9385
 0  ''


 I don't have a working copy of Matlab right now, but I think it does this
 too.

 On Tue, Nov 4, 2014 at 8:31 PM, Neil Devadasan ndeva...@gmail.com wrote:

 Thanks

 On Tuesday, November 4, 2014 2:13:37 PM UTC-5, John Myles White wrote:

 Hi Neil,

 Julie does math the same way that all computers do math. You're probably
 coming from another language where a lot of effort is invested into
 pretending that computers offer a closer approximation to abstract
 mathematics than they actually do. Those systems have been lying to you.

 Put another way: you just took the red pill by using Julia.

  -- John

 On Nov 4, 2014, at 11:06 AM, Neil Devadasan ndev...@gmail.com wrote:

  julia f(x::Float64, y::Float64) = 2x + y;
 
  julia f(10.97,23.9985)
  45.9385005
 
  The above method execution of function f returns an answer that I
 cannot understand.  Can someone clarify?
 
  Thank you.





Re: [julia-users] type confusions in list comprehensions (and how to work around it?)

2014-11-03 Thread Miguel Bazdresch
 How could I force the type of gxs1 to be of an array of Float64?

The simplest way is:

gxs1 = Float64[g(x) for x in xs]

-- mb

On Mon, Nov 3, 2014 at 6:01 PM, Evan Pu evanthebou...@gmail.com wrote:

 Consider the following interaction:

 julia g(x) = 1 / (1 + x)
 g (generic function with 1 method)

 julia typeof(g(1.0))
 Float64

 julia xs = [1.0, 2.0, 3.0, 4.0]
 4-element Array{Float64,1}:
  1.0
  2.0
  3.0
  4.0

 julia gxs1 = [g(x) for x in xs]
 4-element Array{Any,1}:
  0.5
  0.33
  0.25
  0.2

 Why isn't gxs1 type of Array{Float64,1}?
 How could I force the type of gxs1 to be of an array of Float64?

 julia gxs2 = [convert(Float64,g(x)) for x in xs]
 4-element Array{Any,1}:
  0.5
  0.33
  0.25
  0.2

 somehow this doesn't seem to work...






Re: [julia-users] repmat :comparison with Matlab/Octave - 6x slow?

2014-10-14 Thread Miguel Bazdresch
Of course, that's the best way to do it -- Thanks.

-- mb

On Tue, Oct 14, 2014 at 7:34 AM, Johan Sigfrids johan.sigfr...@gmail.com
wrote:

 You can tell ones to construct a array on Ints by passing it a type
 parameter:

 ones(Int, 1, 3)

 With a length of three it doesn't make much difference but with a bigger
 array you save a lot of time avoiding the conversion.

 On Tuesday, October 14, 2014 3:14:38 AM UTC+3, Miguel Bazdresch wrote:

 Just wanted to point out a little-known way to achieve the same with the
 `kron` (Kronecker product) command:

 julia x=[1 2 3 4]
 1x4 Array{Int64,2}:
  1  2  3  4

 julia kron(x,int(ones(1,3)))
 1x12 Array{Int64,2}:
  1  1  1  2  2  2  3  3  3  4  4  4

 -- mb

 On Mon, Oct 13, 2014 at 6:05 PM, Rajn rjngr...@gmail.com wrote:



 Hi,
 I have two questions.

 First question:

 I have a fairly simple problem which can be solved in many ways.

 To begin I have a vector
 z1=Array(Float64,1,0)

 I have
 Z=1:0.01:100

 I would like to generate a vector in which each element is repeated
 length(Z) times i.e., [1 1 1 1length(Z) times 1.01 1.01
 1.01length(Z) times and so on

 When I do
 for j=1:length(Z)
  z1=[z1 repmat([Z[j]],1,length(Z)]
 end

 and compare the time for this exact code with Matlab's/Octave, Julia
 takes 7 seconds in comparison to 1.5 seconds for Matlab/Octave.

 Of course I did not see any improvement using
 z1=[z1 ones(1,length(Z))*Z[j]]

 It took practically the same time.

 However, this reduced to fraction of a second...i.e., after I generated
 a vector of zeros and just replaced the zeros appropriately.
 z1=zeros(1,length(Z)^2)
 length(Z)=dd
 for j=1:dd
  v=1:dd:(dd-1)*dd
  z1[1,v[j]:(v[j+dd-1])]=Z[j];
 end

  Of course even Octave/Matlab became equally fast with this code.

 So what gives in repmat for Julia? Why is it slow? Have I gone wrong
 with my first code?




 Question 2:
 If I start with A=[]
 How do I vcat or hcat a row or a column vector to A in a for loop form a
 MATRIX.
 say my vector is A(10x1) and I want to make B=[A[1] A[2] A[3] A[4]]
 which is a 10x4 matrix.
 In Octave I would do
 B=[]
 B=[B A[j]] in a for loop.

 Thanks





Re: [julia-users] repmat :comparison with Matlab/Octave - 6x slow?

2014-10-13 Thread Miguel Bazdresch
Just wanted to point out a little-known way to achieve the same with the
`kron` (Kronecker product) command:

julia x=[1 2 3 4]
1x4 Array{Int64,2}:
 1  2  3  4

julia kron(x,int(ones(1,3)))
1x12 Array{Int64,2}:
 1  1  1  2  2  2  3  3  3  4  4  4

-- mb

On Mon, Oct 13, 2014 at 6:05 PM, Rajn rjngrj2...@gmail.com wrote:



 Hi,
 I have two questions.

 First question:

 I have a fairly simple problem which can be solved in many ways.

 To begin I have a vector
 z1=Array(Float64,1,0)

 I have
 Z=1:0.01:100

 I would like to generate a vector in which each element is repeated
 length(Z) times i.e., [1 1 1 1length(Z) times 1.01 1.01
 1.01length(Z) times and so on

 When I do
 for j=1:length(Z)
  z1=[z1 repmat([Z[j]],1,length(Z)]
 end

 and compare the time for this exact code with Matlab's/Octave, Julia takes
 7 seconds in comparison to 1.5 seconds for Matlab/Octave.

 Of course I did not see any improvement using
 z1=[z1 ones(1,length(Z))*Z[j]]

 It took practically the same time.

 However, this reduced to fraction of a second...i.e., after I generated a
 vector of zeros and just replaced the zeros appropriately.
 z1=zeros(1,length(Z)^2)
 length(Z)=dd
 for j=1:dd
  v=1:dd:(dd-1)*dd
  z1[1,v[j]:(v[j+dd-1])]=Z[j];
 end

  Of course even Octave/Matlab became equally fast with this code.

 So what gives in repmat for Julia? Why is it slow? Have I gone wrong with
 my first code?




 Question 2:
 If I start with A=[]
 How do I vcat or hcat a row or a column vector to A in a for loop form a
 MATRIX.
 say my vector is A(10x1) and I want to make B=[A[1] A[2] A[3] A[4]] which
 is a 10x4 matrix.
 In Octave I would do
 B=[]
 B=[B A[j]] in a for loop.

 Thanks



Re: [julia-users] 3D plots with Julia

2014-10-01 Thread Miguel Bazdresch
Gaston can also do 3D plots. The docs are here:
https://bitbucket.org/mbaz/gaston/downloads/gastondoc-0.5.5.pdf

Having said that, PyPlot.jl is probably the way to go, unless you really
like gnuplot.

-- mb

On Wed, Oct 1, 2014 at 2:47 PM, Viral Shah vi...@mayin.org wrote:

 Of course! PyPlot.jl is the way to go.

 -viral



  On 01-Oct-2014, at 11:07 pm, Isaiah Norton isaiah.nor...@gmail.com
 wrote:
 
  Surface plots are also available via PyPlot.jl (using matplotlib).
 
  On Wed, Oct 1, 2014 at 1:26 PM, Viral Shah vi...@mayin.org wrote:
  Not right out of the box yet, but I hear that 3d support will be coming
 in Gadfly. Someone else who knows more should comment.
 
  Until then, this may be a starting point perhaps.
  https://github.com/SimonDanisch/GLPlot.jl
 
  -viral
 
 
  On Wednesday, October 1, 2014 9:28:34 PM UTC+5:30, Tim K wrote:
  Hi All,
 
  I am wondering if there is an equivalent to something like Matlab's
 plot3 command?
 
  I am trying to switch to Julia, but this is an early stumbling block.
 
  Cheers,
 
  Tim.
 
 




Re: [julia-users] negative power throws error

2014-06-08 Thread Miguel Bazdresch
I just tried this (on 0.2.1):

julia (10//1)^(-2//1)
0.01

Is this expected?

-- mb



On Sun, Jun 8, 2014 at 6:36 PM, 'Stéphane Laurent' via julia-users 
julia-users@googlegroups.com wrote:

 julia (10//1)^(-2)

 1//100


 Would it be problematic to return a rational
 for  (a::Integer)^(b::Integer) ?



 Le dimanche 8 juin 2014 21:53:45 UTC+2, Stefan Karpinski a écrit :

 There are three obvious options for (a::Integer)^(b::Integer):

1. Always return an integer ⟹ fails for negative b.
2. Always return a float ⟹ a^2 is not the same as a*a.
3. Return float for negative b, integer otherwise ⟹ not type-stable.

 As you can see, all of these choices are problematic. The first one,
 which is what we currently do, seems to be the least problematic. One
 somewhat crazier option that has been proposed is making ^- as in a^-b
 parse as a different operator and have a^b return an integer for integer
 arguments but a^-b return a float for integer arguments. This would have
 the unfortunate effect of making a^-b different from a^(-b).


 On Sat, Jun 7, 2014 at 12:41 PM, Daniel Jones daniel...@gmail.com
 wrote:

  I'd definitely be in favor of '^' converting to float, like '/',
 having fallen for than recently
 https://github.com/JuliaLang/Color.jl/commit/c3d05dd2b94f0d38b64ef86022accdfec886a673
 .

 On Sat, Jun 7, 2014, at 12:53 AM, Ivar Nesje wrote:
 
  There has also been discussion on whether ^(a::Integer,b::Integer)
 should
  return a Float64 by default, and defer to pow() like /(a::Integer,
  b::Integer) defers to div(). The problem is that many people like the
  10^45 vs 1e45 notation for large integers vs float constants, and we
 can
  make it a clean error instead of a silent bug.






Re: [julia-users] Re: step function like behaviour

2014-06-06 Thread Miguel Bazdresch
I'm not sure I understand the question. Do you mean something like this?

inside_disc(x,y,radius) = sqrt(x^2+y^2)radius ? 1 : 0

-- mb


On Fri, Jun 6, 2014 at 8:28 PM, Zahirul ALAM zahirul.a...@gmail.com wrote:

 I guess one can do a for loop. But how do I vectorize the code?


 On Friday, 6 June 2014 20:27:46 UTC-4, Zahirul ALAM wrote:

 How would one implement a step function like behaviour in julia? In
 mathematica one can write the following to create a circle with value of 1
 within the radius and 0 outside

 UnitBox[Sqrt[X^2 + Y^2]*0.5/radius];

 X and Y are the coordinates.




Re: [julia-users] MATLAB v. Julia - why different results?

2014-05-29 Thread Miguel Bazdresch
Weird indeed -- I have the same version and I get the same output as Matlab
(125.0 and 126.0).

julia versioninfo()
Julia Version 0.2.1
Commit e44b593* (2014-02-11 06:30 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm

-- mb


On Thu, May 29, 2014 at 10:36 AM, Alexander Dubbs alex.du...@gmail.com
wrote:

 versioninfo()
 Julia Version 0.2.1
 Commit e44b593* (2014-02-11 06:30 UTC)
 Platform Info:
   System: Darwin (x86_64-apple-darwin12.5.0)
   WORD_SIZE: 64
   BLAS: libgfortblas
   LAPACK: liblapack
   LIBM: libopenlibm

 On Thursday, May 29, 2014 10:29:09 AM UTC-4, Jacob Quinn wrote:

 Weird. I get the same output as Matlab.

 In  [84]: function smooth(Xin,k,s)
 Xout = zeros(size(Xin,1),1)
 for z = -s:s
 Xout = Xout + Xin[:,k+z]*binomial(2*s,s+z)
 end
 Xout = Xout/2^(2*s)
 return Xout
 end

 Out [84]: smooth (generic function with 1 method)

 In  [85]: X = zeros(2,375);
  X[1,:] = 1:375;
 X[2,:] = 2:376
 Y = smooth(X,125,8)

 Out [85]: 2x1 Array{Float64,2}:
  125.0
  126.0


 What version of Julia are you on? (julia -e versioninfo())

 -Jacob


 On Thu, May 29, 2014 at 10:20 AM, Alexander Dubbs alex@gmail.com
 wrote:

 I can't for the life of me figure out why these two functions return
 different things, the function is called smooth, and in MATLAB:

 X = zeros(2,375);
 X(1,:) = 1:375;
 X(2,:) = 2:376;
 Y = smooth(X,125,8)

 Y =

125
126

 and in Julia

 X = zeros(2,375);
 X[1,:] = 1:375;
 X[2,:] = 2:376
 Y = smooth(X,125,8)
 2x1 Array{Float64,2}:
  127.0
  128.0

 The functions are (MATLAB then Julia)

 
 
 

 function Xout = smooth(Xin,k,s)

 Xout = zeros(size(Xin,1),1);

 for z = -s:s

 Xout = Xout + Xin(:,k+z)*nchoosek(2*s,s+z);

 end

 Xout = Xout/2^(2*s);

 
 
 

 function smooth(Xin,k,s)

 Xout = zeros(size(Xin,1),1)

 for z = -s:s

 Xout = Xout + Xin[:,k+z]*binomial(2*s,s+z)

 end

 Xout = Xout/2^(2*s)

 return Xout

 end





Re: [julia-users] Re: OT: entering Unicode characters

2014-05-22 Thread Miguel Bazdresch
In vim, you can do something like

imap \alphaTAB C-Vu03b1

to reproduce this behavior.

-- mb


On Thu, May 22, 2014 at 1:27 PM, Steven G. Johnson stevenj@gmail.comwrote:

 A quick update for people who haven't been tracking git closely:

 The Julia REPL (#6911), IJulia, and (soon) Emacs julia-mode (#6920) now
 allows you to type many mathematical Unicode characters simply by typing
 the LaTeX symbol and hitting TAB.

 e.g. you can type \alphaTAB and get α, or x\hatTAB and get x̂.

 There are currently 736 supported symbols (though not all of them are
 valid in Julia identifiers).   This should provide a consistent,
 cross-platform Julian idiom for entering Unicode math.

 Hopefully this can also be added to other popular editors at some point,
 e.g. presumably vim can be programmed to do this, and there is a somewhat
 similar mode for Sublime (https://github.com/mvoidex/UnicodeMath).
  (Less-programmable editors might need source-level patches, but it doesn't
 seem like an unreasonable patch to suggest.)



Re: [julia-users] Re: OT: entering Unicode characters

2014-05-22 Thread Miguel Bazdresch
That's true, but I think the best solution would be to have the same
keybindings in the julia REPL and in vim. I think it'd be terribly
confusing otherwise.

-- mb


On Thu, May 22, 2014 at 3:56 PM, Daniel Jones danielcjo...@gmail.comwrote:

  Also for vim users who aren't aware of this: vim has a convenient way to
 enter common special characters in the form of 
 digraphshttp://vimdoc.sourceforge.net/htmldoc/digraph.html which
 you can enter by pressing ctrl-k in insert mode. You have to learn the
 digraph for the symbol, but they are pretty mnemonic in their assignment
 (e.g 'C(' - ⊂, 'm*' - μ, 's*' - σ, 'Fm' - ♀), and honestly, you
 wouldn't be using vim if you weren't into maximizing efficiency by learning
 short cryptic commands.


 On Thu, May 22, 2014, at 12:03 PM, Miguel Bazdresch wrote:

 In vim, you can do something like

 imap \alphaTAB C-Vu03b1

 to reproduce this behavior.

  -- mb


 On Thu, May 22, 2014 at 1:27 PM, Steven G. Johnson 
 stevenj@gmail.comwrote:

 A quick update for people who haven't been tracking git closely:

 The Julia REPL (#6911), IJulia, and (soon) Emacs julia-mode (#6920) now
 allows you to type many mathematical Unicode characters simply by typing
 the LaTeX symbol and hitting TAB.

 e.g. you can type \alphaTAB and get α, or x\hatTAB and get x̂.

 There are currently 736 supported symbols (though not all of them are
 valid in Julia identifiers).   This should provide a consistent,
 cross-platform Julian idiom for entering Unicode math.

 Hopefully this can also be added to other popular editors at some point,
 e.g. presumably vim can be programmed to do this, and there is a somewhat
 similar mode for Sublime (https://github.com/mvoidex/UnicodeMath).
  (Less-programmable editors might need source-level patches, but it doesn't
 seem like an unreasonable patch to suggest.)






Re: [julia-users] Generating latex friendly plots

2014-05-12 Thread Miguel Bazdresch
Some time ago I wrote a script to use pgfplots from octave/Matlab:

https://bitbucket.org/mbaz/printpgf/src/28cead667bda6ec745a4418bc408f7f712cf8433/inst/printpgf.m

It's very easy to use and I've used it for several publications. I tried it
to make it very easy to perfectly match fonts with the rest of your
document, by including a document preamble that you specify.

I want to port this to Julia, but I haven't had the time. If somebody
thinks this is a good idea, feel free to copy it.

-- mb


On Mon, May 12, 2014 at 6:04 AM, Oliver Lylloff oliverlyll...@gmail.comwrote:

 Hello all,

 For several years (in the dark Matlab-ages before Julia), I used
 matlab2tikz https://github.com/nschloe/matlab2tikz to generate nice
 looking pdf figures for academic reports. It's a nice tool and I personally
 like the idea that my data is exported from matlab to a .tikz or .tex file
 that I can make changes to without having to open matlab and reexport my
 figures.

 Julia already has some very nice plotting features in Winston, Gadfly and
 matplotlib (IJulia), am I forgetting someone? The exporting options are
 good and useful for many different purposes. However, for me, there's
 something extraordinary about the tikz/pgf plots that I haven't been able
 to reproduce with these packages.

 Therefore I've made a quick-and-dirty module
 https://github.com/1oly/PrintFig.jl that uses PyCall to call
 matplotlib2tikz https://github.com/nschloe/matplotlib2tikz, a close
 relative to matlab2tikz, that exports figure objects to a .tex file using
 the standalone latex documentclass. I like this approach and it creates the
 figures that I like for academic work. It's not the intention to add this
 to METADATA but merely to get a discussion going - if anyone is interested
 at all...

 If anyone has comments, suggestions or want to discuss workflows for
 generating latex friendly plots, don't be shy :)

 Cheers,
 Oliver



Re: [julia-users] Re: Question on generating rand numbers with fixed state

2014-04-17 Thread Miguel Bazdresch
The distributions.jl package extends Julia's random number capabilities,
it's worth a look:

https://github.com/JuliaStats/Distributions.jl

-- mb


On Thu, Apr 17, 2014 at 1:18 PM, X Du dux...@gmail.com wrote:


 Thanks Isaiah,

  It seems that srand([*rng*], *seed*) does not work, I always got the
 error rng is not defined.
 I tried to set MersenneTwister([*2*]) and use rand(*rng::AbstractRNG*[,
 *dims...*]) to generate the random number. It did not work.

 Could you please give me an example? Many thanks in advance.

 Isaac


 On Thursday, April 17, 2014 12:45:01 PM UTC+2, X Du wrote:


  Hi All,

  Is there some comments to save or load a particular state when
 generating rand numbers?
 e.g. the code in Matlab:

 stream = RandStream.getGlobalStream;
 savedState = stream.State;
 u1 = rand(1,5)
 u1 =
 0.81470.90580.12700.91340.6324

 stream.State = savedState;
 u2 = rand(1,5)
 u2 =
 0.81470.90580.12700.91340.6324

 which can produce exactly the same random numbers.


 Thanks!

 Isaac






Re: [julia-users] Re: Radio.jl: a digital communications package

2014-04-07 Thread Miguel Bazdresch
Can't it be done with a pipe? What I mean is, use the radio API to get the
data and store in a pipe. In julia, the main process would read from the
pipe and run your algorithms on it. If necessary, it could hand the data to
another process.

I've done something similar to read data from a sound card in real time,
using sox and octave. Sox reads data from the sound card and sends it to a
pipe, which in turn is read by octave. Works great. You can use the same
idea to have bidirectional data.

-- mb


On Mon, Apr 7, 2014 at 2:01 AM, Elliot Saba staticfl...@gmail.com wrote:

 The main sticking point I've had so far is getting data from the radio in
 realtime.  What I would like to do is start up a second thread to
 constantly read data and store it into a buffer, but since Julia doesn't
 have multithreading yet I suppose I'll need to travel down the
 multiprocessing road; something I haven't really explored with Julia yet.
 -E


 On Sun, Apr 6, 2014 at 10:55 PM, Elliot Saba staticfl...@gmail.comwrote:

 Jay, I'm a signal processing student and can help you out with the
 multirate dsp if you want.  Feel free to contact me off-list if you wish,
 and I can contribute some algorithms.  I've done polyphase filtering and
 extreme downsampling and such before.

 I think it would be useful to have a standardized interface for SDR, (if
 possible, I don't know any interfaces other than librtlsdr) but as with
 many other things Julia, I think we should make a small effort in this
 direction, but focus most of our effort on making at least one
 implementation worthwhile, and then we can adapt that implementation to be
 generic enough for the rest once it's been proven well-thought out in
 actual use.
 -E


 On Sun, Apr 6, 2014 at 5:36 PM, Jay Kickliter jay.kickli...@gmail.comwrote:

 Elliot  Miguel,

 I've been toying with writing an interface to libbladrfhttp://nuand.com,
 and could definitely use an interface to UHD also. GNU Radio is a great
 framework, but most of the work I do snapshot based.

 Do you guys think there should be a common package for all these SDR
 interfaces? If I do tackle an interface for bladeRF, it won't be for a long
 time. I'm too new to Julia make an elegant interface, even if it is just
 calling the dynamic library.






Re: [julia-users] Re: Radio.jl: a digital communications package

2014-04-07 Thread Miguel Bazdresch
I agree that we should focus on getting something that works, and only then
focus on making it good and generic.

-- mb


On Mon, Apr 7, 2014 at 1:55 AM, Elliot Saba staticfl...@gmail.com wrote:

 Jay, I'm a signal processing student and can help you out with the
 multirate dsp if you want.  Feel free to contact me off-list if you wish,
 and I can contribute some algorithms.  I've done polyphase filtering and
 extreme downsampling and such before.

 I think it would be useful to have a standardized interface for SDR, (if
 possible, I don't know any interfaces other than librtlsdr) but as with
 many other things Julia, I think we should make a small effort in this
 direction, but focus most of our effort on making at least one
 implementation worthwhile, and then we can adapt that implementation to be
 generic enough for the rest once it's been proven well-thought out in
 actual use.
 -E


 On Sun, Apr 6, 2014 at 5:36 PM, Jay Kickliter jay.kickli...@gmail.comwrote:

 Elliot  Miguel,

 I've been toying with writing an interface to libbladrfhttp://nuand.com,
 and could definitely use an interface to UHD also. GNU Radio is a great
 framework, but most of the work I do snapshot based.

 Do you guys think there should be a common package for all these SDR
 interfaces? If I do tackle an interface for bladeRF, it won't be for a long
 time. I'm too new to Julia make an elegant interface, even if it is just
 calling the dynamic library.





Re: [julia-users] Radio.jl: a digital communications package

2014-04-06 Thread Miguel Bazdresch
I've been dreaming of writing a UHD package so that julia could talk to the
USRP. That'd be awesome, and probably not too hard, but I haven't found the
time.

-- mb


On Sun, Apr 6, 2014 at 5:19 PM, Elliot Saba staticfl...@gmail.com wrote:

 This is pretty great!  I've been wanting to write an rtlsdr library for a
 while, (I've gotten blocking reading mode working) and it'd be great to be
 able to hook this up to it and actually receive some signals!


 On Sun, Apr 6, 2014 at 1:46 PM, João Felipe Santos joao@gmail.comwrote:

 Hello Jay,

 first of all, great job with the package!

 We should definitely integrate Radio.jl with DSP.jl, so that it uses DSP
 as a dependency instead of having duplicates of basic functions (FIR,
 windows, etc). I will be able to assist in migrating the extra
 functionality you implemented to DSP.jl in a few weeks, but feel free to
 send pull requests to if you are interested.

 --
 João Felipe Santos


 On Sun, Apr 6, 2014 at 4:02 PM, Jay Kickliter jay.kickli...@gmail.comwrote:

 I didn't tag the subject with [ANN] since *Radio.jl
 https://github.com/JayKickliter/Radio.jl* is barely a package yet.
 But I am looking for feedback, feature requests, and hopefully some help.

 I'm mainly writing the package to support my work with space
 communications, so I will be focusing on Phase Shift Keying and rectangular
 Quadrature Amplitude Modulation. But Julia needs a general comms package.
 If you have any needs/suggestions please let me know.

 I mistakenly re-implemeted some of *DSP.jl*'s functionality, and some
 of what I've written is missing from it. Maybe Radio's filtering functions
 should be moved to DSP?






Re: [julia-users] Linear convolution

2014-03-04 Thread Miguel Bazdresch
There is DSP.jl: http://dspjl.readthedocs.org/en/latest/index.html


On Tue, Mar 4, 2014 at 10:22 AM, Tobias Knopp
tobias.kn...@googlemail.comwrote:

 I don't want to give a definate yes to it but will think a little bit how
 such a package could look like.
 My Cartesian macro foo is currently completely absent so that I would have
 to learn this first.

 Do you know of others efforts/packages that go into that direction?

 Am Dienstag, 4. März 2014 15:51:33 UTC+1 schrieb Tim Holy:

 I'm fine with that. Do you want to start it?

 --Tim




Re: [julia-users] Linear convolution

2014-03-04 Thread Miguel Bazdresch
I was worried about getting a little noise in the result, so I ran a
quick test in Matlab and Julia, and got almost exactly the same error. This
is the Matlab code:

Ts=0.01;
t=-10:Ts:10;
s=sinc(t);
sc=Ts*conv(s,s);
sc=sc(1000:3000);
sum((sc-s).*(sc-s))

ans =

0.3695

So, at least for accuracy, julia's conv implementation seems to be no worse
than Matlab's.


On Tue, Mar 4, 2014 at 7:19 AM, Toivo Henningsson toivo@gmail.comwrote:

 Yes, with sufficient padding, you can compute a linear convolution (of
 finite length vectors) exactly using a circular convolution. The FFT might
 introduce a little noise in the result, but that is all.


 On Tuesday, 4 March 2014 13:12:48 UTC+1, Oliver Lylloff wrote:

 Well ok,

 Maybe I misunderstood the whole thing then but since fft assumes periodic
 input then I don't see how it can be a linear convolution. I guess
 Base.conv2 probably uses zero-padding to reduce wrap-around but in theory
 it would still be a circular convolution. I'll read up on it :)

 Best,
 Oliver

 Den tirsdag den 4. marts 2014 13.07.20 UTC+1 skrev Andreas Noack Jensen:

 Both conv and conv2 are linear convolutions but the implementations use
 the fft. Maybe the documentation could be more clear on that.


 2014-03-04 13:01 GMT+01:00 Oliver Lylloff oliver...@gmail.com:

 Thanks Tim.

 Can't believe I missed that - been working with Images.jl all day. Nice
 job by the way, very useful.

 Best,
 Oliver

 Den tirsdag den 4. marts 2014 12.48.01 UTC+1 skrev Tim Holy:

 Images.jl's imfilter might be what you want.
 --Tim

 On Tuesday, March 04, 2014 03:38:15 AM Oliver Lylloff wrote:
  Hello all,
 
  Is anyone aware of a linear convolution implementation?
  The Base.conv and Base.conv2 functions are implemented with fft
 which makes
  them circular convolution functions (as far as I know).
 
  I'm looking for something alike Matlabs conv2 or SciPys
 signal.convolve2d.
 
  Should be straightforward to implement though.
 
  Best,
  Oliver




 --
 Med venlig hilsen

 Andreas Noack Jensen




Re: [julia-users] Re: Does winston support panning and zooming?

2014-03-04 Thread Miguel Bazdresch
With Gaston, too, if that's any help.

-- mb


On Tue, Mar 4, 2014 at 8:16 PM, Steven G. Johnson stevenj@gmail.comwrote:

 Panning and zooming work with PyPlot.

 On Tuesday, March 4, 2014 7:05:07 PM UTC-5, Dan Becker wrote:

 I just installed julia (v0.2.1) on windows, followed by winston. Plotting
 works, but I see no obvious way to zoom or pan the plot. I also haven't
 found anything about this in the documentation (
 http://winston.readthedocs.org/en/latest/) or github repo.





Re: [julia-users] animated plot

2014-02-24 Thread Miguel Bazdresch
Gaston supports output to GIF, which you could then assemble into an
animation with an independent tool.

https://github.com/mbaz/Gaston.jl

If possible, use the development version -- the latest release is getting a
bit long in the tooth.

-- mb


On Mon, Feb 24, 2014 at 11:57 AM, harven har...@free.fr wrote:

 Is there a way to produce an animated plot with julia?
 I am thinking of simple animations, like the one produced by
 CAS softwares (maple/mathematica/sage etc)
 e.g.
 http://www.maplesoft.com/support/help/helpview.aspx?si=2057/file01057/plot309.gif





Re: [julia-users] Continuous data flow similar to Simulink/LabView

2014-02-09 Thread Miguel Bazdresch
Back in 2012 I did some preliminary work along these lines. The simulator
is described in this paper:

http://www.thinkmind.org/index.php?view=articlearticleid=simul_2012_1_20_50094

and the code is at: https://bitbucket.org/mbaz/chango

This simulator is able to interface to external devices; at the moment,
only sound cards are supported, both for recording and for playing. It also
has a primitive scheduler that will send packets of data and code to any
idle processor. It is also (I think) very easy to use: creating a new block
involves just a few lines of boilerplate code.

The code is old, it may need to be brought up to date to run with the
latest julia.

-- mb


On Sat, Feb 8, 2014 at 1:04 AM, Rick Graham rickhg1...@gmail.com wrote:

 Does Julia have or plan to include the ability to process a continuous
 stream of data (think DSP operations on data from a device/port/pipe/etc.).
  Are there possibilities for a graphical GUI with connected functional
 nodes, etc.?



Re: [julia-users] problem plotting with Gadfly/Cairo

2013-12-30 Thread Miguel Bazdresch
Laksh,

It works for me with julia 0.2 on Linux. I don't understand what this
message means:

INFO: Nothing to be done.

You shouldn't see that message. Do you get the same thing when loading
other packages? Can you delete or rename your .julia directory and try
adding the package again?

-- mb


On Mon, Dec 30, 2013 at 3:31 AM, Laksh Gupta glaks...@gmail.com wrote:

 Since using SVG plot were good enough for me, I moved ahead in the project
 I am doing to get familiar with Julia. Now I need to generate contour and
 other complex plot for which I am not sure Gadfly will be of much use.
 Hence I tried working with Gaston and is facing the same problem:

 julia Pkg.add(Gaston)






 julia


 INFO: Nothing to be done.




 julia using Gaston






 julia x=-pi:.001:pi; y=x.*sin(10./x); plot(x,y) #(plot x*sin(10/x))


 plot not defined




 julia x=-pi:.001:pi; y=x.*sin(10./x); Gaston.plot(x,y) #(plot x*sin(10/x))


 plot not defined




 julia


 What am I missing here?

 On Monday, December 23, 2013 8:12:22 AM UTC-8, Stu Thompson wrote:

 Hi Laksh,

 Where you able to resolve your issue?  Or are you still having problems?
  In theory it could be something related to Julia Studio.  If so, my
 colleague Kees and I would like to help you resolve it.

 Cheers,

 Stu




 Stu Thompson   /forio  |  +1 (415) 518 32 19  |  
 forio.comhttp://www.forio.com/



 On Sat, Dec 21, 2013 at 7:09 AM, John Myles White 
 johnmyl...@gmail.comwrote:

 You haven’t installed Cairo yet it seems. Or at least Julia isn’t
 finding Cairo installed where it expects to find it.

  — John

 On Dec 21, 2013, at 2:26 AM, Laksh Gupta glak...@gmail.com wrote:

  Hi
 
  I am running 64 bit Julia Studio 0.4.3 on Windows 8. I installed
 Gadfly and Cairo but is still facing problems while trying to plot anything:
 
  julia plot plot not defined
 
 
   julia Gadfly.plot
   plot (generic function with 6 methods)
 
 
   julia Gadfly.plot(x=collect(1:100), y=sort(rand(100)))
   Plot(...)
 
 
  julia p = Gadfly.plot(x=collect(1:100), y=sort(rand(100)))
 
  Plot(...)
 
 
  julia draw(PNG(plot.png, 6.5inch, 3inch), p)
 
  Cairo must be installed to use the PNG backend.
 
 
 
 
  julia using Cairo
 
 
 
 
 
 
 
  julia draw(PNG(plot.png, 6.5inch, 3inch), p)
 
  Cairo must be installed to use the PNG backend.
 
 
  Any idea what am I missing here?
 
  Thanks,
  lg





Re: [julia-users] problem plotting with Gadfly/Cairo

2013-12-30 Thread Miguel Bazdresch
I'm stumped -- I have no idea why you don't have a plot command after
loading gaston.

Can you try typing Gaston. in the terminal and then TAB? You should see
all functions from the Gaston module.

Can you try running gaston_demo() ?

-- mb


On Mon, Dec 30, 2013 at 8:56 PM, Laksh Gupta glaks...@gmail.com wrote:


 Actually I already added the package but just for the sake of putting the
 complete example here I included
 'Pkg.add(Gaston)'

 That's why we are seeing the message : Nothing to be done.

 Yes, it is happening with other packages also, say with PyPlot. I tried
 deleting the .julia directory but no luck. I tried both with the standard
 installation of Julia as well as with Julia Studio.


 On Monday, December 30, 2013 3:12:06 PM UTC-8, Miguel Bazdresch wrote:

 Laksh,

 It works for me with julia 0.2 on Linux. I don't understand what this
 message means:

 INFO: Nothing to be done.

 You shouldn't see that message. Do you get the same thing when loading
 other packages? Can you delete or rename your .julia directory and try
 adding the package again?

 -- mb


 On Mon, Dec 30, 2013 at 3:31 AM, Laksh Gupta glak...@gmail.com wrote:

 Since using SVG plot were good enough for me, I moved ahead in the
 project I am doing to get familiar with Julia. Now I need to generate
 contour and other complex plot for which I am not sure Gadfly will be of
 much use. Hence I tried working with Gaston and is facing the same problem:

 julia Pkg.add(Gaston)






 julia


 INFO: Nothing to be done.




 julia using Gaston






 julia x=-pi:.001:pi; y=x.*sin(10./x); plot(x,y) #(plot x*sin(10/x))


 plot not defined




 julia x=-pi:.001:pi; y=x.*sin(10./x); Gaston.plot(x,y) #(plot x*sin(10/x))


 plot not defined




 julia


 What am I missing here?

 On Monday, December 23, 2013 8:12:22 AM UTC-8, Stu Thompson wrote:

 Hi Laksh,

 Where you able to resolve your issue?  Or are you still having
 problems?  In theory it could be something related to Julia Studio.  If so,
 my colleague Kees and I would like to help you resolve it.

 Cheers,

 Stu




 Stu Thompson   /forio  |  +1 (415) 518 32 19  |  
 forio.comhttp://www.forio.com/



 On Sat, Dec 21, 2013 at 7:09 AM, John Myles White johnmyl...@gmail.com
  wrote:

 You haven’t installed Cairo yet it seems. Or at least Julia isn’t
 finding Cairo installed where it expects to find it.

  — John

 On Dec 21, 2013, at 2:26 AM, Laksh Gupta glak...@gmail.com wrote:

  Hi
 
  I am running 64 bit Julia Studio 0.4.3 on Windows 8. I installed
 Gadfly and Cairo but is still facing problems while trying to plot 
 anything:
 
  julia plot plot not defined
 
 
   julia Gadfly.plot
   plot (generic function with 6 methods)
 
 
   julia Gadfly.plot(x=collect(1:100), y=sort(rand(100)))
   Plot(...)
 
 
  julia p = Gadfly.plot(x=collect(1:100), y=sort(rand(100)))
 
  Plot(...)
 
 
  julia draw(PNG(plot.png, 6.5inch, 3inch), p)
 
  Cairo must be installed to use the PNG backend.
 
 
 
 
  julia using Cairo
 
 
 
 
 
 
 
  julia draw(PNG(plot.png, 6.5inch, 3inch), p)
 
  Cairo must be installed to use the PNG backend.
 
 
  Any idea what am I missing here?
 
  Thanks,
  lg