[julia-users] Re: map(mean, zip(v...)) doesn't scale

2016-08-10 Thread David Gold
I want to say it's the iteration over the large ZipIterator that's giving you grief. Possibly relevant (since n-arg map implementation falls back on iterating over zipped argument arrays): https://github.com/JuliaLang/julia/issues/17321 On Wednesday, August 10, 2016 at 5:34:08 AM UTC-4, Tamas

[julia-users] Re: Is empty map result type going to be fixed?

2016-07-05 Thread David Gold
On this branch https://github.com/JuliaLang/julia/pull/16622 there is *julia> **map(length, String[])* *0-element Array{Int64,1}* So, perhaps on 0.5 this will be "fixed". On Monday, July 4, 2016 at 2:58:07 PM UTC-4, Jussi Piitulainen wrote: > > I browsed through some Github issues where t

[julia-users] Re: Which way is preferred to define a closure?

2016-07-02 Thread David Gold
Thank you for the clarification! On Saturday, July 2, 2016 at 8:52:38 AM UTC-4, Fengyang Wang wrote: > > let is lowered to what is basically a function that's executed > immediately. It should have identical performance on 0.5. > > On Friday, July 1, 2016 at 10:31:20 AM UTC

[julia-users] Re: Which way is preferred to define a closure?

2016-07-01 Thread David Gold
Depends which version you're on. On 0.5, where anonymous functions are performant, I think the way to go is myfun(x) () -> do_something(x) end cf. https://github.com/JuliaLang/julia/pull/13412. I think you might experience performance issues with the let block approach. I could be wrong ab

[julia-users] Difficulty building latest master

2016-05-15 Thread David Gold
Something relating to OpenBLAS is going wrong when I try to build the latest master: 22736 Symbol names changed ld: warning: could not create compact unwind for _sgbtrf_64_: stack subq instruction is too different from dwarf stack size ld: warning: could not create compact unwind for _shseqr_6

Re: [julia-users] Re: why's my julia code running slower than matlab, despite performance tips

2016-05-08 Thread David Gold
So, the issue here was the indexing clashing up against the column-major storage of multi-dimensional arrays? On Sunday, May 8, 2016 at 10:10:54 AM UTC-7, Tk wrote: > > Could you try replacing >for i in 1:nx, j in 1:ny, k in 1:nz > to >for k in 1:nz, j in 1:ny, i in 1:nx > because your ar

Re: [julia-users] Nongeneric functions

2015-12-29 Thread David Gold
It may be more helpful to have a general audience friendly section on built-ins somewhere in the documentation and to include information in docstrings for individual built-in functions. On Sunday, December 27, 2015 at 4:25:26 PM UTC-5, Ismael Venegas Castelló wrote: > > I think this would be u

[julia-users] Re: Read back a Dict from a text file in Julia ?

2015-11-21 Thread David Gold
Note that your dd is a Dict{String, Any}. If you access its entries inside a function, the type inference system that runs when the function is JIT compiled will not have any information on the types of the objects returned from accessing dd. The lack of concrete type information will most likel

[julia-users] Re: How to escape array of symbols in a macro?

2015-10-20 Thread David Gold
ethod for generic function "f": f(x::Int64, y::Int64) at none:3 julia> f(1, 2) 3 On Tuesday, October 20, 2015 at 11:19:44 AM UTC-7, David Gold wrote: > > IIUC, the following yields the desired behavior: > > macro deffun(ex) > func = ex.args[1] > args = ex.a

[julia-users] Re: How to escape array of symbols in a macro?

2015-10-20 Thread David Gold
IIUC, the following yields the desired behavior: macro deffun(ex) func = ex.args[1] args = ex.args[2:end] decl = Expr(:call, func, args...) body = quote # do some stuff

[julia-users] Re: Interest in a Seattle-Area Julia Meetup?

2015-10-19 Thread David Gold
I just joined the PhD program in Statistics at UW and would be very much interested in a Seattle-area meet up! On Monday, October 19, 2015 at 12:46:02 PM UTC-7, tim@multiscalehn.com wrote: > > I work for a company where we are big fans of Julia, and are using it for > several projects. We h

[julia-users] Re: Performance compared to Matlab

2015-10-19 Thread David Gold
One doesn't always need to write the loops oneself. Oftentimes switching from a pure operator (e.g. broadcast) to its in-place counterpart (e.g. broadcast!) can make a world of difference: julia> A = rand(5_000_000); julia> function f(A) sum(A .+ A.^2) end f (generic function with 1 met

Re: [julia-users] ANN: NullableArrays.jl package

2015-10-19 Thread David Gold
> I did see this https://github.com/JuliaStats/NullableArrays.jl/issues/1, > but that seems outdated. > > > > Thanks, > > David > > > > *From:* julia...@googlegroups.com [mailto: > julia...@googlegroups.com ] *On Behalf Of *David Gold > *Sent:* Sa

