Re: [julia-users] Re: How to built an array with some keys of a dictionary ?

2016-11-07 Thread Dan
a = Vector{String} is also a good option. On Monday, November 7, 2016 at 5:27:49 PM UTC+2, Steven G. Johnson wrote: > > > > On Monday, November 7, 2016 at 9:45:37 AM UTC-5, Mauro wrote: >> >> On Mon, 2016-11-07 at 15:27, Fred wrote: >> > Hi Steven, >> > >> > >> > I

Re: [julia-users] Re: How to built an array with some keys of a dictionary ?

2016-11-07 Thread Dan
I meant, a = Vector{String}() Dan On Tuesday, November 8, 2016 at 9:39:53 AM UTC+2, Dan wrote: > > a = Vector{String} > > > > is also a good option. > > On Monday, November 7, 2016 at 5:27:49 PM UTC+2, Steven G. Johnson wrote: >> >> >> >> On Mon

[julia-users] Re: jump ahead in Mersenne Twister

2016-10-21 Thread Dan
not too hard as well. G'day, Dan Getz On Friday, October 21, 2016 at 3:43:05 AM UTC+3, Joaquim Masset Lacombe Dias Garcia wrote: > > Hi, > > Have anybody implemented an arbitrary jump ahead for Mersenne Twister in > julia? > > I saw that the randjump documentatio

Re: [julia-users] Please help me to convert a BitArray to a Integer array in Julia

2016-10-17 Thread Dan
If saving characters is a thing, then: julia> a = rand(Bool,3,2) 3×2 Array{Bool,2}: false false true false false true julia> 1a 3×2 Array{Int64,2}: 0 0 1 0 0 1 On Monday, October 17, 2016 at 2:08:44 PM UTC+3, Scott Jones wrote: > > Tim, do you know if there is any difference in

[julia-users] Re: julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
This is what @dpsanders brought up in issue #22 . Summarizing my response there (repeated below), I wanted to get a prototype working to gauge the likelihood of adoption. " it probably could be, the truth is: + I wanted to bang

[julia-users] Re: julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
Sorry this wasn't clear! - Julz is a framework for building Julia projects. - It is *not* designed for making webpages, I was just trying to highlight the analogy The reason for the weird structure of the project is that: - this is a CLI

[julia-users] Re: julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
One more thing I wanted to say is, - I tried to do with julz what ember-cli did for ember.js - I really think ember-cli shaped their community into what it is today -- > *Code* > >- github repo:

[julia-users] Re: julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
- One final note is I tried to do with julz what ember-cli did for Ember.js - I really think the addition of ember-cli into the ecosystem changed the community in a way they never thought possible

[julia-users] Re: julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
ober 6, 2016 at 10:12:21 AM UTC-4, Dan Segal wrote: > > *Code* > >- github repo: https://github.com/djsegal/julz >- (see readme.rst as well as included dummy Julia project) > > *Summary* > > Julz is a command line utility for creating ambitious Julia appl

[julia-users] julz: a command line utility for creating scalable Julia applications

2016-10-06 Thread Dan Segal
*Code* - github repo: https://github.com/djsegal/julz - (see readme.rst as well as included dummy Julia project) *Summary* Julz is a command line utility for creating ambitious Julia applications. Its goal is to remove many of the petty decisions involved in starting a project and

[julia-users] julz: a command line utility for creating scalable Julia applications

2016-10-05 Thread Dan Segal
Summary Julz is a command line utility for creating ambitious Julia applications. Its goal is to remove many of the petty decisions involved in starting a project and establish a standard that can be adopted by the entire Julia ecosystem. In this way it channels Ruby on Rails’ mantra of

Re: [julia-users] Return structure-like elements from a function

