Re: [julia-users] I noticed there is no do while loop

2014-04-08 Thread Cameron McBride
I've long enjoyed ruby's `loop` keyword for exactly this type of use.

Cameron


On Tue, Apr 8, 2014 at 4:28 PM, Stefan Karpinski ste...@karpinski.orgwrote:

 Eh, doesn't seem that hard to write `while true` and `while` by itself is
 kind of confusing. I also don't necessarily think this is how everyone
 should write loops, but I increasingly find myself starting out by writing
 `while true` and then putting conditions where they are needed as I go.
 Then after I've written the loop out, I'll figure out how to refactor it as
 a while condition.


 On Tue, Apr 8, 2014 at 3:38 PM, Mike Innes mike.j.in...@gmail.com wrote:

 If while true loops are idiomatic, could we perhaps make the true
 optional?


 On Tuesday, 8 April 2014 18:57:53 UTC+1, Stefan Karpinski wrote:

  Good idea. For what it's worth, these days I would be perfectly happy
 to only program with while true loops and explicit breaks.

 On Apr 8, 2014, at 1:41 PM, Kevin Squire kevin@gmail.com wrote:

 Although not too frequent, this would be a good FAQ entry.

 Cheers, Kevin


 On Tuesday, April 8, 2014, Pierre-Yves Gérardy pyg...@gmail.com wrote:

 This does the trick:

 while true
 # ...
 condition || break
 end



 On Tuesday, April 8, 2014 5:26:00 AM UTC+2, Freddy Chua wrote:

 as stated in question..





[julia-users] Selectively read text columns into vectors?

2014-04-10 Thread Cameron McBride
Greetings,

Does this exist somewhere in base and/or DataFrames: the ability to read
only selected columns from some text input?  Ideally, you could have each
output vector of a different type (Float64, Int, etc.).   (So it differs
from readdlm() in philosophy.)

A minimal implementation is below assuming space delimiters and Float64
types for all columns. (BTW, comments on this approach or improvements are
also very welcome.)

# selectively read specified columns from a file
# return tuple of vectors
# TODO: enable optional selection of types for each column
function readcols(file,idx...)
const re_comment = r#.*$
r = map( x - Float64[] , idx )
open(file) do f
for line in eachline(f)
l = strip( replace(line, re_comment, ) )
if length(l)  0
c = split(l)
j = 1
 for i in idx
push!(r[j], float(c[i]))
j += 1
 end
end
end
end
return r
end

Thanks!

Cameron


Re: [julia-users] All packages for numerical math

2014-04-23 Thread Cameron McBride
Or you can use the non-vectorized version and save the overhead of the
temporary arrays being created by the addition and multiplication steps.

function trapz{T:Real}(x::Vector{T}, y::Vector{T})
local len = length(y)
if (len != length(x))
error(Vectors must be of same length)
end
r = 0.0
for i in 2:len
r += (x[i] - x[i-1]) * (y[i] + y[i-1])
end
r/2.0
end

BTW, another possibility is to use a spline interpolation on the original
data and integrate the spline evaluation  with quadgk().  (Ideally,
integrations can be incorporated into a spline interface.) This could be
useful depending on the functional shape between the grid points.

Cameron


On Wed, Apr 23, 2014 at 7:52 AM, Tomas Lycken tomas.lyc...@gmail.comwrote:

 The trapezoidal rule (http://en.wikipedia.org/wiki/Trapezoidal_rule)
 would probably be almost trivial to implement.

 function trapz{T:Real}(x::Vector{T}, y::Vector{T})
if (length(y) != length(x))
error(Vectors must be of same length)
end
sum( (x[2:end] .- x[1:end-1]).*(y[2:end].+y[1:end-1]) ) / 2
 end

 x = [0:0.01:pi]
 y = sin(x)

 trapz(x,y) # 1.820650436642

 This, of course, only currently works on vectors of real numbers, but it's
 easy to extend it if you want.

 And there might be more accurate methods as well, of course (see e.g.
 http://en.wikipedia.org/wiki/Simpson%27s_rule) but this one's often good
 enough.

 // T

 On Wednesday, April 23, 2014 8:43:48 AM UTC+2, Evgeny Shevchenko wrote:

 Hi, John.
 No, I didn't. I didn't find it and it seems to be not what i need:

 no method quadgk(Array{Float64,1}, Array{Float64,1})

 quadgk(f,a,b,...) expects a function as its first argument but I mean the
 case when y = f(x), but i don't have f, e.g. obtained experimental data, so
 x and y are 1-D arrays of floats.


 On Tue, Apr 22, 2014 at 7:49 PM, John Myles White 
 johnmyl...@gmail.comwrote:

 Have you tried the quadgk function?

  -- John

 On Apr 22, 2014, at 7:32 AM, Evgeny Shevchenko eu...@ya.ru wrote:

 Hi

 Is there a package for numeric integration of obtained arrays, say x and
 y? Couldn't find one, the led me to use @pyimport and numpy.trapz.

 --
 pupoque@IRC






Re: [julia-users] All packages for numerical math

2014-04-24 Thread Cameron McBride
On Thu, Apr 24, 2014 at 4:28 AM, Hans W Borchers hwborch...@gmail.comwrote:

 function trapz2{T:Number}(x::Vector{T}, y::Vector{T})
 local n = length(x)
 if (length(y) != n)
 error(Vectors 'x', 'y' must be of same length)
 end
 if n == 1; return 0.0; end
 r = 0.0
 for i in 2:n
 r += (x[i] - x[i-1]) * (y[i] + y[i-1])

 end
 r / 2.0
 end


I'm not sure it's behavior we should rely on, but the if branch for n ==
1 isn't necessary in this for loop, although perhaps it was included to aid
the comparison. A range of 2:1 is a zero-length iteration, so the loop will
not run even once.  Try this:

julia [2:1]
0-element Array{Int64,1}

If  we are being pedantic on types, then the result of the integral should
at least be a floating point.  Granted, I am not sure of what the use case
for integer vector inputs would be, but I doubt *if* someone used them that
they'd want an integer result in return.  (This would be similar to sqrt(),
for example.)

Cameron


Re: [julia-users] Re: Julia Hack Nights?

2014-04-29 Thread Cameron McBride
On Tue, Apr 29, 2014 at 2:13 PM, Iain Dunning iaindunn...@gmail.com wrote:

 Nothing has really been happening in Cambridge more often than those. What
 exactly is a hack night?


All I had in mind was an informal meeting where there is work on something
julia for the evening (an hour or two or so).  Basically, no scheduled
talks and increased chance to collaborate.  Maybe a couple lightning talks
if it seemed appropriate to the time and venue, but certainly nothing more.

I suspect Cambridge has enough interested people to make this happen. I
guess many (most?) of the julia folks here are oriented on the core and
interact enough anyhow?  Julia is not my day job, so...

Cameron


Re: [julia-users] Re: Julia Hack Nights?

2014-04-30 Thread Cameron McBride
I'm not one to push for regular participation, as my schedule is
typically a mess.

Hypocrisy aside, perhaps it might work to designate one evening every XXX
(month?  two weeks?  weekly?) where people informally congregate and work
on something julia related?  I think it just needs a couple people to show
up each time at a specified venue.

Anyhow, more details for Cambridge should probably happen on another list
(cajun?)

Cameron

p.s. It looks like the standard is using meetup.com for group organization,
which all the groups listed on the website use (community tab on home
page). More specifically,
 http://julia.meetup.com/

On Tue, Apr 29, 2014 at 3:49 PM, Jiahao Chen jia...@mit.edu wrote:

 I've been busy, so the cajun meetups have slipped somewhat from the
 original monthly plan. I can certainly advertise on julia-cajun if
 someone wants to put together such a hack night. I believe Cameron
 mentioned to me May 9 as a possibility.
 Thanks,

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


 On Tue, Apr 29, 2014 at 3:31 PM, Cameron McBride
 cameron.mcbr...@gmail.com wrote:
  On Tue, Apr 29, 2014 at 2:13 PM, Iain Dunning iaindunn...@gmail.com
 wrote:
 
  Nothing has really been happening in Cambridge more often than those.
 What
  exactly is a hack night?
 
 
  All I had in mind was an informal meeting where there is work on
 something
  julia for the evening (an hour or two or so).  Basically, no scheduled
 talks
  and increased chance to collaborate.  Maybe a couple lightning talks if
 it
  seemed appropriate to the time and venue, but certainly nothing more.
 
  I suspect Cambridge has enough interested people to make this happen. I
  guess many (most?) of the julia folks here are oriented on the core and
  interact enough anyhow?  Julia is not my day job, so...
 
  Cameron



Re: [julia-users] Re: A Big Data stress test

2014-04-30 Thread Cameron McBride
If there is some desire for big data tests, there is a fair number of
public astronomical datasets that wouldn't be too hard to package up.

The catalog level versions aren't too different than the type of dataset
metioned by Doug. There are a number of fairly simple analyses that could
be done on them for testing, either simple predictions or classifications.
 These wouldn't be hard too document and/or describe.  I can produce
examples if people care.

For example, SDSS (a survey I work on) has public catalog data of ~470
million objects (rows), with something like ~3 million of those that have
more in depth information (many more columns).   Depending on the test
questions, these can be trimmed to provide datasets of various sizes.
 Numbers pulled from: http://www.sdss3.org/dr10/scope.php.

Anyhow, I guess the advantage here is the data is public and can be used
indefinitely.  And it's astronomy data, so naturally it's awesome.  ;)
 (However, it might suffer from the who cares in the real world issue.)