[julia-users] Re: ANN: NullableArrays.jl package

2015-10-19 Thread David Gold
ecause there are tentative plans to replace it with different semantics (see https://github.com/JuliaStats/NullableArrays.jl/pull/56#issuecomment-133995334). On Sunday, October 18, 2015 at 1:11:16 PM UTC-7, Matt Bauman wrote: > > On Sunday, October 18, 2015 at 3:54:13 PM U

[julia-users] Re: ANN: NullableArrays.jl package

2015-10-18 Thread David Gold
NullableArray{T, N} and Array{Nullable{T, N}} essentially follow the struct-of-arrays vs. array-of-struct distinction. All of the values of a NullableArray and all of the information about missingness/presence of values are each stored in separate Array objects, which allows for certain optimiz

[julia-users] Re: ANN: NullableArrays.jl package

2015-10-18 Thread David Gold
@Sebastian: If I understand you correctly, then it should at least be possible. If T is your datatype that behaves as such and x is the value of type T that designates missingness, then it seems you could straightforwardly write your own method to convert an Array{T} to a NullableArray{T} that

[julia-users] Re: Is there a way to replace f(object, args...) with object.f(args...)?

2015-10-07 Thread David Gold
See perhaps https://groups.google.com/forum/?hl=en#!topic/julia-dev/V1HJcHQz4JE On Wednesday, October 7, 2015 at 8:13:33 AM UTC-7, cheng wang wrote: > > Hello everyone, > > In some cases, I would like to make a function belongs to an object. > In classical OO, we do something like object.f(args..

Re: [julia-users] DataFrames' readtable very slow compared to R's read.csv when loading ~7.6M csv rows

2015-10-07 Thread David Gold
be missing https://github.com/lindahua/DataStreams.jl >> I have no idea where to find DataStreams package >> Does it still exist? >> >> Is there any (experimental) way to make CSV.jl work? >> >> >> >>> Am Samstag, 6. Juni 2015 14:41:36 UTC+2

Re: [julia-users] metaprogramming: create type programmatically?

2015-10-05 Thread David Gold
@Tim is it not recommended because of the use of eval to change the global state? On Monday, October 5, 2015 at 12:39:48 PM UTC-7, Tim Holy wrote: > > On Monday, October 05, 2015 07:19:48 PM Jameson Nash wrote: > > in short: you can't. > > In long: you can :-), but it's not recommended. There m

[julia-users] Re: Variable number of parameters types in a function

2015-10-04 Thread David Gold
Note that if the type variable T does not appear in the argument signature then the method won't be callable. If you really want to make use of the variable parameters, your best bet I think is to pass a tuple of args: function f{T<:Tuple}(x::T) for (i, param) in enumerate(T.parameters)

[julia-users] Re: ANN: NullableArrays.jl package

2015-09-20 Thread David Gold
am looking forward to using it. Are the performance > characteristics as good as expected (compared to DataArray?) > > On Sunday, 20 September 2015 02:38:08 UTC+9, David Gold wrote: >> >> I'm happy to announce that a tagged and registered beta release of >> Nulla

[julia-users] Re: Julia code 5x to 30x slower than Matlab code

2015-09-19 Thread David Gold
One thing I suspect is hurting you is that you're storing your parameters in a `Dict` object. Because the parameters are all of different types, (and because of the way you declare the `Dict`), they are stored in a `Dict{Any, Any}`, which means that Julia's type inference system is unable to dis

[julia-users] ANN: NullableArrays.jl package

2015-09-19 Thread David Gold
I'm happy to announce that a tagged and registered beta release of NullableArrays.jl is now available for use with the Julia 0.4 release candidates. This is the latest stage of my work for the Julia Summer of Code '15 program, and I hope to cont

Re: [julia-users] Re: Getting type parameters from a parameterized types?

2015-09-12 Thread David Gold
es.jl >> could (should?) be expanded for any type-parameters. (Or does it already >> work?) >> >> On Fri, 2015-09-11 at 21:54, David Gold > > wrote: >> > I'm not convinced it's more Julian to use such a helper function, since >> it >> &g

[julia-users] Re: Getting type parameters from a parameterized types?

2015-09-11 Thread David Gold
I'm not convinced it's more Julian to use such a helper function, since it will needlessly compile a different method for each distinct set of parameters. Directly accessing the `parameter` field of the type in question avoids this. On Friday, September 11, 2015 at 12:30:16 PM UTC-7, Josh Lang

[julia-users] Re: How to evaluate variable inside Formula type? (Linear Mixed Models)

2015-09-11 Thread David Gold
I can think of two possible solutions to try. 1) pass the covariate names as symbols rather than strings, e.g. probeName=:X10154 2) if you're going to pass the names as strings, try mod=fit(lmm($(symbol(probeName)) ~ X + (1|PatientID),Data)) On Friday, September 11, 2015 at 6:18:39 AM UTC-7, M