2016-09-27 Thread Dan
That last line was probably meant to be paths = Vector{Matrix{Float64}}(4) On Tuesday, September 27, 2016 at 7:01:14 PM UTC-4, Yichao Yu wrote: > > On Tue, Sep 27, 2016 at 6:28 PM, Zhilong Liu > wrote: > > Hello All, > > > > I am trying to return values to elements

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
best_response_dimension, _, 1:length(_) ) > zip(_...) > map(all, _) > end > > On Sunday, September 25, 2016 at 11:57:47 AM UTC-4, Dan wrote: >> >> Oops, that `cat` code was supposed to be: >> >> cat(1,map(x->reshape(x,1,size(x)...),array_of_array)...)

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
Oops, that `cat` code was supposed to be: cat(1,map(x->reshape(x,1,size(x)...),array_of_array)...) Mew! On Sunday, September 25, 2016 at 11:54:43 AM UTC-4, Dan wrote: > > OK. So, to get the array to have the first dim as the player selector, you > can go: > > cat(1,map(x

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
1 array just seems so much more neat. Which is why I > was looking for a neat implementation of broadcast_slices to match. > > On Sunday, September 25, 2016 at 10:53:57 AM UTC-4, Dan wrote: >> >> Have you found the right implementation? >> >> Fiddling a bit, I ten

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
Have you found the right implementation? Fiddling a bit, I tend to agree with Steven G. Johnson `for` loops would be the most efficient and probably the most understandable implementation. Also, would it not be easier to have the first index in the `payoff_matrix` determine which player's

[julia-users] Re: dependent types in julia?

2016-09-14 Thread Dan
Maybe the following is the form you are looking for: julia> decomplexify{T}(::Type{Complex{T}}) = T decomplexify (generic function with 1 method) julia> type bar{S,T} sum::S sumsqr::T function bar(s,ss) if typeof(ss) != decomplexify(typeof(s))

Re: [julia-users] Julia Zmq Server creates Memory Leaks

2016-09-05 Thread Dan
This did the trick. Thanks!

[julia-users] Julia Zmq Server creates Memory Leaks

2016-09-05 Thread Dan
Hi, I am trying to create a Julia server instance by using ZMQ with the Req/Rep pattern. My Julia code for the Rep-server looks like this: module JServer # import zmq using ZMQ import Base.gc # create context ctx=Context(); # create socket socket=Socket(ctx, REP); # msg msg = 0; #

[julia-users] Re: Unexpected slowdown

2016-08-22 Thread Dan
Try keeping the loop over all primes and breaking when `a > maxp` where maxp is calculated once before the loop as `maxp = floor(Int,sqrt(n))`. On Monday, August 22, 2016 at 4:58:30 PM UTC-4, Achu wrote: > > I have a simple piece of code that finds me 10001 prime numbers. > > function a() >

[julia-users] Re: Unexpected Performance Behaviour

2016-08-02 Thread Dan
The following standalone version recovers the speed of `test2` using the @fastmath macro. Integer exponents have trade-offs in implementation using repeated squaring and multiplication and intrinsic power instructions. Not really sure how to control the implementation used in every instance.

[julia-users] Re: Linear-Equation-System Solver("\") does not work reliably for the "Rational" Type

2016-07-15 Thread Dan
be A*x == v is true. Hope this helps. -- Dan On Friday, July 15, 2016 at 2:50:01 PM UTC-4, Kurolong wrote: > > Hey Guys and Gals ^^ > I'm having trouble with Julia. Maybe one of you can help me out > The program i am writing requires the > linear-equation-system-solver(command &qu

[julia-users] Re: Want: "Deprecation" badge for Github

2016-07-12 Thread Dan
+1 There was also a suggestion at JuliaCon the badge could count the number of warnings displayed - perhaps, this would give some incentive for progressive cleanup/levelingup of code. On Tuesday, July 12, 2016 at 1:15:24 PM UTC-4, Erik Schnetter wrote: > > Our Julia projects live on Github,

[julia-users] Re: caching the pivot ordering for a sparse cholesky factorization?

2016-07-11 Thread Dan
solution it would be interesting to hear about it. On Sunday, July 10, 2016 at 9:38:44 PM UTC-4, Gabriel Goh wrote: > > I'd love more details Dan! > > On Saturday, July 9, 2016 at 8:53:16 PM UTC-7, Dan wrote: >> >> Hi Gabe, >> >> SuiteSparse which comes togeth

[julia-users] Re: caching the pivot ordering for a sparse cholesky factorization?

2016-07-09 Thread Dan
Hi Gabe, SuiteSparse which comes together with Julia includes a library KLU which does sparse LU factorization. It has the option to return the fill-in reducing order it manages to find for a given sparsity pattern. With this returned structure it can subsequently factorize many matrices (and

[julia-users] Re: changing record separator to read text files

2016-07-09 Thread Dan
`readuntil` is your friend. `readline` uses `readuntil`. In fact, it is defined as: readuntil(s,'\n') On Saturday, July 9, 2016 at 7:40:37 AM UTC-4, Fred wrote: > > Hi ! > > It is often very useful to read a text files by blocks of lines, using > another line separator than '\n'. > >

[julia-users] Re: Another nested function scope issue

2016-07-01 Thread Dan
Can you explain why it modified the one from the second block? On Friday, July 1, 2016 at 9:58:26 AM UTC-4, FANG Colin wrote: > > Never mind, I get it. > > On the third run, the `state` variable that `counter` modified is the one > from the second let block. >

[julia-users] Re: readdlm() pound sign at beginning of string is not read

2016-06-26 Thread Dan
Yes, this is the intended functionality because # is used a character which starts a comment in the file which is not parsed. The simplest way around this is to disble comments using the named parameter `comments` like this: readdlm(file,'\t',comments=false) You can also change the

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

2016-06-23 Thread Dan
[[M] [M]] works. And is the same as Matrix{Float64}[[M] [M]] But concur it is unintuitive. On Thursday, June 23, 2016 at 10:28:39 PM UTC-4, Sheehan Olver wrote: > > > [M,M] will do a Vector of Matrices in 0.5. But [M M] still does > concatenation. So the question is how to do

[julia-users] Re: Value written to file different from value printed

2016-06-17 Thread Dan
The print to screen statement is rather unequivocal. By elimination, the -1 in the file is the culprit. My guess is the -1 in the file is the value of a different variable. When writing to the file, add some text to identify which line is which var. Notice all vars are initialized to -1. P.S.

Re: [julia-users] Abstract version of rng=1:end ?

2016-06-13 Thread Dan
A reason such 'extended' ranges might be good, is the ability to dispatch on them for efficiency. For example, `deleteat!(vec,5:end)` could be implemented faster than just any `deleteat!` of any range. This would be applicable to other such structures with edge effects. Indeed, we can learn

[julia-users] Re: local package, howto?

2016-06-12 Thread Dan
Not sure, but I may have had a similar problem and doing (in the shell): git config --global url."https://".insteadOf git:// solved it. On Sunday, June 12, 2016 at 1:42:13 PM UTC-4, Andreas Lobinger wrote: > > Hello colleagues, > > like with similar problems, i don't know how i ended up

[julia-users] Re: Keeping heads and tails

2016-06-09 Thread Dan
Great. This is exactly what I needed. On Thursday, June 9, 2016 at 5:11:05 PM UTC-4, Kristoffer Carlsson wrote: > > Use resize! maybe.

[julia-users] Keeping heads and tails

2016-06-09 Thread Dan
Hello All, Given a vector (v) of length n, if I want to truncate it to its first k elements. How does one do this? My code currently uses `deleteat!(v,(k+1):length(v))`. But this is somewhat cumbersome and might be inefficient since `deleteat!` has to take care of all other ranges of elements

Re: [julia-users] confusion with Julia -p 2

2016-04-24 Thread Dan Y
The most funny part - I managed to reduce the running time to 3 seconds, rofl. In my code I use a lot of computations of the dot(A*B*f,f) for matrices A,B and vectors f filled with complex{float64}. But this is the same as dot(B*f,A'*f) !! So, multiplication of matrices was the most

Re: [julia-users] confusion with Julia -p 2

2016-04-24 Thread Dan Y
I must add that making code parallel was worth it! In my particular case I've got the following numbers: 21s - parallel code, blas_set_num_threads doesn't affect this much 32s - single-threaded code with blas_set_num_threads(2) 94s - single-threaded code with blas_set_num_threads(1) Also

Re: [julia-users] confusion with Julia -p 2

2016-04-23 Thread Dan Y
g > line: blas_set_num_threads(CPU_CORES) > > I've done this myself and had parallel julia processes each using more > than one core. Make use that line of code is used in each parallel > instance being called. > > On Saturday, April 23, 2016 at 4:29:40 AM UTC-6, Dan Y wrote: &

Re: [julia-users] confusion with Julia -p 2

2016-04-23 Thread Dan Y
Maybe it is because I use matrix multiplication in my code. I guess that base library which is responsible for linear algebra uses multiple cores automatically. But with "-p 2" it is forced to work only on 1 core for some reason. It's only a guess, though.

[julia-users] Re: Should Iterators be nonmutating?

2016-04-23 Thread Dan
ere it was before. > So it looks like we are not mutating the underlying object. > (cos we undo our changes) > This would not be threadsafe though. > > > On Saturday, 23 April 2016 05:22:11 UTC+8, Dan wrote: >> >> Looks like it might be appropriate to make the `stream` in `Each

[julia-users] Re: Should Iterators be nonmutating?

2016-04-22 Thread Dan
Looks like it might be appropriate to make the `stream` in `Eachline` be the state of the iterator (instead of the `nada` returned by `next`). Opening an issue (perhaps with a PR of a fix) could be the next step. Unless someone finds some other logic for keeping `Eachline` the way it is. On

[julia-users] confusion with Julia -p 2

2016-04-22 Thread Dan Y
I use julia-0.4.5 on windows10 with pentium B970 (2 cores, 2 threads) I have a code with no parallel instructions. When I run it in a standard session with no options my CPU utilization is about 80-90%. But when I run it in a session with "Julia -p 2" the CPU utilization is only about 20-25% .

[julia-users] Re: Modifying large vectors of repeated data

2016-04-14 Thread Dan
Similar `rle` and `inverse_rle` functions exists in StatsBase.jl https://github.com/JuliaStats/StatsBase.jl/blob/master/src/misc.jl#L15 . These function may be enough for the application involved. On Thursday, April 14, 2016 at 6:48:40 PM UTC+3, Kenta Sato wrote: > > I guess what you want is

[julia-users] Re: Fast coroutines

2016-04-02 Thread Dan
variable (and not const) which is a source of trouble for Julia type-inference based optimization (it is mentioned in the Performance Tips). So try to wrap up things in a function or make them const (but make sure they are not global which cannot be relied to keep their types). Dan On Saturday

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Dan
as a matrix reshape(map(x->A3[x[1]]+A3[x[2]],mapedges(A3,3)),dropdim(A3,3)) On Thursday, March 24, 2016 at 3:21:02 AM UTC+2, Dan wrote: > > # something along these lines: > > topleft(A,d) = tuple(ones(Int,ndims(A))...) > bottomleft(A,d) = tuple([i==d ? 1 : e for (i,e)

[julia-users] Re: How do I, as efficiently as possible, iterate over the first and last elements along a given dimension of an array?

2016-03-23 Thread Dan
# something along these lines: topleft(A,d) = tuple(ones(Int,ndims(A))...) bottomleft(A,d) = tuple([i==d ? 1 : e for (i,e) in enumerate(size(A))]...) topright(A,d) = tuple([i==d ? e : 1 for (i,e) in enumerate(size(A))]...) bottomright(A,d) = size(A) mapedges(A,d) = zip(

Re: [julia-users] Re: Mmap allocation question

2016-03-12 Thread Dan
g the code from the REPL, may that be a problem? (As I read in > the REPL everything is global). In the file nothing is global. > Also, the counters are UInt16s, but that shouldnt matter I guess. > > Thanks for the help so far! > > On Saturday, 12 March 2016 14:22:38 UTC+1, Dan wrot

Re: [julia-users] Re: Mmap allocation question

2016-03-12 Thread Dan
It's better to have code which actually runs in the post. In any case, the allocations at the `for` lines is suspicious - the for should basically only allocate a counter. Are there any global variables? Is `counter1` or `counter2` or `dims` global? Globals are always a good source of confusion

[julia-users] Re: what name would you give to the functional 'complement' of trunc()?

2016-03-12 Thread Dan
trunc_to_inf and add an alias trunc_to_zero for regular trunc ?? On Saturday, March 12, 2016 at 1:49:41 PM UTC+2, Jeffrey Sarnoff wrote: > > x = trunc(fp) yields fp rounded towards zero to the closest integer valued > float. > What name would you give to the complementary function, rounding away

[julia-users] Re: What wrong in (D'*D)/k.-(mean(D,1)'*mean(D,1)) ?

2016-03-04 Thread Dan
The matrix `D` is based on type `Int8` which overflows and wraps (without error) very quickly. The `cov` function automatically converts to a `Float64` but the manual calculation does not. To make the calculations match, try: D = convert(Matrix{Int},D) On Friday, March 4, 2016 at 10:42:02 AM

Re: [julia-users] Adding element to array and filtering multi-dimensional arrays.

2016-02-22 Thread Dan
On Monday, February 22, 2016 at 12:18:02 PM UTC+2, Tamas Papp wrote: > > > On Mon, Feb 22 2016, Aleksandr Mikheev wrote: > > > Hi everyone. I have two simple questions, answer to which I cannot find > by > > myself. > > > > 1. Is there any way to add an element to array? For example, I have

Re: [julia-users] Adding a mtrix to the third dimension of a multi-dimensional array

2016-02-14 Thread Dan
>From the help for `cat`: cat(dims, A...) Concatenate the input arrays along the specified dimensions in the iterable dims And indeed, if size(M1)=(3,3,3) and size(M2)=(3,3) Then, size(cat(3,M1,M2)) = (3,3,4) This method may not be efficient (though in terms of memory

Re: [julia-users] randperm run time is slow

2016-01-24 Thread Dan
A good description of random permutation generation is given in Wikipedia. It's the Fisher-Yates algorithm and its variants. On Saturday, January 23, 2016 at 4:43:36 PM UTC+2, Kevin Squire wrote: > > Hi Dan, > > It would also be good if you deleted that post (or edited it

Re: [julia-users] randperm run time is slow

2016-01-24 Thread Dan
at 4:43:36 PM UTC+2, Kevin Squire wrote: > > Hi Dan, > > It would also be good if you deleted that post (or edited it and removed > the code), for the same reason Viral mentioned: if someone reads the post > and then creates a pull request for changing the Julia implement

Re: [julia-users] randperm run time is slow

2016-01-23 Thread Dan
Another way to go about it, is to look at R's implementation of a random permutation and recreate it in Julia, hoping for similar performance. Having done so, the resulting Julia code is: function nrandperm(r::AbstractRNG, n::Integer) res = Array(typeof(n),n) if n == 0

[julia-users] Re: What's the difference between unique(a) and union(a)

2016-01-13 Thread Dan
Essentially, not much. `union` accepts multiple arguments with multiple types, but `unique` accepts a single collection. For example: union(1,2,3,3) == unique([1,2,3,3]) This would probably make `union` slightly slower. On Wednesday, January 13, 2016 at 11:58:18 PM UTC+2, Sheehan Olver wrote: >

Re: [julia-users] Iterating over leafs of a tree: use Cartesian?

2016-01-08 Thread Dan
For the special problem of getting all the betas in the post, they can be calculated with combinatorics: betas(levels,parts) = map(x->([x;levels+parts].-[0;x]-1)/parts, combinations(1:(levels+parts-1 ),(levels-1))) The idea is to choose which parts of (0.0,0.2), (0.2,0.4)... (0.8,1.0) go

Re: [julia-users] Re: Optimize sum of elements in an Array according to some conditions

2015-12-30 Thread Dan
at 11:54:27 PM UTC+2, Charles Santana wrote: > > Thanks, Dan! Indeed my "x" vector is sorted and your suggestion is really > fast! > > Best, > > Charles > > On 30 December 2015 at 12:08, Dan <get...@gmail.com > wrote: > >> Thanks Kristoffer, tu

[julia-users] Re: Optimize sum of elements in an Array according to some conditions

2015-12-30 Thread Dan
Thanks Kristoffer, turns out there is always interesting stuff in the bag of optimization tricks. Regarding the original function, a cheat could make it faster: The `x` vector is sorted, which means: function calcSum4(x::Array{Float64,1}, y::Array{Float64,1}, Ei::Float64, Ef::Float64,

[julia-users] Re: python a[range(x), y] equivalent in Julia

2015-12-20 Thread Dan
Is the following red expression a good Julia equivalent: julia> a = [ -1 2; 3 -4 ] ⋮ julia> y = [ 1, 2 ] ⋮ julia> [a[i,y[i]] for i=1:2] 2-element Array{Any,1}: -1 -4 (it's also fast) On Sunday, December 20, 2015 at 2:44:20 AM UTC+2, Lex wrote: > > I am expecting [-1 -4] in the Julia

[julia-users] Re: Using callable types or FastAnonymous with Sundials

2015-12-18 Thread Dan
The parameter for the `cvode` function is `f` and so is the function you want to use. These get confused, and it tries to use the "function" `J` instead. Changing the parameter name to something other than `{f}` should work On Wednesday, December 16, 2015 at 4:26:41 PM UTC+2, Simon Frost

[julia-users] Re: Compute selected eigenvectors with eigvecs

2015-12-16 Thread Dan
Linear algebra tells us Symmetric matrices have real eigenvalues and general matrices have complex eigenvalues in general. `eigvecs` can be called with an upper and lower bound on the eigenvalues of the eigenvectors to be found, but upper and lower bounds are applicable only to Real numbers,

[julia-users] Re: DataFrame melt question

2015-12-16 Thread Dan
the following re-reads the header and generates a dictionary which assigns the original column name to the converted one, in a one-liner-ish: df = readtable("/the/file.csv") h = Dict(zip(keys(df.colindex.lookup),split(open("/tmp/file.csv") do f chomp(readline(f)) ;

[julia-users] A non-breaking Julia control-flow change to separate the One language from mortal languages, doomed to die

2015-12-09 Thread Dan
*A non-breaking Julia control-flow change to separate the One language from mortal languages, doomed to die * >From a design patterns and DRY perspective it seems `for` loops together with >the `break` statement are serving as a useful `try`/`catch` mechanism for non-error situations. A common

[julia-users] A non-breaking Julia control-flow change to separate the One language from mortal languages, doomed to die

2015-12-09 Thread Dan
*A non-breaking Julia control-flow change to separate the One language from * *mortal languages, doomed to die * >From a design patterns and DRY perspective it seems `for` loops together with >the `break` statement are serving as a useful `try`/`catch` mechanism for non-error situations. A

[julia-users] A non-breaking Julia control-flow change to separate the One language from mortal languages, doomed to die

2015-12-09 Thread Dan
*A non-breaking Julia control-flow change to separate the One language from * *mortal languages, doomed to die * >From a design patterns and DRY perspective it seems `for` loops together with >the `break` statement are serving as a useful `try`/`catch` mechanism for non-error situations. A

Re: [julia-users] Re: A non-breaking Julia control-flow change to separate the One language from mortal languages, doomed to die

2015-12-09 Thread Dan
yntax needs cleaning up. > > -erik > > > > On Wed, Dec 9, 2015 at 10:47 AM, Seth <catc...@bromberger.com > > wrote: > >> Seems to me that this is just a more complex repeat...until or do...while >> bottom-conditional loop, which has already been discusse

Re: [julia-users] Re: `findmin` with arbitrary comparison operator?

2015-12-01 Thread Dan
suggestion: call the named argument `lt` to match the argument of `sort`. On Tuesday, December 1, 2015 at 6:23:07 PM UTC+2, Júlio Hoffimann wrote: > > Hi Erik, > > What I meant was a derived type from Julia's Tuple type. Though I agree > with you that this may be too much of an overhead for such

Re: [julia-users] Re: slow wordcount

2015-11-30 Thread Dan
and replacing println("$(t.first)\t$(t.second)") with @printf("%s\t%d\n",t.first,t.second) also halves the print time (which might or might not make a big difference but definitely > 1 second) On Monday, November 30, 2015 at 6:20:54 PM UTC+2, Dan wrote:

Re: [julia-users] Re: slow wordcount

2015-11-30 Thread Dan
ditacs/wordcount#leaderboard for details) > > Dan: > I can use external packages, it's not a big issue. However, FastAnonymous > didn't give results comparable to python. > The baseline python code I compare to is here: > https://github.com/juditacs/wordcount/blob/m

Re: [julia-users] Re: slow wordcount

2015-11-30 Thread Dan
: for t in sort(collect(wc), lt=customlt) println(t.first, "\t", t.second) end end On Monday, November 30, 2015 at 5:08:56 PM UTC+2, Dan wrote: > > Can you provide the comparable python code? Perhaps even the data used for > testing? > > Since you are eval

Re: [julia-users] Re: slow wordcount

2015-11-30 Thread Dan
Can you provide the comparable python code? Perhaps even the data used for testing? Since you are evaluating Julia, there are two important points to remember: 1) In Julia because the language is fast enough to implement basic functionality in Julia, then the distinction between Base Julia and

Re: [julia-users] Re: slow wordcount

2015-11-30 Thread Dan
Some points: 1) If you are timing the program by running from shell (i.e. including the whole Julia load time) - it's not a good idea for a bunch of reasons. 2) The printouts are also a little dubious to be used in a test. 3) Too short an input makes the test noisy. On Monday, November 30, 2015

Re: [julia-users] Re: Arrays of arrays.

2015-11-29 Thread Dan
`. all this is unnecessary, but might help for readability purposes. On Sunday, November 29, 2015 at 3:49:19 PM UTC+2, Milan Bouchet-Valat wrote: > > Le dimanche 29 novembre 2015 à 04:21 -0800, Dan a écrit : > > Since this situation comes up once in a while, it might be nice to > &g

[julia-users] Re: is it possible for collect() to return a collection of a specific type?

2015-11-27 Thread Dan
have you tried running collect within a function? sometimes the Global scope is bad for type inference. On Saturday, November 28, 2015 at 2:45:26 AM UTC+2, ele...@gmail.com wrote: > > Collect only requires that the collection is iterable, for which providing > an eltype() function is optional.

[julia-users] Re: is it possible for collect() to return a collection of a specific type?

2015-11-27 Thread Dan
Looking at the collect code, it seems you really should define Base.eltype for your iterator and things will work out. On Saturday, November 28, 2015 at 3:15:18 AM UTC+2, Seth wrote: > > I guess that makes sense, though I struggle to see why one would create an > iterator that produces multiple

[julia-users] Re: Precompilation and functions with keyword arguments

2015-11-25 Thread Dan
Aha! tested the same sequence in a non-REPL run and the 1st and 2nd runtimes after a `precompile` are the same. On Wednesday, November 25, 2015 at 10:23:04 PM UTC+2, Dan wrote: > > I've managed to reproduce the timing peculiarities you described, with a > different function. In fa

[julia-users] Re: Precompilation and functions with keyword arguments

2015-11-25 Thread Dan
if (sf->linfo->functionObject != NULL) { // found in the system image: force a recompile Function *llvmf = (Function*)sf->linfo->functionObject; if (llvmf->isDeclaration()) { sf->linfo->specFunctionObject = NULL; sf->linfo->func

[julia-users] Re: Precompilation and functions with keyword arguments

2015-11-25 Thread Dan
I've managed to reproduce the timing peculiarities you described, with a different function. In fact, I get the same first run slower behavior even with regular functions with -no- keywords. It is almost as if `precompile` is not doing the entire job. Have you tried, just testing the basic

Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Dan
Using `append!` instead of `push!` and letting efficient dynamic reallocation of vector do the resizing: function vcat_nosplat2a(y) result = Array(eltype(y[1]), 0) for a in y append!(result, a) end result end (@benchmark shows way less allocations and 2-3x time) BTW the

Re: [julia-users] Re: split a utf-8 string

2015-11-22 Thread Dan
`split` already has hooks for using other splitters. To achieve the UTF8 space splitting functionality, one can leverage the `isspace` function and add some decorations. For example: type FuncSplitter pred::Function end function Base.search(s::AbstractString, splt::FuncSplitter,

[julia-users] Re: What is the best way to get two by two tables in Julia?

2015-11-22 Thread Dan
Hi Arin, It would be helpful to have more details about the input (a dataframe?) and output (a two-by-two table or a table indexed by categories?). Some code to give context to the question would be even more help (possibly in another language, such as R). Having said this, here is a starting

Re: [julia-users] Re: Better alternative to find all permutations?

2015-11-22 Thread Dan
If we are already at this, it would be cool to have versions with Gray ordering. Something like: for (i1,i2) in permutations(vector,indices=true,Gray=true) theperm[[i1,i2]] = theperm[[i2,i1]] @show theperm end would go over all permutations. The syntax would be different and

[julia-users] Re: Coveralls/Codecov report certain lines are not covered, but test for the lines do appear to exist in code

2015-11-21 Thread Dan
Regarding the last printing point only print(string(eltype(8)) * ", " * string(eltype(8))) is probably what you meant. AbstractString(Int64), tries to create an AbstractString from an Int64, while string(Int64) asks for a string representation. The latter semantics is more accurate, and works.

[julia-users] Re: Better alternative to find all permutations?

2015-11-19 Thread Dan
Well, the previous listing worked only for Int vectors. Following is a more properly typed version. Various optimizations are possible: @inbounds, reducing allocations, etc. function uniquepermutations(base) zpos = Vector{Vector{Vector{Int}}}() zval = Vector{eltype(base)}() left =

[julia-users] Re: Better alternative to find all permutations?

2015-11-19 Thread Dan
How about this: using StatsBase using Iterators function uniquepermutations(base) zpos = Vector{Vector{Vector{Int}}}() zval = Vector{Int}() left = length(base) for (v,c) in countmap(base) push!(zpos,collect(subsets(collect(1:left),c))) push!(zval,v) left

[julia-users] Re: Converting ASCIIString to and from Array{UInt8,1}

2015-11-17 Thread Dan
`convert` is the go-to equivalent in Julia of casting. In this case: uint_array = convert(Vector{UInt8},str) but there are many ways of getting similar results! BTW `convert(ASCIIString,uint_array)` gets back. On Wednesday, November 18, 2015 at 1:49:36 AM UTC+2, James Gilbert wrote: > >

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
Well, its not as simple as that because of everything being sparse (adding columns is not just a loop over sum). Actually, it would be interesting to see a clever solution. On Wednesday, November 18, 2015 at 2:14:39 AM UTC+2, Dan wrote: > > the columns of A'A when A is sparse are just

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
]*sp.nzval[j] end end res end On Wednesday, November 18, 2015 at 3:54:56 AM UTC+2, Dan wrote: > > Oops... a bug (which showed itself when matrix was sparser than my > previous tests): > [when columns where completely empty, the first `if` should have been a > `while

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
) while sp.colptr[col+1]=sp.colptr[col2+1] col2+= 1 end @show col,col2,sp.nzval[i],sp.nzval[j] res[col,col2] += sp.nzval[i]*sp.nzval[j] end end res end On Wednesday, November 18, 2015 at 3:35:30 AM UTC+2, Dan wrote

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
It works, but it is slow (compared to `full(A'*A)`) On Wednesday, November 18, 2015 at 3:56:31 AM UTC+2, Dan wrote: > > And finally, getting rid of debug print. > > function AtrA(sp::SparseMatrixCSC) > res = zeros(eltype(sp),sp.n,sp.n) > col = 1 > @inbounds fo

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
end On Wednesday, November 18, 2015 at 2:30:14 AM UTC+2, Dan wrote: > > Well, its not as simple as that because of everything being sparse (adding > columns is not just a loop over sum). Actually, it would be interesting to > see a clever solution. > > On Wednesday, November 18, 201

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
Embarrassingly, there is yet another bug. while sp.colptr[col+1]=sp.colptr[col2+1] col2+= 1 end res[col,col2] += sp.nzval[i]*sp.nzval[j] end end res end On Wednesday, November 18, 2015 at 4:18:37 AM UTC+2, Dan wrote: > > It

[julia-users] Re: Looking for a few good algorithms

2015-11-17 Thread Dan
problem. The trick is doing the calculation in the right direction for the sparse storage, and it also uses the fact A multiplied by its own transpose. The exact speedup depends on the density and size. But I got 4x on `sprand(200,400,0.1)` On Wednesday, November 18, 2015 at 4:41:36 AM UTC+2, Dan

[julia-users] Re: push! performance

2015-11-15 Thread Dan
AFAIK the implementation of `push!` in Julia only occasionally allocates a bigger buffer for the new vector. This results in a very low average time for adding multiple elements (O(1) amortized time in complexity jargon). Notice, `a = [a new_element ]` would in Julia do something else than

[julia-users] Find

2015-11-14 Thread Dan
`x .> 3` is a bit-array. The function form, which is probably what fits, is `x->x.>3` (the back-ticks are for quotation, not part of the code).

[julia-users] Re: Median filter

2015-11-10 Thread Dan
As a quick stopgap, you could use the following: medianfilter1(v,ws) = [median(v[i:(i+ws-1)]) for i=1:(length(v)-ws+1)] medianfilter(v) = medianfilter1(vcat(0,v,0),3) `medianfilter` does a 3 window median filter. It is not the fastest implementation, but it works (hopefully). On Tuesday,

Re: [julia-users] Arrays as streams / consuming data with take et al

2015-11-09 Thread Dan
XXX in your questions = chain. Or more clearly: julia> stream = chain([1,2,3,4,5]) Iterators.Chain(Any[[1,2,3,4,5]]) julia> collect(take(stream, 3)) 3-element Array{Any,1}: 1 2 3 On Monday, November 9, 2015 at 7:47:51 PM UTC+2, andrew cooke wrote: > > > hmmm. maybe i'm doing it wrong as

Re: [julia-users] Arrays as streams / consuming data with take et al

2015-11-09 Thread Dan
ators.jl i guess. > > it doesn't support read though (which i didn't realise i needed when i > first asked). > > i'll add a warning to StatefulIterators pointing people to this. > > thanks, > andrew > > On Monday, 9 November 2015 17:07:52 UTC-3, Dan wrote: >> &g

Re: [julia-users] Arrays as streams / consuming data with take et al

2015-11-09 Thread Dan
lia> collect(rest(1:3,start(1:3))) 3-element Array{Any,1}: 1 2 3 Shouldn't the type of both arrays be the same? (the latter defined in non-global context still yield Any Array). On Monday, November 9, 2015 at 10:45:12 PM UTC+2, Dan wrote: > > the example with `pull` before, traverses th

Re: [julia-users] Arrays as streams / consuming data with take et al

2015-11-09 Thread Dan
bered somewhere. On Monday, November 9, 2015 at 10:07:52 PM UTC+2, Dan wrote: > > XXX in your questions = chain. > Or more clearly: > julia> stream = chain([1,2,3,4,5]) > Iterators.Chain(Any[[1,2,3,4,5]]) > > julia> collect(take(stream, 3)) > 3-element Array{Any,1}: > 1 >

  1   2   >