Cameron



On Wed, Apr 30, 2014 at 3:02 PM, Stefan Karpinski ste...@karpinski.orgwrote:

 Ah, ok, yes – if there aren't very many distinct values, it could
 definitely help. With strings it's always nice to convert from
 variable-length strings to fixed-size indices.


 On Wed, Apr 30, 2014 at 2:54 PM, Douglas Bates dmba...@gmail.com wrote:

 On Wednesday, April 30, 2014 1:20:26 PM UTC-5, Stefan Karpinski wrote:

 Is 22GB too much? It seems like just uncompressing this and storing it
 naturally would be fine on a large machine. How big are the categorical
 integers? Would storing an index to an integer really help? It seems like
 it would only help if the integers are larger than the indices.


 For example I just checked the first million instances of one of the
 variables and there are only 1050 distinct values, even though those values
 are 10 digit integers, as often happens with identifiers like this.  So
 let's assume that we can store the indices as Uint16.  We obtain the
 equivalent information by storing a relatively small vector of Int's,
 representing the actual values and a memory-mapped file at two bytes per
 record, for this variable.

 To me it seems that working from the original textual representation as a
 .csv.gz file is going to involve a lot of storage, i/o and conversion of
 strings to integers.




 On Wed, Apr 30, 2014 at 2:10 PM, Douglas Bates dmb...@gmail.com wrote:

 On Wednesday, April 30, 2014 11:30:41 AM UTC-5, Douglas Bates wrote:

 It is sometimes difficult to obtain realistic Big data sets.  A
 Revolution Analytics blog post yesterday

 http://blog.revolutionanalytics.com/2014/04/predict-which-shoppers-
 will-become-repeat-buyers.html

 mentioned the competition

 http://www.kaggle.com/c/acquire-valued-shoppers-challenge

 with a very large data set, which may be useful in looking at
 performance bottlenecks.

 You do need to sign up to be able to download the data and you must
 agree only to use the data for the purposes of the competition and to
 remove the data once the competition is over.


 I did download the largest of the data files which consists of about
 350 million records on 11 variables in CSV format.  The compressed file is
 around 2.6 GB, uncompressed it would be over 22GB.  Fortunately, the GZip
 package allows for working with the compressed file for sequential access.

 Most of the variables are what I would call categorical (stored as
 integer values) and could be represented as a pooled data vector.  One
 variable is a date and one is a price which could be stored as an integer
 value (number of cents) or as a Float32.

 So the first task would be parsing all those integers and creating a
 binary representation.  This could be done using a Relational DataBase but
 I think that might be overkill for a static table like this.  I have been
 thinking of storing each column as a memory-mapped array in a format like
 pooled data.  That is, store only the indices into a table of values so
 that the indices can be represented as whatever size of unsigned int is
 large enough for the table size.

 To work out the storage format I should first determine the number of
 distinct values for each categorical variable.  I was planning on using
 split(readline(gzfilehandle,,)) applying int() to the appropriate
 fields and storing the values in a Set or perhaps an IntSet.  Does this
 seem like a reasonable way to start?






Re: [julia-users] style question about Float initialization

2014-05-01 Thread Cameron McBride
Would linked lists be a more natural storage for these events?

On Thursday, May 1, 2014, Ethan Anderes ethanande...@gmail.com wrote:

 Oop the second line of the code block should read

 chain = Array{Float64,1}[theta_init]



Re: [julia-users] style question about Float initialization

2014-05-01 Thread Cameron McBride
Is there an idiomatic Julian way to deal with these cases without a large
pre-allocation or push? I understand why your suggestion here would be
faster than the original. This application aside, I see a lot of push!()
usage in some of the libs (eg saving state in Optim.jl, readdlm in base,
etc).

Linked lists (they only live in DataStructures.jl?) have all the obvious
problems that Stefan points out (scattered in memory), but prevent big
re-allocations if you can take the performance hit on any calculations.

Happy to be schooled here.

Cameron

On Thursday, May 1, 2014, John Myles White johnmyleswh...@gmail.com wrote:

 For this kind of problem, you could allocate a big matrix in advance and
 fill it in column-by-column, rather than push onto an array. Something
 roughly like the following would work:

 theta = Array(Float64, 3, 10_000)
 theta[:, 1] = [2.0, 3.0, 4.0]
 for k= 2:10_000
   theta_cur = theta[:, k - 1]
   theta_prop = theta_cur + rand(3)
   likelihoodratio = computelr(theta_prop, theta_curr)
   if rand()  min(1,likelihoodratio)
   theta[:, k] = theta_prop
   else
   theta[:, k] = theta_curr
   end
 end

 You could make something much faster still with devectorization. The code
 for simulated annealing in Optim.jl might be helpful in this regard,
 although it doesn't retain the full history of the chain.

  -- John

 On May 1, 2014, at 9:46 AM, Ethan Anderes 
 ethanande...@gmail.comjavascript:;
 wrote:

  Ok, here is quickest example that I came up with.
 
 
  theta_init = [2.0, 3.0, 4.0]
  chain = Array{Float64,1}[init]
  for k=1:10_000