[julia-users] Re: Performance between R, Julia and Cpp

2015-08-28 Thread David Gold
Thanks for following up on the details, Kristoffer!

[julia-users] Re: Performance between R, Julia and Cpp

2015-08-28 Thread David Gold
I'm traveling and cannot take the time to go through this code more thoroughly. However, I see at least a few issues worth mentioning in addition to the other comments: 1) Note that Kristoffer's function 'f' in https://gist.github.com/KristofferC/207dcc6f4f22eed73562 does not include the readt

[julia-users] Re: boolean not for integer array?

2015-08-17 Thread David Gold
http://docs.julialang.org/en/latest/stdlib/arrays/#Base.find On Monday, August 17, 2015 at 2:31:11 PM UTC-4, Ratan Sur wrote: > > That is what I meant, I was hoping there was a less verbose way to do it. > So I would need to do: > c = a.!=0 & b.!=0 > > Instead of something like > c = !a & !b > > >

Re: [julia-users] Assistance with understanding typing

2015-08-12 Thread David Gold
Well, not all arrays: julia> Array{Int}() 0-dimensional Array{Int64,0}: 4544954880 On Wednesday, August 12, 2015 at 11:36:24 AM UTC-4, Mauro wrote: > > > > On Wed, 2015-08-12 at 17:28, Cedric St-Jean > wrote: > > On Wednesday, August 12, 2015 at 12:15:19 AM UTC-4, Stefan Karpinski > wrote: >

[julia-users] Re: fast columnwise norm of matrix/speed up mapslices?

2015-08-12 Thread David Gold
Here's a way to do it with slices julia> function f(mat) mat1 = slice(mat, 1, :) mat2 = slice(mat, 2, :) mat3 = slice(mat, 3, :) A = Array(Float64, size(mat, 2)) for i in 1:size(mat, 2) A[i] = sqrt(mat1[i]^2 + mat2[i]^2 + mat3[i

Re: [julia-users] fast columnwise norm of matrix/speed up mapslices?

2015-08-12 Thread David Gold
One thing that's hurting your home-rolled function's performance is that .^ is allocating a copy for each 1e6-length row. I'm not sure if the vectorized sqrt operator does something similar (I'm actually having some trouble finding the source code for it). Anyway, the best thing to do here seem

Re: [julia-users] Assistance with understanding typing

2015-08-12 Thread David Gold
spatch. > > > > On Wednesday, August 12, 2015 at 2:14:14 PM UTC+2, David Gold wrote: >> >> @Stefan, >> >> I'd have thought that parametric types being invariant in typevars would >> lead to >> >> !(Tuple{ASCIIString, ASCIIString} <:

Re: [julia-users] Assistance with understanding typing

2015-08-12 Thread David Gold
@Stefan, I'd have thought that parametric types being invariant in typevars would lead to !(Tuple{ASCIIString, ASCIIString} <: Tuple{String, String}) just as !(Vector{ASCIIString} <: Vector{String}) Tuples seem to behave specially? On Tuesday, August 11, 2015 at 4:18:38 PM U

Re: [julia-users] Difficulty making latest Julia master