theta_prop = chain[end]
theta_prop += rand(3)
likelihoodratio = computelr(theta_prop, theta_curr)
if rand()  minimum([1,likelihoodratio])
push!(chain, theta_prop)
else
push!(chain, theta_curr)
end
  end
 
  I'm generating a markov chain of vectors. The code proposes a new state
 vector, theta_prop, and pushes it to chain if it satisfies a criterion. The
 problem is that I may run it for 10_000 steps, look at the results and then
 decide to run it for longer... so preinitializing isn't as natural.
 
  BTW: thanks a ton...I can't believe I'm having Stefan look at my code!
 
 




[julia-users] Julian way to write longer if/elseif/else clauses?

2014-05-02 Thread Cameron McBride
I'm still trying to settle into proper syntax and style, and all comments
are welcome!

For potentially longer if / elseif / else clauses, e.g.

# an overly simplistic example
if ndims(wt) == 2
   println(Matrix stuff)
elseif ndims(wt) == 1
   println(Vector stuff)
else
   println(Scalar stuff)
end

Multiple dispatch doesn't seem to help the specific case I have in mind, as
this is only a small part of the logic.

This is perhaps as easy application of a case / switch statement, which I
don't think Julia has (I have ruby's case / when / else in mind).

Even more general, is there any mechanism to do pattern matching (e.g.
'match' in OCaml)?

Cameron


Re: [julia-users] Julian way to write longer if/elseif/else clauses?

2014-05-02 Thread Cameron McBride
Excellent. Thanks to both of you!

Cameron


On Fri, May 2, 2014 at 11:11 AM, Kevin Squire kevin.squ...@gmail.comwrote:



 On Friday, May 2, 2014, Cameron McBride cameron.mcbr...@gmail.com wrote:

 I'm still trying to settle into proper syntax and style, and all comments
 are welcome!

 For potentially longer if / elseif / else clauses, e.g.

 # an overly simplistic example
 if ndims(wt) == 2
println(Matrix stuff)
 elseif ndims(wt) == 1
println(Vector stuff)
 else
println(Scalar stuff)
 end

 Multiple dispatch doesn't seem to help the specific case I have in mind,
 as this is only a small part of the logic.

 This is perhaps as easy application of a case / switch statement, which I
 don't think Julia has (I have ruby's case / when / else in mind).

 Even more general, is there any mechanism to do pattern matching (e.g.
 'match' in OCaml)?


 Match.jl does pattern matching.

  Cheers,
   Kevin



Re: [julia-users] Re: Julian way to write longer if/elseif/else clauses?

2014-05-07 Thread Cameron McBride
great! I'll check it out.

Cameron


On Wed, May 7, 2014 at 8:01 AM, Mike Innes mike.j.in...@gmail.com wrote:

 If you need deeper pattern matching Match.jl is a great option, but you
 may also be interested in the @switch macro that lives in Lazy.jl – it
 will have zero overhead for cases like your example.

 https://github.com/one-more-minute/Lazy.jl#macros


 On Friday, 2 May 2014 15:11:08 UTC+1, Cameron McBride wrote:

 I'm still trying to settle into proper syntax and style, and all comments
 are welcome!

 For potentially longer if / elseif / else clauses, e.g.

 # an overly simplistic example
 if ndims(wt) == 2
println(Matrix stuff)
 elseif ndims(wt) == 1
println(Vector stuff)
 else
println(Scalar stuff)
 end

 Multiple dispatch doesn't seem to help the specific case I have in mind,
 as this is only a small part of the logic.

 This is perhaps as easy application of a case / switch statement, which I
 don't think Julia has (I have ruby's case / when / else in mind).

 Even more general, is there any mechanism to do pattern matching (e.g.
 'match' in OCaml)?

 Cameron




Re: [julia-users] for loops

2014-05-15 Thread Cameron McBride
I missed enumerate() for a while,  and was happy I found it.  I find it
amusing how satisfying a few missing keystrokes can be.

On a related but different note, from a similar influence, I keep wanting
to pass blocks to iterators.  Any chance that will ever happen?

I realize that do..end blocks are used currently as syntactic sugar for
methods that take a function as the first arg (e.g. open(), map()), and the
same functionality can be achieved with three letters and two braces (map),
but it still seems somewhat cleaner to write:

enumerate(a) do i,x
...
end

over

map(enumerate(a)) do i,x
...
end

which are really just equivalent, as we know, to

for i,x, in enumerate(a)
...
end

Are there technical reasons this is a bad idea to assume?

Cameron

On Thu, May 15, 2014 at 1:01 PM, John Myles White
johnmyleswh...@gmail.comwrote:

 I kind of suspect Stefan, like me, would instinctively call this operation
 `each_with_index`.

  -- John

 On May 15, 2014, at 6:33 AM, Kevin Squire kevin.squ...@gmail.com wrote:

 One nice thing about Julia is that she borrows many (though not all) good
 ideas from other languages. In this case, enumerate came from Python
 (although it likely has other incarnations).

 Cheers!
Kevin

 On Thursday, May 15, 2014, Billou Bielour jonathan.bie...@epfl.ch wrote:

 I was thinking the same thing the other day, when using *for x in xs* I
 often find myself needing an index at some point and then I have to change
 the for loop, or write an index manually.

 Enumerate is exactly what I need in this case.

 +1 for Julia





Re: [julia-users] for loops

2014-05-15 Thread Cameron McBride
Sure, Mike.  But the idea is to have this for all iterator objects
intrinsically rather than defining it for each function that returns an
iterator.

There is likely a way to do this automagically for all iterators, but my
julia-fu isn't strong enough that it jumped out at me when I looked over
some source in base/.  I expect it's simple, but I don't have time to
figure it out today.

Cameron



On Thu, May 15, 2014 at 4:51 PM, Mike Innes mike.j.in...@gmail.com wrote:

 Well, if you want the first syntax you can easily define

 Base.enumerate(f::Function, args...) = map(t-f(t...), enumerate(args...))

 You could always open a pull request if you wanted to see this in Base,
 too.


 On Thursday, 15 May 2014 21:18:31 UTC+1, Cameron McBride wrote:

 I missed enumerate() for a while,  and was happy I found it.  I find it
 amusing how satisfying a few missing keystrokes can be.

 On a related but different note, from a similar influence, I keep wanting
 to pass blocks to iterators.  Any chance that will ever happen?

 I realize that do..end blocks are used currently as syntactic sugar for
 methods that take a function as the first arg (e.g. open(), map()), and the
 same functionality can be achieved with three letters and two braces (map),
 but it still seems somewhat cleaner to write:

 enumerate(a) do i,x
 ...
 end

 over

 map(enumerate(a)) do i,x
 ...
 end

 which are really just equivalent, as we know, to

 for i,x, in enumerate(a)
 ...
 end

 Are there technical reasons this is a bad idea to assume?

 Cameron

 On Thu, May 15, 2014 at 1:01 PM, John Myles White 
 johnmyl...@gmail.comwrote:

 I kind of suspect Stefan, like me, would instinctively call this
 operation `each_with_index`.

  -- John

 On May 15, 2014, at 6:33 AM, Kevin Squire kevin@gmail.com wrote:

 One nice thing about Julia is that she borrows many (though not all) good
 ideas from other languages. In this case, enumerate came from Python
 (although it likely has other incarnations).

 Cheers!
Kevin


 On Thursday, May 15, 2014, Billou Bielour jonatha...@epfl.ch wrote:

 I was thinking the same thing the other day, when using *for x in xs* I
 often find myself needing an index at some point and then I have to change
 the for loop, or write an index manually.

 Enumerate is exactly what I need in this case.

 +1 for Julia






Re: [julia-users] suggestion of OSX julia/ijulia setup

2014-05-16 Thread Cameron McBride
I am not sure if this appeals to you, but I'm happy to share my
configuration.  I just use the REPL and a decent editor (vim), which I'm
happy with.

I've been using this setup for the past couple months (mid-March). I've
only had occasionally issues, but I follow HEAD so that is expected.  I am
now on 10.9, but this has been short enough that only a few deps have been
updated via system homebrew.  Things could break there, but never have.

The situation I finally created was:
 - homebrew and then pip to install python / scipy / ipython (see iJulia
docs)
 - git repo of Julia github/master
 - Pkg.add(...), Pkg.update(), etc.

Ideally, I'm not sure I really need the julia homebrew which this uses by
default.  But it works, so I haven't worried about resolving this.

1. I pull and re-compile master every few days.  I usually scan the dev /
users list before that to look for any ongoing gotchas, or new github
issues.
2. When I compile Julia, and I do a few tests (basic crunching, Winston
plots via Cairo, iJulia) then I use a local tag in my git repo to signify
the working version.  It is just easier for me to roll things back, but
certainly not strictly necessary.
3. I usually only  Pkg.update() after I've confirmed a new Julia compiles
and seems to work from the above tests.

Most of the issues I've had were between 2  3 not being in sync.  Some
small changes where packages didn't catch up.  I've been impressed with how
quickly many of the authors have fixed things, so it's rarely been an
issue.  The one issue of Julia rollback I had to do was pretty easy (an
issue that broke Grid.jl, I rolled back master for a couple days and
watched the discussion / issue until it was resolved).

I think this works as a lot of developers try and run real stuff with
master, and most of the current packages are tracking master as the
language develops.  YMMV, but I've been satisfied with the stability of
this.

Cameron

p.s. I tried using anaconda to pin the python previously, which worked, but
had some issues. I was happier when I did homebrew only python.


Re: [julia-users] for loops

2014-05-17 Thread Cameron McBride
Stefan,

Thank you. Your description really helps clarify things. The issue about
different functionality for return in map vs for loops was obviously
something I overlooked here.

And yes, the influence is clearly ruby.

I see how a macro could can duplicate the for loop structure. I guess I'm a
bit surprised that is the only way, and there wasn't a metaprogramming way
to add this functionality to all iterators.

I guess what I was wanting was the ability to use something like each
(which functions like a for loop, but looks like map()), and any such
function (enumerate, etc.), which I guess is just more method definitions.

But I probably just have too much baggage from history, so I'll just try
and use natural julia expressions for the time being...  ;)

Cameron





On Fri, May 16, 2014 at 12:58 PM, Stefan Karpinski ste...@karpinski.orgwrote:

 That form of iteration is common from Ruby, which is where I'm guessing
 this interest is coming from? Ruby has the block/proc/lambda distinction
 that makes the for loop and .each forms behaviorally similar, whereas in
 Julia, there's just the one kind of anonymous function. As a result, if
 this were made to work, enumerate(a) do i,x and for (i,x) in enumerate(a)
 would not behave exactly the same – return in the former would exit the
 current loop iteration whereas return in the latter exits the enclosing
 function. I'm not sure it's a good idea to introduce too many different
 ways to write this. If we were going to implement this, we wouldn't do it
 by adding language features, but by adding methods to iterator-producing
 functions like enumerate. In this case, you could do something like this:

 function enumerate(f::Callable, x)
   for (i,x) in enumerate(x)
 f(i,x)
   end
 end


 That pattern could be emitted by a macro, of course.



Re: [julia-users] suggestion of OSX julia/ijulia setup

2014-05-18 Thread Cameron McBride
Hi Jon,

No -- I pull julia via git on github, and compile by hand every few days.
 I've symlinked ~/bin/julia to the directory that I compile julia into, so
julia is in my path.

On 10.9, the native option is Clang, which works fine..  I've been able
to dodge gcc (gnu) for all system dependencies so far.  Homebrew seems to
handle a lot of lib conflicts pretty well, unless you tap some obvious ones
or do some forcing.

Cameron


On Sun, May 18, 2014 at 12:46 PM, Jon Norberg jon.norb...@ecology.su.sewrote:

 Also, I sometimes seem to get issues with what libraries are being used. I
 am not very good at this but I understand there are different compiler
 libraries and native osx ones. How do you guys handle this? or is it not an
 issue using brew?


 On Sunday, May 18, 2014 6:39:38 PM UTC+2, Jon Norberg wrote:

 Many thanks Cameron, I'll try that setup. Did I understand that you use
 brew to compile julia?

 On Friday, May 16, 2014 4:21:19 PM UTC+2, Ethan Anderes wrote:

 +1 for Cameron. I use the same workflow.




Re: [julia-users] Benchmarking study: C++ Fortran Numba Julia Java Matlab the rest

2014-06-17 Thread Cameron McBride
Do any of the more initiated have an idea why Numba performs better for
this application, as both it and Julia use LLVM?  I'm just asking out of
pure curiosity.

Cameron