2015-08-11 Thread David Gold
dependencies that we get from git from now on. > > > On Tuesday, August 11, 2015 at 10:18:59 AM UTC-7, David Gold wrote: >> >> Thanks, but not working =( >> >> On Tuesday, August 11, 2015 at 12:25:50 PM UTC-4, Isaiah wrote: >>> >>> make -C

Re: [julia-users] Difficulty making latest Julia master

2015-08-11 Thread David Gold
I'm just re-cloning the julia repo, so presumably that ought to fix the issue. On Tuesday, August 11, 2015 at 1:25:09 PM UTC-4, ron.s...@gmail.com wrote: > > I had that problem yesterday. Isaiah's solution worked for me.

Re: [julia-users] Difficulty making latest Julia master

2015-08-11 Thread David Gold
Thanks, but not working =( On Tuesday, August 11, 2015 at 12:25:50 PM UTC-4, Isaiah wrote: > > make -C deps clean-libgit2 && make > > On Tue, Aug 11, 2015 at 12:23 PM, David Gold > wrote: > >> I incur the following error after pulling from GitHub and running `mak

[julia-users] Difficulty making latest Julia master

2015-08-11 Thread David Gold
I incur the following error after pulling from GitHub and running `make`: Davids-MBP:julia David$ make error: Your local changes to the following files would be overwritten by checkout: CMakeLists.txt src/openssl_stream.c Please, commit your changes or stash them before you can switch branche

Re: [julia-users] Defining a function in different modules

2015-08-06 Thread David Gold
`ModelBase.fit!`. On Thursday, August 6, 2015 at 6:23:14 PM UTC-7, David Gold wrote: > > Madeleine, > > You are experiencing these problems in 0.3, correct? > > On Thursday, August 6, 2015 at 3:46:49 PM UTC-7, Madeleine Udell wrote: >> >> I've been running into major

Re: [julia-users] Defining a function in different modules

2015-08-06 Thread David Gold
Madeleine, You are experiencing these problems in 0.3, correct? On Thursday, August 6, 2015 at 3:46:49 PM UTC-7, Madeleine Udell wrote: > > I've been running into major user problems because of the silent > overwriting of functions from one module by functions from another. My > LowRankModels m

Re: [julia-users] Determine current function name

2015-08-06 Thread David Gold
For counting, is there a reason why you can't use a `let` block? let count = 0 global foo function foo(args...) count += 1 ... end global foo_count() function foo_count() return count end end # let count On Thursday, August 6, 2015 at 7:36:10 AM UT

[julia-users] Re: Julia as first programming language

2015-08-05 Thread David Gold
I've been learning Julia as my first programming language, if I don't count the VB I learned in high school tech and the small amount of R I learned to pass STAT 201. For me, Julia has been an excellent first first language. The syntax is friendly and accessible, so it's easy to get started wor

[julia-users] Re: Readtimearray function in Julia TimeSeries package

2015-08-03 Thread David Gold
I'm not familiar with TimeSeries, but perhaps you should check if readtimearray automatically detects headers? On Monday, August 3, 2015 at 8:07:37 AM UTC-4, Danny Zuko wrote: > > I would like to read a csv file of the following form with readtimearray: > > > "","ES1 Index","VG1 Index","TY1 Comdt

[julia-users] Re: setindex! for matrix of vectors

2015-07-28 Thread David Gold
d Linus, an easy work-around (assuming that you don't always just have a > one-element) is to use `fill!` instead: `fill!(A, [1,2,3])`. > > On Tuesday, July 28, 2015 at 8:45:44 AM UTC-4, David Gold wrote: >> >> That error makes sense to me, insofar as `A[:]` is not a scalar

[julia-users] Re: setindex! for matrix of vectors

2015-07-28 Thread David Gold
concatenation vs construction issue), but this will only work if > `length(A)==1`. > > And Linus, an easy work-around (assuming that you don't always just have a > one-element) is to use `fill!` instead: `fill!(A, [1,2,3])`. > > On Tuesday, July 28, 2015 at 8:45:44 AM UTC-4,

[julia-users] Re: setindex! for matrix of vectors

2015-07-28 Thread David Gold
That error makes sense to me, insofar as `A[:]` is not a scalar entry but a whole vector. So assigning the vector `[1, 2, 3]` to `A[:]` is interpreted as, "put all the things from this vector into that vector". But by that logic, `A[:] = [[1, 2, 3],]` ought to work, and it doesn't. Of course, s

[julia-users] Re: :(a.b)

2015-07-26 Thread David Gold
Perhaps it's related to the fact that `getfield` takes a `Symbol` argument: julia> type MyType b end julia> a = MyType(10) MyType(10) julia> getfield(a, :b) 10 So you could just do `getfield(x, $(rhs.arg[2]))`. On Sunday, July 26, 2015 at 6:00:58 PM UTC-4, Cedric St-Jean wrote: > >

[julia-users] Re: Using a macro argument as a symbol, inside the returned quote

2015-07-26 Thread David Gold
at it should, but since it's possible to just call both >> functions manually I'm in no way blocked by it :) >> >> Thanks for the help! >> >> // T >> >> On Sunday, July 26, 2015 at 1:48:43 AM UTC+2, David Gold wrote: >>> >>> Hmm

[julia-users] Re: Using a macro argument as a symbol, inside the returned quote

2015-07-25 Thread David Gold
ell - except that I have to define it in each new > workspace… Adding it to .juliarc.jl does make it available on start, but > after workspace() it’s not available anymore, and kind-of looses its > point… > > Any suggestions? > > // T > > On Sunday, July 26, 2015 a

[julia-users] Re: Using a macro argument as a symbol, inside the returned quote

2015-07-25 Thread David Gold
This seems to work: julia> macro foo(bar) _bar = Expr(:quote, bar) res = Expr(:call, :isdefined, :($_bar)) return res end julia> macroexpand(:( @foo(baz) )) :(isdefined(:baz)) On Saturday, July 25, 2015 at 6:30:08 PM UTC-4, Tomas Lycken wrote: > > H

[julia-users] Re: New variables overwrite old variables in certain cases.

2015-07-25 Thread David Gold
To supplement John's resource (which explains that the behavior you indicate is indeed a property of the language): Currently (and in the version you're using), range indexing such as `x[:]` returns a copy of `x`. So does applying an operation like `y * 4`. That's why writing `y = x[:]` or `y =

Re: [julia-users] NaN definition for Integer types?

2015-07-24 Thread David Gold
If you end up trying the `Nullable` route, you might find our in-progress `NullableArrays` package helpful: https://github.com/johnmyleswhite/NullableArrays.jl. Its designed to extend the functionality of the `AbstractArray` interface to a container type specialized to handle `Nullable` entries

[julia-users] Re: How Do You Filter Rows in a DataFrame Based on a Set of Interest or Specific Pattern?

2015-07-23 Thread David Gold
Check out the DataFramesMeta package: https://github.com/JuliaStats/DataFramesMeta.jl On Wednesday, July 22, 2015 at 11:18:46 PM UTC-4, Clinton Brownley wrote: > > Hello, > > *Does the DataFrames package or the DataFramesMeta package provide > syntax/functions you can use to filter for rows that

[julia-users] Re: Nullable parametric types

2015-07-21 Thread David Gold
Or use typealiases? On Tuesday, July 21, 2015 at 4:48:31 PM UTC-4, David Gold wrote: > > My instinct is to write a macro. > > On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote: >> >> Hi all, >> >> I'm in the process of repl

[julia-users] Re: Nullable parametric types

2015-07-21 Thread David Gold
My instinct is to write a macro. On Tuesday, July 21, 2015 at 4:37:03 PM UTC-4, Darwin Darakananda wrote: > > Hi all, > > I'm in the process of replacing my Union{Nothing, T} annotations to > Nullable{T}, but I'm getting stuck when T is a parametric type. For > example, replacing the function >

[julia-users] Re: Abstract type in field values

2015-07-20 Thread David Gold
It's kind of tricky talking about "the compiler", since there's a lot that goes on to get from user-facing Julia code to native machine code. That being said, here's how I'd explain the issue to myself, under the very rough and ready approximation that "the compiler" is the engine that produces

[julia-users] Re: Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)

2015-07-19 Thread David Gold
Also, what's wrong with `foo(args...) = length(args)` ? Seems like that ought to achieve your desired result. On Sunday, July 19, 2015 at 5:43:30 PM UTC-4, Tomas Lycken wrote: > > Hi everybody, > > I created the function > > foo{N}(bar::NTuple{N}...) = N > > under the impression that I'd be

[julia-users] Re: Splatting NTuple-s in method signatures (what's the difference between defining foo{N}(x::NTuple{N}...) and bar{N}(x::NTuple{N})?)

2015-07-19 Thread David Gold
To see the difference between `foo` and `bar`, try `foo((2,3), (4,5))` and `bar((2,3), (4,5))`. Then try `foo((2,3), (4,5,6))`. On Sunday, July 19, 2015 at 5:43:30 PM UTC-4, Tomas Lycken wrote: > > Hi everybody, > > I created the function > > foo{N}(bar::NTuple{N}...) = N > > under the imp

[julia-users] Re: Finding the index of the n-th occurrence of a predicate in an Array

2015-07-17 Thread David Gold
- 1) prev == 0 ? 0 : findnext(f, A, prev + 1) end On Friday, July 17, 2015 at 10:24:06 AM UTC-4, Pontus Stenetorp wrote: > > On 17 July 2015 at 15:07, David Gold > > wrote: > > > > If you don't care about short-circuiting after finding the nth > oc

[julia-users] Re: Finding the index of the n-th occurrence of a predicate in an Array

2015-07-17 Thread David Gold
cc(x->iseven(x), A, 3) 6 julia> findocc(x->iseven(x), A, 5) 10 julia> findocc(x->iseven(x), A, 6) 0 On Friday, July 17, 2015 at 10:07:47 AM UTC-4, David Gold wrote: > > If you don't care about short-circuiting after finding the nth occurrence > you could of co

[julia-users] Re: Finding the index of the n-th occurrence of a predicate in an Array

2015-07-17 Thread David Gold
If you don't care about short-circuiting after finding the nth occurrence you could of course just do `find(f, A)[n]`. On Friday, July 17, 2015 at 10:00:43 AM UTC-4, Pontus Stenetorp wrote: > > Everyone, > > I just recently needed to find the index of the n-th occurrence of a > predicate an Arr

Re: [julia-users] Question about @eval and quoting

2015-07-17 Thread David Gold
> 3: > unless > (top(box))(Bool,(top(not_int))((top(box))(Bool,(top(not_int))(#s1::Int64 > === > (top(box))(Int64,(top(add_int))((top(getfield))(GenSym(0),:stop)::Int64,1))::Bool > > goto 2 > 1: > 0: > return >

Re: [julia-users] Question about @eval and quoting

2015-07-16 Thread David Gold
ter type > resolution. The second version keeps a "Function" object around for every > call while the first version only uses that "Function" object to get the > symbol/name. > > Hope this helps? > > On Thu, Jul 16, 2015 at 4:21 PM, Yichao Yu > > wrot

Re: [julia-users] Question about @eval and quoting

2015-07-16 Thread David Gold
ized with input and output type information. > > On Thu, Jul 16, 2015 at 11:22 AM, David Gold > wrote: > >> Suppose I want to apply the trick that makes `broadcast!` fast to `map!`. >> Because of the specificity of `map!`'s functionality, I don't necessarily >&

[julia-users] Question about @eval and quoting

2015-07-16 Thread David Gold
Suppose I want to apply the trick that makes `broadcast!` fast to `map!`. Because of the specificity of `map!`'s functionality, I don't necessarily need to cache the internally declared functions, so I just write: function map!{F}(f::F, dest::AbstractArray, src::AbstractArray) _f = Expr(:quo

[julia-users] Re: scoping rule help for functions within functions

2015-07-15 Thread David Gold
Unless I'm mistaken, this is a consequence of lexical scoping. See the fifth paragraph down http://docs.julialang.org/en/latest/manual/variables-and-scoping/. Since mesh() is defined inside of foo(), the call to `mesh(2:3) in the line `y = mesh(2:3)` actually reassigns the name `x` from the lin

[julia-users] Re: How to make (sort of) pointers to an array subsection ?

2015-07-15 Thread David Gold
Also see http://docs.julialang.org/en/latest/devdocs/subarrays/ On Wednesday, July 15, 2015 at 6:14:14 AM UTC-4, Ferran Mazzanti wrote: > > Hi folks, > > I have a little mess with the way arrays are being handled in Julia. I > come from C and fortran95 and I know I can do the following things the

Re: [julia-users] Re: Environment reification and lazy evaluation

2015-07-10 Thread David Gold
> > Hmm, so the reason that macros are able to function is that they occur > before type computation? I don't know how best to respond to this question, but I will throw out that staged functions are expanded after type information is known to the compiler. On Friday, July 10, 2015 at 10:07

[julia-users] Re: Constructing tuples using Tuple

2015-07-10 Thread David Gold
@Scott maybe it's just me, but passing a tuple to the method that's responsible for constructing precisely that same tuple is kind of unsatisfying! =p On Friday, July 10, 2015 at 9:51:17 AM UTC-4, Scott Jones wrote: > > You need to pass a tuple to the constructor, i.e.: > julia> x = Tuple{Int64}

[julia-users] Re: Constructing tuples using Tuple

2015-07-10 Thread David Gold
@Andrew: I wonder if it's more complicated than that. Clearly tuples aren't implemented that way and the docs language is analogical. However, it seems that constructing a tuple object from non-tuple objects doesn't work the same way as constructing other types: julia> @which tuple(1) ERROR: Ar

[julia-users] Re: Constructing tuples using Tuple

2015-07-10 Thread David Gold
For whatever reason, the relevant method isn't a type constructor: julia> tuple(1) (1,) On Friday, July 10, 2015 at 9:40:44 AM UTC-4, andrew cooke wrote: > > > sorry, more confusion... why doesn't this work? > > julia> Tuple{Int}(1) > ERROR: MethodError: `convert` has no method matching conver

Re: [julia-users] Type constructor for Arrays or Tuples

2015-07-10 Thread David Gold
@Tim, On that note, one would also want to amend the declaration of `MyArray` to `MyArray{T <: MyType}` in order that the type information about the `values` field be reflected in the type of the `MyArray` object, correct? On Friday, July 10, 2015 at 8:38:11 AM UTC-4, Tim Holy wrote: > > Off-to

[julia-users] Re: Environment reification and lazy evaluation

2015-07-08 Thread David Gold
Some of these issues have been thought about fairly extensively by the stats community in particular, precisely on account of the use cases you cite: https://github.com/JuliaStats/DataFrames.jl/pull/472 https://github.com/JuliaStats/DataFrames.jl/issues/504 I think that the matter is still very

[julia-users] Re: Efficient way to compute X' diag(w) Y

2015-07-08 Thread David Gold
Jutho & Andreas, thank you both for the resources. On Tuesday, July 7, 2015 at 3:42:52 PM UTC-4, Matthieu wrote: > > A lot of statistical algorithms require to compute X' diag(w) Y where X > and Y are two matrices and w is a vector of weight (Y may or may not equal > X). Is there a way to comput

Re: [julia-users] Re: Efficient way to compute X' diag(w) Y

2015-07-08 Thread David Gold
Andreas, do you know offhand which matrix multiplication algorithm OpenBLAS routine uses? On Wednesday, July 8, 2015 at 11:37:51 AM UTC-4, Andreas Noack wrote: > > It can be quite large. With > > julia> function mymul(A,B) >m, n = size(A, 1), size(B, 2) >C = promote_type(typeof(A)

[julia-users] Re: Any function to generate code in String from Expr?

2015-06-21 Thread David Gold
@Isaiah, Thank you for that resource. Shamelessly hijacking this topic a bit, do you know if there is any way to do something similar with the body of an anonymous function short of bushwacking through the AST object in its `code` field? I'd actually like to access just the body as an Expr obje

[julia-users] Re: Any function to generate code in String from Expr?

2015-06-21 Thread David Gold
Not sure if this is what you're looking for, but if you have a generic function, you can (kind of) pluck out the body of the specified method as follows: julia> f(x::Int) = x+5 f (generic function with 1 method) julia> e = code_typed(f, (Int,)) 1-element Array{Any,1}: :($(Expr(:lambda, Any[

[julia-users] Re: Object attributes // dispatch on extra attributes?

2015-06-20 Thread David Gold
For some inspiration on method caching, you might take a look at the `broadcast!` code: https://github.com/JuliaLang/julia/blob/master/base/broadcast.jl#L219. The body of the `broadcast!` function essentially asks, "Have I been asked to broadcast this function before? If so, have I been asked t

[julia-users] Re: How to install an unregistered package on a server?

2015-06-19 Thread David Gold
This may have nothing at all to do with the problem, but what version of Julia are you running on your PC? And what version is running on the server? It looks like the latter may be v0.2, which is fairly out-dated. On Friday, June 19, 2015 at 8:38:37 PM UTC-4, L. Caroline wrote: > > Hi everyone

[julia-users] Re: preferred syntax for creating empty vectors?

2015-06-19 Thread David Gold
I'm a fan of Array(Int, 0). You can also use this constructor to make empty n-dimensional arrays, if that's ever useful. On Friday, June 19, 2015 at 11:49:01 AM UTC-4, Seth wrote: > > > > I note that Int[] works in 0.3 and 0.4, but Vector{Int}() and > Array{Int,1}() were introduced at some poin

Re: [julia-users] Re: What's [] called? ie How do I refer to the array construction function?

2015-06-17 Thread David Gold
was wrong to say that concatenation in general doesn't go through a function. It probably does, just not always through getindex (sometimes vcat, typed_vcat, vect, etc). On Wednesday, June 17, 2015 at 10:15:00 AM UTC-4, David Gold wrote: > > However, it does look like this use pa

Re: [julia-users] Re: What's [] called? ie How do I refer to the array construction function?

2015-06-17 Thread David Gold
However, it does look like this use pattern does resolve to 'getindex', *julia> **dump(:( Int[1, 2, 3, 4] ))* Expr head: Symbol ref args: Array(Any,(5,)) 1: Symbol Int 2: Int64 1 3: Int64 2 4: Int64 3 5: Int64 4 typ: Any *julia> **getindex(Int, 1, 2, 3, 4)* *

Re: [julia-users] Re: What's [] called? ie How do I refer to the array construction function?

2015-06-17 Thread David Gold
The `getindex` explanation is not quite correct. Note, for instance, that Avik's example returns a 1-element array containing the tuple (1, 2, 3), not the 3-element array [1, 2, 3]. As far as *callable* objects are concerned, I think you probably want `vcat` (or 'hcat', depending on your case

Re: [julia-users] Re: Need help writing parallel code with @sync and @everywhere

2015-06-17 Thread David Gold
;) symbol("##v#8970") julia> v symbol("##v#8970") See: http://docs.julialang.org/en/latest/manual/metaprogramming/#hygiene On Wednesday, June 17, 2015 at 8:44:53 AM UTC-4, Daniel Carrera wrote: > > Wait #6#v is the name of a variable? How is that pos

[julia-users] Re: Need help writing parallel code with @sync and @everywhere

2015-06-17 Thread David Gold
Actually, it seems that @sync is also responsible for setting the variable #6#v equal to the return object of the call to Base.pfor and then returning #6#v after calling Base.sync_end(). On Wednesday, June 17, 2015 at 8:22:08 AM UTC-4, David Gold wrote: > > Have you tried macroexpandi

[julia-users] Re: Need help writing parallel code with @sync and @everywhere

2015-06-17 Thread David Gold
Have you tried macroexpanding the expression? Doing so yields julia> macroexpand(:( for i = 1:N @sync @parallel for j = (i + 1):N tmp[j] = i * j end end )) :(for i = 1:N # line 2:

[julia-users] Re: Index into an array with an IntSet

2015-06-15 Thread David Gold
`collect(myIntSet)` should also do it, I believe. On Monday, June 15, 2015 at 8:20:15 PM UTC-4, colint...@gmail.com wrote: > > Ah, I understand. Thanks for responding and pointing me to the appropriate > pull request. So currently if we want to index with an IntSet, the best > thing to do is pro

Re: [julia-users] Multiple lines statement?

2015-06-15 Thread David Gold
@Ben: as has been noted elsewhere in this thread, you can use parens to this end: julia> function foo(a, b, c, d, e, f) if (a > b || c > d || e > f) println("Foo for you.") end end foo (generic function with 1 method)

[julia-users] Re: How to know the size of a large array stored in a csv file (greater than RAM

2015-06-15 Thread David Gold
related: https://groups.google.com/forum/?hl=en#!searchin/julia-users/readcsv/julia-users/FmgkpF6ldk0/nmFGu5o87JsJ On Monday, June 15, 2015 at 9:38:31 AM UTC-4, Ian Hellström wrote: > > Would it be possible/feasible to introduce external data frames (like in > Revolution Analytics R), so that we

[julia-users] Re: How to Initialize a Composite Type

2015-06-15 Thread David Gold
Yes, though as Simon points out there is a good reason why it doesn't work. On Sunday, June 14, 2015 at 11:25:47 PM UTC-4, Ranjan Anantharaman wrote: > > @David, What doesn't work for you? Do you mean you're getting the same > error? > > On Monday, 15 June 2015 08:55:07 UTC+5:30, Ranjan Ananthara

[julia-users] Re: How to Initialize a Composite Type

2015-06-14 Thread David Gold
Nvm, totally doesn't work for me. On Sunday, June 14, 2015 at 7:40:56 AM UTC-4, Simon Danisch wrote: > > Julia is not object oriented, so you only put constructors inside the type > definition, which are then inner constructors. > Inner constructors overwrite the default constructor, so the funct

[julia-users] Re: How to Initialize a Composite Type

2015-06-14 Thread David Gold
@Simon that was my original thought, too. But, this actually works for me: julia> type foo a::Int64 function boss() println("Hey, boss!") end end julia> f = foo(1) foo(1) @Ranjan, what version of Julia are you using? On Sunday, June 14, 2015 at

Re: [julia-users] Method parameters and union types

2015-06-11 Thread David Gold
> Are you looking for the type-intersection perhaps? > > julia> typeintersect(Union(Int,Float64), Float64) > Float64 > > > On Thu, Jun 11, 2015 at 3:15 PM David Gold > wrote: > >> I want the following function >> >> function t_or_void{T}(::Ty

[julia-users] Method parameters and union types

2015-06-11 Thread David Gold
I want the following function function t_or_void{T}(::Type{Union(T, Void)}) return T end to work like this: julia> t_or_void(Union(Int, Void)) Int64 But in reality, it does this: julia> t_or_void(Union(Int, Void)) UnionType Is there a way to make this work, or a way to extract T from Unio

[julia-users] Re: map without creating a new array

2015-06-10 Thread David Gold
> effect, I want to replace this: > > for x in A; step1!(x); end > for x in A; step2!(x); end > for x in A; step3!(x); end > > with this: > > foreach(A, step1!, step2!, step3!) > > > > > > On Wednesday, June 10, 2015 at 10:06:39 AM UTC-4, David Gold wro

[julia-users] Re: map without creating a new array

2015-06-10 Thread David Gold
Pipe and map seem like related but orthogonal concepts; I don't know if they ought to be given the same operator. But I may just be looking at things wrongly. I'd sooner see a tricked-out array comprehension syntax. Something like ![ add_one(x) for x in A ] If the target array were ambiguous,

[julia-users] Re: Best Julian practices for a function with a set of options

2015-06-08 Thread David Gold
I've seen people define types for options. Maybe you could use type FunctionOptions{T, U, V} end Where T, U, V are bools. You could then define your function like function f(mainarg, optionarg = no_options_set) ... end where 'no_options_set' is an object of type FunctionOptions that represen

[julia-users] Re: Is it possible to change an object's type at runtime?

2015-06-07 Thread David Gold
Just in case there is another solution that may work within the confines of your application. On Sunday, June 7, 2015 at 6:01:14 PM UTC-4, andrew cooke wrote: > > > why do you ask? > > On Sunday, 7 June 2015 10:35:10 UTC-3, David Gold wrote: >> >> What is the applica

[julia-users] Re: Is it possible to change an object's type at runtime?

2015-06-07 Thread David Gold
What is the application in which you intend to use such a feature? On Saturday, June 6, 2015 at 6:49:53 PM UTC-4, andrew cooke wrote: > > > Is there any way to switch the "visible" type - the thing that is > dispatched on - at runtime? > > For example, you might think that a Union() could do this

Re: [julia-users] DataFrames' readtable very slow compared to R's read.csv when loading ~7.6M csv rows

2015-06-06 Thread David Gold
te: 25 seconds, 3.25% gc time > > Anyway, hopefully I'll get around to cleaning up CSV.jl to be released > officially, but it's that last 10-20% that's always the hardest to finish > up :) > > -Jacob > > > > On Mon, Jun 1, 2015 at 4:25 PM, David

  1   2   >