On Tue, Jun 17, 2014 at 10:11 AM, Tony Kelman t...@kelman.net wrote:

 Your matrices are kinda small so it might not make much difference, but it
 would be interesting to see whether using the Tridiagonal type could speed
 things up at all.


 On Tuesday, June 17, 2014 6:25:24 AM UTC-7, Jesus Villaverde wrote:

 Thanks! I'll learn those tools. In any case, paper updated online, github
 page with new commit. This is really great. Nice example of aggregation of
 information. Economists love that :)

 On Tuesday, June 17, 2014 9:11:08 AM UTC-4, Stefan Karpinski wrote:

 Not your fault at all. We need to make this kind of thing easier to
 discover. Eg with

 https://github.com/astrieanna/TypeCheck.jl

 On Jun 17, 2014, at 8:35 AM, Jesus Villaverde vonbism...@gmail.com
 wrote:

 Ah Sorry, over 20 years of coding in Matlab :(

 Yes, you are right, once I change that line, the type definition is
 irrelevant. We should change the paper and the code ASAP

 On Tuesday, June 17, 2014 12:03:29 AM UTC-4, Peter Simon wrote:

 By a process of elimination, I determined that the only variable whose
 declaration affected the run time was vGridCapital.  The variable is
 declared to be of type Array{Float64,1}, but is initialized as


 vGridCapital = 0.5*capitalSteadyState:0.1:1.5*capitalSteadyState

 which, unlike in Matlab, produces a Range object, rather than an array.
  If the line above is modified to

 vGridCapital = [0.5*capitalSteadyState:0.1:1.5*capitalSteadyState]

 then the type instability is eliminated, and all type declarations can
 be removed with no effect on execution time.

 --Peter


 On Monday, June 16, 2014 2:59:31 PM UTC-7, Jesus Villaverde wrote:

 Also, defining

 mylog(x::Float64) = ccall((:log, libm), Float64, (Float64,), x)

 made quite a bit of difference for me, from 1.92 to around 1.55. If I 
 also add @inbounds, I go down to 1.45, making Julia only twice as sslow 
 as C++. Numba still beats Julia, which kind of bothers me a bit


 Thanks for the suggestions.


 On Monday, June 16, 2014 4:56:34 PM UTC-4, Jesus Villaverde wrote:

 Hi

 1) Yes, we pre-compiled the function.

 2) As I mentioned before, we tried the code with and without type
 declaration, it makes a difference.

 3) The variable names turns out to be quite useful because this code
 will be eventually nested into a much larger project where it is 
 convenient
 to have very explicit names.

 Thanks

 On Monday, June 16, 2014 12:13:44 PM UTC-4, Dahua Lin wrote:

 First, I agree with John that you don't have to declare the types in
 general, like in a compiled language. It seems that Julia would be able 
 to
 infer the types of most variables in your codes.

 There are several ways that your code's efficiency may be improved:

 (1) You can use @inbounds to waive bound checking in several places,
 such as line 94 and 95 (in RBC_Julia.jl)
 (2) Line 114 and 116 involves reallocating new arrays, which is
 probably unnecessary. Also note that Base.maxabs can compute the 
 maximum of
 absolute value more efficiently than maximum(abs( ... ))

 In terms of measurement, did you pre-compile the function before
 measuring the runtime?

 A side note about code style. It seems that it uses a lot of
 Java-ish descriptive names with camel case. Julia practice tends to
 encourage more concise naming.

 Dahua



 On Monday, June 16, 2014 10:55:50 AM UTC-5, John Myles White wrote:

 Maybe it would be good to verify the claim made at
 https://github.com/jesusfv/Comparison-Programming-
 Languages-Economics/blob/master/RBC_Julia.jl#L9

 I would think that specifying all those types wouldn’t matter much
 if the code doesn’t have type-stability problems.

  — John

 On Jun 16, 2014, at 8:52 AM, Florian Oswald florian...@gmail.com
 wrote:

  Dear all,
 
  I thought you might find this paper interesting:
 http://economics.sas.upenn.edu/~jesusfv/comparison_languages.pdf
 
  It takes a standard model from macro economics and computes it's
 solution with an identical algorithm in several languages. Julia is 
 roughly
 2.6 times slower than the best C++ executable. I was bit puzzled by the
 result, since in the benchmarks on http://julialang.org/, the
 slowest test is 1.66 times C. I realize that those benchmarks can't 
 cover
 all possible situations. That said, I couldn't really find anything 
 unusual
 in the Julia code, did some profiling and removed type inference, but 
 still
 that's as fast as I got it. That's not to say that I'm disappointed, I
 still think this is great. Did I miss something obvious here or is 
 there
 something specific to this algorithm?
 
  The codes are on github at
 
  https://github.com/jesusfv/Comparison-Programming-
 Languages-Economics
 
 




Re: [julia-users] how use find ?

2014-07-12 Thread Cameron McBride
julia find( a . 5 )

cheers,

Cameron


On Sat, Jul 12, 2014 at 11:40 AM, paul analyst paul.anal...@mail.com
wrote:

 I need all indexes where a[:] 5

 julia a=rand(10)*10
 10-element Array{Float64,1}:
  4.84005
  8.29994
  8.8531
  3.42319
  2.60318
  7.25313
  0.816263
  4.44463
  6.71836
  4.65337

 julia a.5
 10-element BitArray{1}:
  false
   true
   true
  false
  false
   true
  false
  false
   true
  false

 julia find(a.5,a)
 ERROR: no method find(BitArray{1}, Array{Float64,1})

 julia find([a.5],a)
 ERROR: no method find(BitArray{1}, Array{Float64,1})

 julia




Re: [julia-users] Re: build-in function to find inverse of a matrix

2014-07-21 Thread Cameron McBride
in the REPL, would it be reasonable to have ?? be able to do an
apropos() search?

Cameron


On Fri, Jul 18, 2014 at 4:40 PM, Viral Shah vi...@mayin.org wrote:

 I think that most new users are unlikely to know about apropos. Perhaps we
 should put it in the julia banner.

 We can say something like:
 Type help() for function usage or apropos() to search the
 documentation.

 apropos() could then just print a message about how to use it, just like
 help() does.

 -viral


 On Wednesday, July 16, 2014 7:35:44 PM UTC+5:30, Hans W Borchers wrote:

 But  apropos  does find it:

 julia apropos(matrix inverse)
 INFO: Loading help data...
 Base.inv(M)


 On Wednesday, July 16, 2014 2:59:05 PM UTC+2, Tomas Lycken wrote:

 `inv` will do that for you. http://docs.julialang.
 org/en/latest/stdlib/linalg/#Base.inv

 It's a little unfortunate that the help text is Matrix inverse, yet
 searching for that exact phrase yields no results at all. Is it possible to
 make documentation search be full-text for help text as well?

 // T

 On Wednesday, July 16, 2014 2:39:53 PM UTC+2, Alan Chan wrote:

 sorry if it's a stupid question. But I cannot find one in the online
 doc.

 Thanks




Re: [julia-users] build-in function to find inverse of a matrix

2014-07-22 Thread Cameron McBride
+1 for sticky shell mode.

I do like the ? - help and ?? - apropos mapping, as it's clear on the
mode what the simple mapping is.  But it's a minor point.

Cameron


On Tue, Jul 22, 2014 at 12:06 AM, Viral Shah vi...@mayin.org wrote:

 That’s not a crazy idea. ? could do help if there is an exact match, and
 if there is no match, it can just do apropos.

 -viral



 On 22-Jul-2014, at 7:20 am, Stefan Karpinski ste...@karpinski.org wrote:

  Would it be crazy to make ? just do apropos? Interestingly, I was just
 thinking of making ;; trigger sticky shell mode where you have to actively
 escape to get back to julia mode.
 
 
  On Mon, Jul 21, 2014 at 6:48 PM, John Myles White 
 johnmyleswh...@gmail.com wrote:
  There's one complication here, which is that a single ? already changes
 the mode of the REPL into help mode. So this would have to be a mode only
 triggerable from inside of help mode.
 
   -- John
 
  On Jul 21, 2014, at 6:47 PM, Ethan Anderes ethanande...@gmail.com
 wrote:
 
   +1. For some reason my fingers always get tied up when typing apropos
 
 




Re: [julia-users] Re: Have Julia send an email (or sound) when code is done

2014-09-18 Thread Cameron McBride
On Thu, Sep 18, 2014 at 1:44 PM, Jake Bolewski jakebolew...@gmail.com
wrote:

 Yo.jl


I thought this was a joke, but naturally, it does exist:
https://github.com/dichika/Yo.jl

Also, not really a julia question -- the stata trick should work just as
well on julia (or anything that goes before the double ampersand).
 However, that trick assumes the code exits successfully.

To continue OT, there is also: echo -e '\a' (or echo ^G supposedly in
Windows).
see,
http://en.wikipedia.org/wiki/Bell_character

Cameron
In any case, also echo \


[julia-users] julia style to resize array with initialization?

2015-10-26 Thread Cameron McBride
Hi All,

What's the best julian way to do the following:

function vecadd!(vec, i, v)
n = length(vec)
if n < i
resize!(vec, i)
vec[n+1:i] = 0.0
end
vec[i] += v
end

This seems somewhat typical for a growing array that's not just incremental
(i.e. not just a push!() operation), so I feel like I missed something.
Better suggestions?

Thanks!

Cameron


Re: [julia-users] Re: julia style to resize array with initialization?

2015-10-27 Thread Cameron McBride
Yeah, looks like very similar arguments to 9147. Although not as easy to
circumvent as using zeros() or the like.

One potential "fix" could be a potential third argument to resize with the
"default / fill" value, which doesn't seem like a viable solution to the
constructors discussed in that thread.

Cameron

p.s. Thanks, Josh, but I think that solution would create a temporary array
(from zeros() call) on every resize. Perhaps successive push!(vec, 0.0)
might also be a good way (I know push allocates in chunks, resize might not
-- I haven't looked).


On Tue, Oct 27, 2015 at 10:36 AM, Stefan Karpinski <ste...@karpinski.org>
wrote:

> I've encountered this too – it might make sense to zero out the grown
> memory. Of course there's the whole "to zero out uninitialized memory or
> not" discussion: https://github.com/JuliaLang/julia/issues/9147. I feel
> like this falls into that same category of questions.
>
> On Mon, Oct 26, 2015 at 3:59 PM, Josh Langsfeld <jdla...@gmail.com> wrote:
>
>> You could do 'append!(vec, zeros(i-n))'.
>>
>>
>> On Monday, October 26, 2015 at 3:32:56 PM UTC-4, Cameron McBride wrote:
>>>
>>> Hi All,
>>>
>>> What's the best julian way to do the following:
>>>
>>> function vecadd!(vec, i, v)
>>> n = length(vec)
>>> if n < i
>>> resize!(vec, i)
>>> vec[n+1:i] = 0.0
>>> end
>>> vec[i] += v
>>> end
>>>
>>> This seems somewhat typical for a growing array that's not just
>>> incremental (i.e. not just a push!() operation), so I feel like I missed
>>> something. Better suggestions?
>>>
>>> Thanks!
>>>
>>> Cameron
>>>
>>
>


Re: [julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Cameron McBride
Also, in the REPL you can use the help files. For example, try typing "?∈"
(which shows this is basically the in() function, hence the \inTAB
suggestion by Kristoffer).

Cameron

On Mon, Jan 4, 2016 at 12:59 PM, Kristoffer Carlsson 
wrote:

> You can enter \in and then press TAB in the REPL.
>
> Here is a list:
> http://docs.julialang.org/en/release-0.4/manual/unicode-input/
>
> Many editors have packages that support entering these type of unicode
> characters.
>


Re: [julia-users] Re: JuliaCon birds of a feather

2016-06-22 Thread Cameron McBride
Sounds like a good plan -- seems an interesting topic given a number of
relevant talks today.

Cameron

On Wed, Jun 22, 2016 at 1:19 PM, Tom Breloff  wrote:

> For those at JuliaCon today, I'm organizing a dinner to discuss "The
> future of Machine Learning and Data Science in Julia".  Tonight (Wednesday)
> 7pm, location TBD.  If you're interested in joining, please let me know.
>
> -Tom
>
> On Mon, Jun 20, 2016 at 11:15 AM, Cedric St-Jean 
> wrote:
>
>> +1, definitely interested in some of those subjects
>>
>> On Sunday, June 19, 2016 at 11:29:06 PM UTC-4, Tom Breloff wrote:
>>>
>>> Time to dredge this topic up again!  With JuliaCon only a couple days
>>> away, I want to make sure we take advantage of getting people in the same
>>> room to collaborate.  I'm interested in the following topics, and I'm ready
>>> to organize lunches, dinners, and/or drinks to discuss:
>>>
>>> - graphics in Julia
>>> - data science: LearnBase and generalized learnable transformations
>>> - AGI: deep reinforcement learning, dynamic neural net structures, or an
>>> infinity of other interesting topics
>>> - Julia in finance: robust trading systems, handling real-time
>>> workloads, etc
>>>
>>> This is a small amount of what interests me, but if you see anything,
>>> please reach out.  I hope that the hackathon on Saturday will be productive
>>> collaboration on ideas that are discussed!
>>>
>>> Best,
>>> Tom
>>>
>>> On Wed, May 18, 2016 at 9:38 AM, Andreas Noack 
>>> wrote:
>>>
 The Hackathon on Saturday is quite flexible so if somebody volunteers
 to organize such session then I'm sure we can make it happen. There should
 be people around that are knowledgeable about the topics.


 On Tuesday, May 17, 2016 at 10:26:00 AM UTC-4, Josef Sachs wrote:
>
> Will there be any organized or unorganized opportunities for
> birds of a feather sessions at JuliaCon?  I would be particularly
> interested in
>
> (1) Julia on Amazon Web Services, and
>
> (2) editors and IDEs for Julia (There was talk at one point about
> arranging a NYC Julia User Group meeting where we would be talking
> about how to get various text editors set up to work with Julia,
> but doing it at JuliaCon would probably be even better.  It would
> also be great to see a demo of JuliaDT, the Eclipse plugin, if that
> could be arranged.)
>

>>>
>


Re: [julia-users] using in try catch block

2016-06-27 Thread Cameron McBride
On Mon, Jun 27, 2016 at 1:02 PM, Yichao Yu  wrote:
>
> On Jun 27, 2016 12:58 PM, "Tom Breloff"  wrote:
> >
> > Yichao: is there an alternative "is_installed" definition that would
check the load path?  Lets assume I don't actually want to import it, just
check.
>
> No.

Seems like potentially useful function for Pkg module?

Pkg.is_installed(pkgstr)

Or perhaps more useful: is_missing(...)

Although just having several Pkg.add(...) statements for a "setup" step
also seems reasonable.

Cameron


[julia-users] Julia command line usage: tool versus library

2016-03-30 Thread Cameron McBride
Simple question (I think): Is there an easy or idiomatic way to
differentiate if a julia file is being run directly from when it's included?

I'm looking for the equivalent of this in ruby:

if $0 == __FILE__
  puts "Running file"
else
  puts "Included file"
end

Thanks.

Cameron


Re: [julia-users] Re: Julia command line usage: tool versus library

2016-04-01 Thread Cameron McBride
Ahh, nice.

Thanks!

Cameron

On Fri, Apr 1, 2016 at 9:11 AM, Curtis Vogt <curtis.v...@invenia.ca> wrote:

> There does exist a way to do this in Julia 0.5 using the PROGRAM_FILE
> <http://docs.julialang.org/en/latest/stdlib/constants/#Base.PROGRAM_FILE>
>  constant:
>
> Given the file: "example.jl"
>
> if abspath(PROGRAM_FILE) == @__FILE__
>
> println("Running file")
>
> else
>
> println("Included file")
>
> end
>
> *$* ./julia-0.5 example.jl
>
> Running file
>
> *$* ./julia-0.5 -e 'include("example.jl")'
>
> Included file
>
>
> On Friday, April 1, 2016 at 7:40:36 AM UTC-5, James Fairbanks wrote:
>>
>> What kind of production system is it? Why is it inconvenient to have two
>> files, one that defines the library and one that parses the command line
>> and calls the "main" function?
>>
>> On Friday, April 1, 2016 at 8:21:03 AM UTC-4, Cameron McBride wrote:
>>>
>>> Thanks, I missed that thread.
>>>
>>> Although neither suggested solution works as I was hoping for.
>>>
>>> I am trying to shoehorn julia into various parts of our pipeline and
>>> production systems. Having a single library that can function as an
>>> executable via shell is helpful. It's not a big deal, I just achieve this
>>> by
>>> % julia -L file.jl -e run_something()
>>>
>>> I do agree it's an awkward (and hopefully temporary) solution. Just
>>> wanted to see if I was missing something.
>>>
>>> Cameron
>>>
>>>
>>>
>>> On Thu, Mar 31, 2016 at 3:39 PM, James Fairbanks <jpfai...@gmail.com>
>>> wrote:
>>>
>>>> This had been discussed in this thread
>>>> https://groups.google.com/d/msg/julia-users/ufpi8tV7sk8/-Uv0rtAWTWsJ
>>>>
>>>>
>>>> On Wednesday, March 30, 2016 at 2:37:44 PM UTC-4, Cameron McBride wrote:
>>>>>
>>>>> Simple question (I think): Is there an easy or idiomatic way to
>>>>> differentiate if a julia file is being run directly from when it's 
>>>>> included?
>>>>>
>>>>> I'm looking for the equivalent of this in ruby:
>>>>>
>>>>> if $0 == __FILE__
>>>>>   puts "Running file"
>>>>> else
>>>>>   puts "Included file"
>>>>> end
>>>>>
>>>>> Thanks.
>>>>>
>>>>> Cameron
>>>>>
>>>>
>>>


Re: [julia-users] Re: Julia command line usage: tool versus library

2016-04-01 Thread Cameron McBride
Just trying to do a drop in "tool" for a few tasks. It's mostly a political
workflow thing internally, and a single script worked -- so I wasn't trying
to grow it further.

My technical question is addressed (as there isn't any specific way, but
it's a small thing that the julia style doesn't want to address -- which is
fine).

Cameron

On Fri, Apr 1, 2016 at 8:40 AM, James Fairbanks <jpfairba...@gmail.com>
wrote:

> What kind of production system is it? Why is it inconvenient to have two
> files, one that defines the library and one that parses the command line
> and calls the "main" function?
>
> On Friday, April 1, 2016 at 8:21:03 AM UTC-4, Cameron McBride wrote:
>>
>> Thanks, I missed that thread.
>>
>> Although neither suggested solution works as I was hoping for.
>>
>> I am trying to shoehorn julia into various parts of our pipeline and
>> production systems. Having a single library that can function as an
>> executable via shell is helpful. It's not a big deal, I just achieve this
>> by
>> % julia -L file.jl -e run_something()
>>
>> I do agree it's an awkward (and hopefully temporary) solution. Just
>> wanted to see if I was missing something.
>>
>> Cameron
>>
>>
>>
>> On Thu, Mar 31, 2016 at 3:39 PM, James Fairbanks <jpfai...@gmail.com>
>> wrote:
>>
>>> This had been discussed in this thread
>>> https://groups.google.com/d/msg/julia-users/ufpi8tV7sk8/-Uv0rtAWTWsJ
>>>
>>>
>>> On Wednesday, March 30, 2016 at 2:37:44 PM UTC-4, Cameron McBride wrote:
>>>>
>>>> Simple question (I think): Is there an easy or idiomatic way to
>>>> differentiate if a julia file is being run directly from when it's 
>>>> included?
>>>>
>>>> I'm looking for the equivalent of this in ruby:
>>>>
>>>> if $0 == __FILE__
>>>>   puts "Running file"
>>>> else
>>>>   puts "Included file"
>>>> end
>>>>
>>>> Thanks.
>>>>
>>>> Cameron
>>>>
>>>
>>


Re: [julia-users] Re: Julia command line usage: tool versus library

2016-04-01 Thread Cameron McBride
Thanks, I missed that thread.

Although neither suggested solution works as I was hoping for.

I am trying to shoehorn julia into various parts of our pipeline and
production systems. Having a single library that can function as an
executable via shell is helpful. It's not a big deal, I just achieve this
by
% julia -L file.jl -e run_something()

I do agree it's an awkward (and hopefully temporary) solution. Just wanted
to see if I was missing something.

Cameron



On Thu, Mar 31, 2016 at 3:39 PM, James Fairbanks <jpfairba...@gmail.com>
wrote:

> This had been discussed in this thread
> https://groups.google.com/d/msg/julia-users/ufpi8tV7sk8/-Uv0rtAWTWsJ
>
>
> On Wednesday, March 30, 2016 at 2:37:44 PM UTC-4, Cameron McBride wrote:
>>
>> Simple question (I think): Is there an easy or idiomatic way to
>> differentiate if a julia file is being run directly from when it's included?
>>
>> I'm looking for the equivalent of this in ruby:
>>
>> if $0 == __FILE__
>>   puts "Running file"
>> else
>>   puts "Included file"
>> end
>>
>> Thanks.
>>
>> Cameron
>>
>


Re: [julia-users] Can't add PostgreSQL

2016-05-04 Thread Cameron McBride
I've been using PostgreSQL and DBI just fine for a few months now.

The implementation has a few edges that need polishing and work, but the
basics work just fine for the julia 0.4.x branch.

The problem you ran into with fetchdf() not being implemented is that you
tried to run it on the stmt (before running execute). This is one of the
rough edges that not all convenience functions are implemented. In short, I
just confirmed the following example runs on julia 0.4.5 and the latest
DBI.jl / PostgreSQL.jl:

# slightly modified example from https://github.com/JuliaDB/PostgreSQL.jl

using DBIusing PostgreSQL

conn = connect(Postgres, "localhost", "username", "password", "dbname", 5432)
stmt = prepare(conn, "SELECT 1::bigint, 2.0::double precision,
'foo'::character varying, " *
 "'foo'::character(10);")
result = execute(stmt) # this was missing in your use!
df = fetchdf(result)finish(stmt)
disconnect(conn)


Perhaps that helps clarify? Happy to help further, here or offline.

Cameron


Re: [julia-users] Composite Type Array

2016-07-22 Thread Cameron McBride
On Fri, Jul 22, 2016 at 3:09 PM, Cameron McBride <cameron.mcbr...@gmail.com>
wrote:

> julia> function get_event(v::Vector{ExampleEvent}, i)
>  n = length(v)
>  if i > n
>for j in n:i
>push!(v, ExampleEvent("",0,0,0,0,0,0)) # default values
>end
>  end
>  v[i]
>end
>

haha, that creates one extra element (ExampleEvent row) on the first pass.
Whoops. Here is a quick fix. Likely better ways to do all this, just
kicking it further.

julia> function get_event(v::Vector{ExampleEvent}, i)
 n = length(v)
 if i > n
   i1 = n > 0 ? n : 1
   for x in i1:i
   push!(v, ExampleEvent("",0,0,0,0,0,0)) # default values
   end
 end
 v[i]
   end

Cameron


Re: [julia-users] When Julia v1.0 will be released?

2016-07-07 Thread Cameron McBride
> For industry, it probably means something similar.
>
>
> I really hope people in industry won't act on this date, as it is not
> nearly firm enough to bet a business on. We already have people writing
> blog posts about how using Julia for their startup turned out to be a
> mistake; we really don't need to encourage a new group of people to bet on
> something that's not 100% guaranteed.
>

This is indulging in a potential tangent, but I think the planned
(non-binding) date conversation is often useful as a scope. FWIW, things
are rapidly progressing on that front -- especially with what was on
display at JuliaCon. It's clear Julia Computing is helping push a number of
things now...

I agree with John that it's not an SLA. And betting a complicated codebase
on a rapidly evolving technology is a .. well .. significant risk. That
said, there are lots of places Julia can still excel and be a great choice.
If an industry application can just freeze out a version of julia for a
specific task, it's not hard to keep it running using Julia v0.3 or
whatever until it needs to be updated again.

I don't think John meant anything against the last bit -- but for the
silent readers, I wanted to throw in some of these thoughts.

Cameron


[julia-users] Re: [julia-dev] Convert a dense matrix A into a sparse matrix with sparsevec(A)

2016-09-09 Thread Cameron McBride
This thread is old, but I was poking through some unread bits and found it.
Beyond that, it’s likely a better question for julia-users list (which I’m
including here).

Anyhow, the answer is that sparsevec converts a dense matrix into a sparse
matrix format where zero values are not explicitly stored. If the vector
(or matrix) really is dense, this does not save space.

julia> A = [23.1, 42.67, 8.246, 111.33]
4-element Array{Float64,1}:
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(A)
Sparse vector of length 4 with 4 Float64 nonzero entries:
  [1]  =  23.1
  [2]  =  42.67
  [3]  =  8.246
  [4]  =  111.33


julia> B = [0,0,A...]
6-element Array{Float64,1}:
   0.0
   0.0
  23.1
  42.67
   8.246
 111.33

julia> sparsevec(B)
Sparse vector of length 6 with 4 Float64 nonzero entries:
  [3]  =  23.1
  [4]  =  42.67
  [5]  =  8.246
  [6]  =  111.33

Cameron


On Sat, Aug 20, 2016 at 7:15 AM, Parkway  wrote:

> The doc for the function sparsevec(A) says:
> sparsevec(A)
> Convert a dense vector A into a sparse matrix of size m x 1. In julia,
> sparse vectors are really just sparse matrices with one column.
>
> What does this actually mean? For example, what does the dense vector A =
> [23.1, 42.67, 8.246, 111.33] get converted to?
>
>


Re: [julia-users] so many plotting packages

2016-10-28 Thread Cameron McBride
There is some work on this. On your list is Plots.jl, which is a unifying
package that is backend agnostic. Specifically,
http://github.com/tbreloff/Plots.jl

Also, see:
https://github.com/JuliaPlots

Some seriously great stuff in there (and I say that as a user that has been
plotting in Julia for a couple years now).

Cameron

On Fri, Oct 28, 2016 at 3:17 PM, Ben Arthur  wrote:

> would be nice to have an organization to contain all of these. as
> @StefanKarpinski  pointed out (i
> forget where exactly), it would help to encourage developers to work
> together. it would also help new users of julia figure out which package
> they want to use.
>
> https://github.com/johnmyleswhite/ASCIIPlots.jl
> http://github.com/baggepinnen/ExperimentalAnalysis.jl
> 
> http://github.com/jheinen/GR.jl 
> http://github.com/GiovineItalia/Gadfly.jl
> 
> http://github.com/mbaz/Gaston.jl 
> http://github.com/ma-laforge/GracePlot.jl
> 
> http://github.com/ma-laforge/InspectDR.jl
> 
> http://github.com/sisl/PGFPlots.jl 
> http://github.com/plotly/Plotly.jl 
> http://github.com/tbreloff/Plots.jl 
> http://github.com/JuliaPy/PyPlot.jl 
> http://github.com/ig-or/QWTwPlot.jl 
> http://github.com/tbreloff/Qwt.jl 
> http://github.com/rennis250/Sparrow.jl
> 
> http://github.com/sunetos/TextPlots.jl
> 
> http://github.com/Evizero/UnicodePlots.jl
> 
> http://github.com/nolta/Winston.jl 
>


Re: [julia-users] matrix multiplications

2016-10-18 Thread Cameron McBride
You mean like the following?

julia> A=[1.0 2.0; 3.0 4.0]; B=[1.0 1.0; 1.0 1.0]; Y = similar(B); Y.= A * B

This doesn’t work as you might hope. I believe it just creates a temporary
result of A*B and then stuffs it into the preexisting Y.

On Tue, Oct 18, 2016 at 2:41 PM, Jérémy Béjanin 
wrote:

> I know, I was asking about that being the default behaviour of *
>
> On Tuesday, October 18, 2016 at 2:10:14 PM UTC-4, Stefan Karpinski wrote:
>>
>> That's what A_mul_B! does.
>>
>> On Tue, Oct 18, 2016 at 1:45 PM, Jérémy Béjanin 
>> wrote:
>>
>>> I think this is something I might have read about in the past, but are
>>> there plans to make y = a*b use an already allocated y?
>>>
>>> On Tuesday, October 18, 2016 at 12:38:00 PM UTC-4, Stefan Karpinski
>>> wrote:

   A_mul_B!(Y, A, B) -> Y

   Calculates the matrix-matrix or matrix-vector product A⋅B and stores
 the result in Y, overwriting the
   existing value of Y. Note that Y must not be aliased with either A or
 B.

   julia> A=[1.0 2.0; 3.0 4.0]; B=[1.0 1.0; 1.0 1.0]; Y = similar(B);
 A_mul_B!(Y, A, B);

   julia> Y
   2×2 Array{Float64,2}:
3.0  3.0
7.0  7.0

 On Tue, Oct 18, 2016 at 10:27 AM,  wrote:

> hi guys
> is there a way to reduce allocated memory in matrix multiplications?
>
> for example this code blew in my machine gives :
>
> function test4(n)
>   a = rand(n,n)
>   for i = 1:100
>  a*a
>end
>  end
>
>
> -- answer  --
> test4(1)
> # force compiling
>
> @time test4(1000)
> 16.589743 seconds (433 allocations: 770.587 MB, 0.68% gc time)
>


>>


Re: [julia-users] matrix multiplications

2016-10-19 Thread Cameron McBride
I agree on the consistency part with other in-place operations. I certainly
don’t feel it’s hard to just use A_mul_B!, but my familiarity with BLAS
shouldn’t be taken for granted. And if an in-place operator syntax exists
in the language already…

How about the flip side of the argument, it appears to works now — but
doesn’t do what one expects. I understand why it doesn’t, and not a big
deal with an evolving landscape of a developing language, but it certainly
can be confusing and suggests matrices are a different beast. I’m not sure
that is consistent with Julian way.  But yeah, no fusing like broadcast so
the gain is much reduced in implementing this.

Cameron

On Wed, Oct 19, 2016 at 8:58 AM, Milan Bouchet-Valat 
wrote:

> Le mardi 18 octobre 2016 à 15:28 -0700, Steven G. Johnson a écrit :
> >
> >
> > > Since it uses the in-place assignment operator .= it could be made
> > > to work as desired, but there's some designing to do.
> > >
> >
> > The problem is that it doesn't know that * is a matrix multiplication
> > until compile-time.
> >
> > In any case, I don't think there's a huge amount to be gained from
> > special syntax here.  Unlike broadcast operations, matrix
> > multiplications cannot in general be fused with other operations.
> > So you might as well do A_mul_B!.
> I think the biggest gain would be discoverability and consistency with
> other in-place operations. A_mul_B! isn't the most Julian of our APIs
> (to say the least)...
>
>
> Regards
>