[julia-users] How to debug inlining wrong type:
I have an example that is along the lines of abstract Foo{T} Base.eltype{T}(::Foo{T})=T function foo(A::Foo) # assumes eltype(A) is a matrix and eltype(eltype(A)) is a number ret=Array(Foo{eltype(eltype(T))},0) push!(ret,anotherfunction(A)) end This is returning an error like expected Foo{Any}, got Foo{Float64} but this error only occurs when calling from command line, not line-by-line in Juno. My feeling is that eltype is being inlined incorrectly, but I have no idea how to debug it since its inconsistent. I can hack around it by splitting the command into two but its not ideal: function foo(AT::Type,A::Foo) ret=Array(Foo{AT},0) push!(ret,anotherfunction(A)) end foo(A::Foo)=foo(eltype(eltype(A)),A)
[julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
how close is this to what you need? *[@sprintf(%02d,i) for i = 1:99]*
Re: [julia-users] How to debug inlining wrong type:
Works for me. Are you sure the error isn't in anotherfunction? I just deleted that line and got no error. (There's also a typo, you need eltype(A) instead of eltype(T).) --Tim On Wednesday, May 20, 2015 12:33:39 AM Sheehan Olver wrote: I have an example that is along the lines of abstract Foo{T} Base.eltype{T}(::Foo{T})=T function foo(A::Foo) # assumes eltype(A) is a matrix and eltype(eltype(A)) is a number ret=Array(Foo{eltype(eltype(T))},0) push!(ret,anotherfunction(A)) end This is returning an error like expected Foo{Any}, got Foo{Float64} but this error only occurs when calling from command line, not line-by-line in Juno. My feeling is that eltype is being inlined incorrectly, but I have no idea how to debug it since its inconsistent. I can hack around it by splitting the command into two but its not ideal: function foo(AT::Type,A::Foo) ret=Array(Foo{AT},0) push!(ret,anotherfunction(A)) end foo(A::Foo)=foo(eltype(eltype(A)),A)
[julia-users] trying to do a simple parallel program with Julia
Hi ! I am trying to do a simple test of parallel computing with Julia. It is a program which read a dataframe and write the number of columns in a text file. I failed :/ The program gives the following error. If you have an idea how to solve it... Thanks in advance ;) $ julia main_parallel-001.jl exception on 3: ERROR: opening file tab2csv: Aucun fichier ou dossier de ce type in open at ./iostream.jl:117 in open at ./iostream.jl:125 in readtable at /home/fred/.julia/v0.3/DataFrames/src/dataframe/io.jl:889 in process_table at /archives/logiciels/julia/parallel-05.jl:7 in anonymous at multi.jl:855 in run_work_thunk at multi.jl:621 in anonymous at task.jl:855 exception on 2: ERROR: opening file tab2csv: Aucun fichier ou dossier de ce type in open at ./iostream.jl:117 in open at ./iostream.jl:125 in readtable at /home/fred/.julia/v0.3/DataFrames/src/dataframe/io.jl:889 in process_table at /archives/logiciels/julia/parallel-05.jl:7 in anonymous at multi.jl:855 in run_work_thunk at multi.jl:621 in anonymous at task.jl:855 ## # main program for parallel computing addprocs(4) require(parallel-05.jl) function main() # process_table(tab.csv)# give good result # process_table(tab2.csv) # give good result pmap(process_table,{tab.csv,tab2csv}) # does not work for tab2csv end main() ## # parallel-05.jl using DataFrames function process_table(title) sep='\t' myData = readtable(title ,separator=sep,header=false) m = size(myData,2) # number of columns file_name = string(processed_,title) outfile = open(file_name, w) write(outfile, $m$sep)# write the number of columns in outfile close(outfile) end
Re: [julia-users] Re: Symbolic relations package
Real (100% score in the course) usage: http://artai.co/Plasma.html
[julia-users] How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99) I need keep all digits on 2 positions 1 must be 01 10 must be 10 (I need compute on this and after save as Char) How define this format ? Paul
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: | *[@sprintf(%02d,i)fori =1:99]* |
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
In Julia you concatenate strings with * julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]*a[2] 0102 On Wednesday, May 20, 2015 at 10:05:08 AM UTC+2, paul analyst wrote: Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: *[@sprintf(%02d,i) for i = 1:99]*
[julia-users] Re: Tips on parallel performance?
In case it helps someone else, the issue was just cache contention and not an issue with Julia. See https://github.com/JuliaLang/julia/issues/11354 On Tuesday, May 19, 2015 at 12:34:51 PM UTC-4, Jason Morton wrote: Done On Tuesday, May 19, 2015 at 6:45:25 AM UTC-4, Viral Shah wrote: Please file an issue for this one. -viral On Monday, May 18, 2015 at 11:58:06 PM UTC+5:30, Jason Morton wrote: Working with a 16 core / 32 thread machine with 32GB ram that presents to ubuntu as 32 cores. I'm trying to understand how to get the best performance for embarrassingly parallel tasks. I want to take a bunch of svds in parallel as an example. The scaling seems to be perfect (6.6 seconds regardless of number of svds) until about 7 or 8 simultaneous svds, at which point it starts to creep up, scaling roughly linearly although with high variance, up to 22 seconds for 16 and 47 seconds for 31. I can confirm that the number of processors being used seems to equals the number getting pmapped over by watching htop, so I don't think openblas multithreading is the issue. Memory usage stays low. Any guess on what is going on? I'm using the generic linux binary julia-79599ada44. I don't think there should be any sending of the matrices but perhaps that is the issue. Probably I am missing something obvious. with nprocs = 16 @time pmap(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:16]) elapsed time: 22.350466328 seconds (12292776 bytes allocated) @time map(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:16]) elapsed time: 91.135322511 seconds (10269056672 bytes allocated, 2.57% gc time) with nprocs = 31 #perfect scaling until here (at 6x speedup) @time pmap(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:6]) elapsed time: 6.720786336 seconds (159168 bytes allocated) @time map(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:6]) elapsed time: 34.146665292 seconds (3847940044 bytes allocated, 2.46% gc time) #4.5x speedup @time pmap(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:16]) elapsed time: 19.819358972 seconds (391056 bytes allocated) @time map(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:16]) elapsed time: 90.688842475 seconds (10260844684 bytes allocated, 2.36% gc time) #3.69x speedup @time pmap(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:nprocs()]) elapsed time: 47.411315342 seconds (738616 bytes allocated) @time map(x-[svd(rand(1000,1000))[2][1] for i in 1:10],[i for i in 1:nprocs()]) elapsed time: 175.308752879 seconds (19880206220 bytes allocated, 2.34% gc time)
Re: [julia-users] Re: Generate polynomial expression on the fly
Have you read through this section of the docs? http://docs.julialang.org/en/release-0.3/manual/metaprogramming/ It's quite helpful on this topic. In particular, note that expressions consist of three building blocks: the head, the arguments, and the return type. Don't worry about the latter (return type) for now. Let's focus on the first two. The arguments are symbols or expressions out of which the target expression is built. The head provides the context in which the arguments interact. For your example, let's turn x^0 * y^1 * z^0 into an expression by *quoting* it with ':()' : julia expr = :(x^0 * y^1 * z^0) :(x^0 * y^1 * z^0) Here I've bound the above expression to the variable ex just for the sake of concision. We can use the dump() function to see the expression's building blocks, i.e. its head, arguments and return type: julia dump(expr) Expr head: Symbol call args: Array(Any,(4,)) 1: Symbol * 2: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol x 3: Int64 0 typ: Any 3: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol y 3: Int64 1 typ: Any 4: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol z 3: Int64 0 typ: Any typ: Any We see that ex consists of four arguments: the '*' symbol, and three expressions, i.e. :(x^0), :(y^1) and :(z^1). The head, symbol call, indicates that the first argument, *, is being called on the latter arguments. Having seen the structure of the target expression, we now have everything we need to build it up from scratch, i.e. just from the tuple (0, 1, 0). We first need to build the argument expressions :(x^0), :(y^1) and :(z^1). Let's take the first such expression as an example. To build expressions, we use the Expr() constructor: julia expr_x = Expr(:call, ^, :x, 0) :((^)(x,0)) The arguments passed to the constructor are the head, then the expression arguments. Note that the expression arguments are *symbols* -- ':x' means the symbol x. How did I know which head and arguments I needed in order to construct the right expression? I just looked above at the second argument of the original target expression: 2: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol x 3: Int64 0 typ: Any That gave me everything I needed to know. Similar for the y and z expressions. Here's how I would turn that all into a function that takes 3-tuples and spits out expressions: function makepowers(xpower::Int64, ypower::Int64, zpower::Int64) expr_powers = Expr(:call, *) dict_symbols = [:x=xpower, :y=ypower, :z=zpower] for symb in [:x, :y, :z] push!(expr_powers.args, Expr(:call, ^, symb, dict_symbols[ symb])) end return expr_powers end makepowers (generic function with 1 method) julia makepowers(0,1,0) :((*)((^)(x,0),(^)(y,1),(^)(z,0))) The resultant expression, though it looks a little different than expr above, is equivalent. We can check that it has given us the correct expression by evaluating it for definite values of x, y, z: julia x = 1 1 julia y = 5 5 julia z = 1 1 julia eval(makepowers(0,1,0)) 5 Hope this all helps. Once you're comfortable analyzing the constituents of an expression using dump() you can build pretty much any expression you like. On Wednesday, May 20, 2015 at 1:47:07 AM UTC-4, Júlio Hoffimann wrote: Hi Steven, I'm actually trying to pass in a matrix X and get out the associated Vandermonde-like matrix as numbers. I thought of expressions because the loop itself is not trivial, we have to deal with all those combinatorial indexing somehow. I have a code that generates the exponents of all the monomials as a tuple, but going from this tuple to the actual product is not clear to me. Let's say I have (0,1,0) meaning x^0*y^1*z^0 = y^1. How to do this conversion? Any trick? -Júlio
Re: [julia-users] Re: Generate polynomial expression on the fly
Sorry, should read Here I've bound the above expression to the variable *'expr'* just for the sake of concision. On Wednesday, May 20, 2015 at 9:55:12 AM UTC-4, David Gold wrote: Have you read through this section of the docs? http://docs.julialang.org/en/release-0.3/manual/metaprogramming/ It's quite helpful on this topic. In particular, note that expressions consist of three building blocks: the head, the arguments, and the return type. Don't worry about the latter (return type) for now. Let's focus on the first two. The arguments are symbols or expressions out of which the target expression is built. The head provides the context in which the arguments interact. For your example, let's turn x^0 * y^1 * z^0 into an expression by *quoting* it with ':()' : julia expr = :(x^0 * y^1 * z^0) :(x^0 * y^1 * z^0) Here I've bound the above expression to the variable ex just for the sake of concision. We can use the dump() function to see the expression's building blocks, i.e. its head, arguments and return type: julia dump(expr) Expr head: Symbol call args: Array(Any,(4,)) 1: Symbol * 2: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol x 3: Int64 0 typ: Any 3: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol y 3: Int64 1 typ: Any 4: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol z 3: Int64 0 typ: Any typ: Any We see that ex consists of four arguments: the '*' symbol, and three expressions, i.e. :(x^0), :(y^1) and :(z^1). The head, symbol call, indicates that the first argument, *, is being called on the latter arguments. Having seen the structure of the target expression, we now have everything we need to build it up from scratch, i.e. just from the tuple (0, 1, 0). We first need to build the argument expressions :(x^0), :(y^1) and :(z^1). Let's take the first such expression as an example. To build expressions, we use the Expr() constructor: julia expr_x = Expr(:call, ^, :x, 0) :((^)(x,0)) The arguments passed to the constructor are the head, then the expression arguments. Note that the expression arguments are *symbols* -- ':x' means the symbol x. How did I know which head and arguments I needed in order to construct the right expression? I just looked above at the second argument of the original target expression: 2: Expr head: Symbol call args: Array(Any,(3,)) 1: Symbol ^ 2: Symbol x 3: Int64 0 typ: Any That gave me everything I needed to know. Similar for the y and z expressions. Here's how I would turn that all into a function that takes 3-tuples and spits out expressions: function makepowers(xpower::Int64, ypower::Int64, zpower::Int64) expr_powers = Expr(:call, *) dict_symbols = [:x=xpower, :y=ypower, :z=zpower] for symb in [:x, :y, :z] push!(expr_powers.args, Expr(:call, ^, symb, dict_symbols[ symb])) end return expr_powers end makepowers (generic function with 1 method) julia makepowers(0,1,0) :((*)((^)(x,0),(^)(y,1),(^)(z,0))) The resultant expression, though it looks a little different than expr above, is equivalent. We can check that it has given us the correct expression by evaluating it for definite values of x, y, z: julia x = 1 1 julia y = 5 5 julia z = 1 1 julia eval(makepowers(0,1,0)) 5 Hope this all helps. Once you're comfortable analyzing the constituents of an expression using dump() you can build pretty much any expression you like. On Wednesday, May 20, 2015 at 1:47:07 AM UTC-4, Júlio Hoffimann wrote: Hi Steven, I'm actually trying to pass in a matrix X and get out the associated Vandermonde-like matrix as numbers. I thought of expressions because the loop itself is not trivial, we have to deal with all those combinatorial indexing somehow. I have a code that generates the exponents of all the monomials as a tuple, but going from this tuple to the actual product is not clear to me. Let's say I have (0,1,0) meaning x^0*y^1*z^0 = y^1. How to do this conversion? Any trick? -Júlio
Re: [julia-users] Convert DataArray to DataFrame
So I tried it this morning and it works for several sheets, but not for one. When I run this: f = openxl(Data.XLSX) test = readxl(DataFrame, f, Data!A1:C1885) I get the following error: NAException(Cannot convert DataArray with NA's to desired type) while loading In[3], in expression starting on line 2 in convert at C:\.julia\v0.3\DataArrays\src\dataarray.jl:561 in readxl_internal at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:214 in readxl at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:204 Any suggestions? Thanks. Brandon On Tuesday, May 19, 2015 at 7:28:59 PM UTC-4, David Anthoff wrote: Have you tried df = readxl(DataFrame, Filename.xlsx, Sheet1!A1:C4) That would return a DataFrame. Note that there is no readxlsheet that reads into a DataFrame (yet). The eventual API design I had in mind is that one can pass as a first argument the return type one desires. Right now the only option is DataFrame, otherwise it defaults to a DataArray. Cheers, David *From:* julia...@googlegroups.com javascript: [mailto: julia...@googlegroups.com javascript:] *On Behalf Of *Brandon Booth *Sent:* Tuesday, May 19, 2015 7:22 PM *To:* julia...@googlegroups.com javascript: *Subject:* [julia-users] Convert DataArray to DataFrame I feel like this should be simple to do, but I can't seem to do it. I'm using ExcelReaders and it imports as a DataArray whereas I'd like to have the data as a DataFrame. I didn't see anything in the approximately 375 pages of methods for convert. Thanks. Brandon
Re: [julia-users] Re: Generate polynomial expression on the fly
On Wednesday, May 20, 2015 at 1:47:07 AM UTC-4, Júlio Hoffimann wrote: I'm actually trying to pass in a matrix X and get out the associated Vandermonde-like matrix as numbers. Metaprogramming is almost certainly the wrong paradigm here... if you are thinking of generating an expression and calling eval in your function, then you are doing the wrong thing. You haven't precisely defined what you mean by Vandermonde-like matrix, though, so it's hard to give specific tips.
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
Big thx, but I need: 01*02=02 like 1*2=2 Paul W dniu 2015-05-20 o 14:21, Kristoffer Carlsson pisze: In Julia you concatenate strings with * | juliaa=[@sprintf(%02d,i)fori =1:99]; juliaa[1]*a[2] 0102 | On Wednesday, May 20, 2015 at 10:05:08 AM UTC+2, paul analyst wrote: Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: | *[@sprintf(%02d,i)fori =1:99]* |
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
You can convert the strings from Mr Walker's method using parseint() and then give (+) a new method: julia module Something export a, + a=[@sprintf(%02d,i) for i = 1:99] +(x::ASCIIString, y::ASCIIString) = a[parseint(x) + parseint(y)] end julia a[1] + a[2] ERROR: a not defined julia using Something julia a[1] + a[2] 03 On Wednesday, May 20, 2015 at 11:28:03 AM UTC-4, paul analyst wrote: Big thx, but I need: 01*02=02 like 1*2=2 Paul W dniu 2015-05-20 o 14:21, Kristoffer Carlsson pisze: In Julia you concatenate strings with * julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]*a[2] 0102 On Wednesday, May 20, 2015 at 10:05:08 AM UTC+2, paul analyst wrote: Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: *[@sprintf(%02d,i) for i = 1:99]*
[julia-users] Re: Some DataFrames questions
Indeed. Maybe the linq-style macro could be used to make that more readable, though perhaps just as lengthy: https://github.com/JuliaStats/DataFramesMeta.jl#alternative-linq-macro On Wednesday, May 20, 2015 at 12:25:09 PM UTC-4, Nils Gudat wrote: That seems to do the trick, although the syntax gets very messy very quickly - an example of replacing values in one column with those in another column, if three conditions are met: @where(df, array((:cond1).==0 (:cond2.==1) (:cond3.==1), false))[:col1] = @where(df, array((:cond1).==0 (:cond2.==1) (:cond3.==1), false))[:col2]
[julia-users] Re: Some DataFrames questions
I think I have to give up and grudgingly revert to pandas/R - I just tried to do this within a loop, dropping observations based on comparisons of a number of columns numbered by years with some transformations of other columns in the corresponding year. This is my (failed) attempt: for i = firstyear:lastyear @where(df, array((convert(Symbol, col1_*string(i)) .= 2*convert(Symbol, colx_*string(i))) | (convert(Symbol, col1_*string(i)) . 400*convert(Symbol, colx_*string(i))) | (convert(Symbol, col2_*string(i)) . 5000) | (convert(Symbol, col2_*string(i)) . 500), false))[:col] = NA end I think this is beyond salvation and maybe not really feasible with DataFrames at the moment. For comparison, this would be the Stata command: replace col`i'=. if col1_`i'= 2*colx_`i' | col1_`i' 400*colx_`i' | col2_`i' 5000 | col2_`i' 500 Of course a highly optimized software package like Stata is an unfair comparison, but still the difference is pretty striking...
[julia-users] Re: Some DataFrames questions
Re #1: Have you looked into the DataFramesMeta.jl experimental package? https://github.com/JuliaStats/DataFramesMeta.jl It may be able to help you, though I'm not sure. See in particular this issue: https://github.com/JuliaStats/DataFramesMeta.jl/issues/13. On Wednesday, May 20, 2015 at 11:17:28 AM UTC-4, Nils Gudat wrote: I have two questions regarding the usage of DataFrame: 1. How can I subset a DataFrame based on multiple criteria (similar to the pandas np.logical_and)? Consider: df = DataFrame(A = 1:3, B = 1:3) How do I get the subset of the DataFrame for which (for simplicity) A and B are 1? df[:A].==1 and df[:B].==1 give me boolean arrays, but I can't find any way of combining them to give me a single boolean mask - things like df[df[:A].==1 df[:B].==1] won't work, and my first idea of a workaround df[ (df[:A].==1 + df[:B].==1)==2 ] fails as well, as for some reason adding the two boolean arrays gives me false even for the first entry (which should be true+true). 2. How do I deal with NA's when indexing? Consider: df = DataFrame(A = 1:3, B = 1:3, C = @data([1,2,NA])) Here, df[df[:C].==1, :] fails with NAException(cannot index an array with a DataArray containing NA values). One way around this would be df[array(df[:C].==1, false), :] - is this the correct way of doing it or are there other indexing methods that automatically deal with NAs?
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
Mr. Wheeler beat me to it. Here's an example. julia module Something export a, + a=[@sprintf(%02d,i) for i = 1:99] +(x::ASCIIString, y::ASCIIString) = a[parseint(x) + parseint(y)] end julia using Something julia a[1] + a[2] 03 On Wednesday, May 20, 2015 at 4:05:08 AM UTC-4, paul analyst wrote: Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: *[@sprintf(%02d,i) for i = 1:99]*
[julia-users] Re: Some DataFrames questions
That seems to do the trick, although the syntax gets very messy very quickly - an example of replacing values in one column with those in another column, if three conditions are met: @where(df, array((:cond1).==0 (:cond2.==1) (:cond3.==1), false))[:col1] = @where(df, array((:cond1).==0 (:cond2.==1) (:cond3.==1), false))[:col2]
Re: [julia-users] Re: How to create own format with two digits 3=03, 10=10, 99=99 (only range 00:99)
Could you just cast your strings to normal integers, do your arithmetic, and then convert it back to a string with the necessary zero-padding? ``` @sprintf(%02d, int(01)*int(02)) ``` On Wednesday, May 20, 2015 at 8:28:03 AM UTC-7, paul analyst wrote: Big thx, but I need: 01*02=02 like 1*2=2 Paul W dniu 2015-05-20 o 14:21, Kristoffer Carlsson pisze: In Julia you concatenate strings with * julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]*a[2] 0102 On Wednesday, May 20, 2015 at 10:05:08 AM UTC+2, paul analyst wrote: Txh, but unfortunatly is not to compute julia a=[@sprintf(%02d,i) for i = 1:99]; julia a[1]+a[2] ERROR: MethodError: `+` has no method matching +(::ASCIIString, ::ASCIIString) Closest candidates are: +(::Any, ::Any, ::Any) +(::Any, ::Any, ::Any, ::Any...) I have in string data with time and i must compute changes only in on 2 last position table= 2015-01-01 2015-01-01 2015-01-12 I take last two digits int(table[i][9:10]) compute somthing and I must put the last two Chars Always i need 2 char '12' or '01' Paul W dniu 2015-05-20 o 09:57, Jeff Waller pisze: *[@sprintf(%02d,i) for i = 1:99]*
Re: [julia-users] Re: Generate polynomial expression on the fly
David, thank you very much for the detailed explanation, will read through it. Steven, sorry for not explaining the problem clearly. My issue is basically trying to figure out a way to loop over all possible combinations of exponents (e1, e2, e3) for which the sum is less or equal to N and generate a vector with the terms Xj[1]^e1*Xj[2]^e2*Xj[3]^e3. The j-th column of the resulting matrix contains the terms of this polynomial evaluated at the j-th column of X. -Júlio
Re: [julia-users] Re: High-performance metric collector in Julia
I was able to get 2M/sec without transactions, and 909K/sec with transactions (so it's durable), on my laptop, using Caché... (from InterSystems... I used to consult for them) They do have a free single user database engine, Globals, that you might be able to use... I don't recall what's available with that version... I suppose you got 2M/sec on some server with pretty high resources - I cannot imagine 2M network operations on my local machine. Anyway, I think I will start with Redis, which is more accessible from Julia both in terms of programming and openness. No, that's on my 1 year old MacBook Pro... with just the default database settings: Well, if they don't use any tricks like passing data through shared memory or heavy batching, then it's pretty impressive. But, as you mentioned, in this particular case Caché is not an option.
Re: [julia-users] Re: best way to traverse a binary tree
Hi Steven thanks for reply and your time¡¡¡ yes i use the built-in PriorityQueue, but not very well. As you mentioned I will try encoded on the fly(like the python code) Regards 2015-05-19 22:22 GMT-03:00 Steven G. Johnson stevenj@gmail.com: For this particular coding problem, I would use the built-in PriorityQueue or heap functions, rather than rolling your own tree data structure. See http://docs.julialang.org/en/latest/stdlib/collections/ and also the Python example on RosettaCode. (Basically, my feeling is that on RosettaCode you should try to put together the shortest readable code with reasonable performance, and that means exploiting the Julia standard library where possible.)
[julia-users] Re: Travis build failures, but Pkg.test() works?
On Wednesday, May 20, 2015 at 1:18:48 PM UTC-7, Tomas Lycken wrote: Just to make sure: what does Pkg.status() say about the package version? (are you on master or a tag?) Thanks. I'm on master. But the Travis build that's kicking off is also for master.
[julia-users] Re: Generate polynomial expression on the fly
Julio, I think Base.Cartesian will be helpful for this (in particular, @nloops and @nexprs): http://julia.readthedocs.org/en/latest/devdocs/cartesian/ One issue that will come up is if you do something like @nexprs 2 j-(i_j = 1), the 2 in there can't be a variable. You can work around this though by doing something like q = :( @nexprs replacethissymbol j-(i_j = 1) ) N = 10 replacesymbol!(q, :replacethissymbol, N) eval(q) where replacesymbol! is a function that traverses the expression q and replaces each instance of the symbol :replacethissymbol with the value of the variable N. I hope that helps! On Tuesday, May 19, 2015 at 11:24:04 AM UTC-6, Júlio Hoffimann wrote: Hi, Given an integer N = 0 and a m-by-n matrix X. Denote Xj the j-th column of X. How would you form the following matrix expression in Julia? result[:,j] = [ 1# order 0 term Xj[1] # order 1 terms Xj[2] Xj[3] . . . Xj[m] Xj[1]^2 # order 2 terms Xj[2]^2 . . . Xj[m]^2 Xj[1]*Xj[2] Xj[1]*Xj[3] Xj[2]*Xj[3] . . . Xj[m-1]*Xj[m] . . . Xj[1]*...*Xj[m] # order N terms ] I'm trying to get something similar to the Vandermonde matrix ( http://en.wikipedia.org/wiki/Vandermonde_matrix), but with additional mixed terms. I know Julia has some nice features for expression generation, can someone guide me through it? Regards, Júlio.
[julia-users] Travis build failures, but Pkg.test() works?
Just to make sure: what does Pkg.status() say about the package version? (are you on master or a tag?)
[julia-users] Re: Travis build failures, but Pkg.test() works?
There haven't been new Linux nightly builds for about 5 days, there was a power outage last week and there have been some lingering problems since then. Check the output of versioninfo from Travis. On Wednesday, May 20, 2015 at 1:18:48 PM UTC-7, Tomas Lycken wrote: Just to make sure: what does Pkg.status() say about the package version? (are you on master or a tag?)
Re: [julia-users] Re: Generate polynomial expression on the fly
Here's how I'd approach the problem, in pseudo-code: R = [] # This could be typed and pre-allocated with the proper length for i=1:N factors = combinations_with_replacement(Xj, i) for f in factors push!(R, prod(f)) end end The only trouble is that combinations_with_replacement function. I don't see a Julia version anywhere at the moment. See Python's itertools package: https://docs.python.org/2/library/itertools.html#itertools.combinations_with_replacement On Wednesday, May 20, 2015 at 2:22:59 PM UTC-4, Júlio Hoffimann wrote: David, thank you very much for the detailed explanation, will read through it. Steven, sorry for not explaining the problem clearly. My issue is basically trying to figure out a way to loop over all possible combinations of exponents (e1, e2, e3) for which the sum is less or equal to N and generate a vector with the terms Xj[1]^e1*Xj[2]^e2*Xj[3]^e3. The j-th column of the resulting matrix contains the terms of this polynomial evaluated at the j-th column of X. -Júlio
Re: [julia-users] Re: High-performance metric collector in Julia
On Wednesday, May 20, 2015 at 4:26:40 PM UTC-4, Andrei Zh wrote: Well, if they don't use any tricks like passing data through shared memory or heavy batching, then it's pretty impressive. But, as you mentioned, in this particular case Caché is not an option. I would say that *any* decent database does tricks like using shared memory... Aerospike does, I don't know about Redis... Caché has a large shared buffer pool... all processes can read or wrote B+ tree blocks via that buffer pool, and there are daemons that take care of making sure the journal is sync'ed to disk, that the blocks get out to disk every so often, etc.
[julia-users] Re: Some DataFrames questions
Whoops, should be for i in firstyear:lastyear for row in 1:n (df[row, :col1_*i] .= 2*(df[row, :colx_*i]) | df[row, :col1_*i] . 400*(df[row, :colx_*i]) | df[row, :col2_*i] . 5000) (df[row, :col_*i] = NA) end end On Wednesday, May 20, 2015 at 4:21:34 PM UTC-4, David Gold wrote: I don't think the @where macro will help you in this case, since it creates a new dataframe out of the selected subsets. If there is a way to use the macro as-is actually to modify the input dataframe, I don't see it. However, I don't know if you really need macros here. First, you can use string interpolation to avoid writing out (convert(Symbol, col1_*string(i)): julia i=1 1 julia symbol(col1_$i) :col1_1 We can do even better by defining a shorthand. * is used for string concatenation, so why not symbol concatenation? julia *(a::Symbol, i::Int)=symbol($a*$i) * (generic function with 133 methods) julia :col1_*i :col1_1 Now you can write a loop like the following, where n is the number of rows in df: for i in firstyear:lastyear for row in 1:n (df[:col1_*i] .= 2*(df[:colx_*i]) | df[:col1_*i] . 400*(df[:colx_*i]) | df[:col2_*i] . 5000) (df[row, :col_*i] = NA) end end Does that work for you? Let me know. I agree it's not as clean as the Stata version, but I don't think it's hopeless. Also, why do you have your year numbers in your column names? Maybe if you had a single Year column that would then determine values for col, col1, col2 and colx then you would be better off. On Wednesday, May 20, 2015 at 12:57:27 PM UTC-4, Nils Gudat wrote: I think I have to give up and grudgingly revert to pandas/R - I just tried to do this within a loop, dropping observations based on comparisons of a number of columns numbered by years with some transformations of other columns in the corresponding year. This is my (failed) attempt: for i = firstyear:lastyear @where(df, array((convert(Symbol, col1_*string(i)) .= 2*convert(Symbol, colx_*string(i))) | (convert(Symbol, col1_*string(i)) . 400*convert(Symbol, colx_*string(i))) | (convert(Symbol, col2_*string(i)) . 5000) | (convert(Symbol, col2_*string(i)) . 500), false))[:col] = NA end I think this is beyond salvation and maybe not really feasible with DataFrames at the moment. For comparison, this would be the Stata command: replace col`i'=. if col1_`i'= 2*colx_`i' | col1_`i' 400*colx_`i' | col2_`i' 5000 | col2_`i' 500 Of course a highly optimized software package like Stata is an unfair comparison, but still the difference is pretty striking...
Re: [julia-users] Winston package problem
Hi Massimo is only a warning or the plot does not appear?¿ Regards 2015-05-20 11:28 GMT-03:00 cameyo massimo.corinald...@regione.marche.it: Hi all, i have the following problem with REPL (Julia 0.3.8 - windows 7 64 bit): using Winston Warning: could not import Base.Text on Tk Can you help me? Massimo -- View this message in context: http://julia-programming-language.2336112.n4.nabble.com/Winston-package-problem-tp20206.html Sent from the Julia Users mailing list archive at Nabble.com.
Re: [julia-users] Re: Generate polynomial expression on the fly
Thank you Matt, I used itertools for similar problems in the past, will check it again. -Júlio
[julia-users] Re: Travis build failures, but Pkg.test() works?
Travis shows $ julia -e 'versioninfo()' Julia Version 0.4.0-dev+4850 and I'm on Version 0.4.0-dev+4911. On Wednesday, May 20, 2015 at 1:23:55 PM UTC-7, Tony Kelman wrote: There haven't been new Linux nightly builds for about 5 days, there was a power outage last week and there have been some lingering problems since then. Check the output of versioninfo from Travis. On Wednesday, May 20, 2015 at 1:18:48 PM UTC-7, Tomas Lycken wrote: Just to make sure: what does Pkg.status() say about the package version? (are you on master or a tag?)
Re: [julia-users] Re: Generate polynomial expression on the fly
Thanks Daniel, I remember Base.Cartesian from previous posts, will definitively check it. -Júlio
[julia-users] Re: trying to do a simple parallel program with Julia
Hi ! I found the bug : a dot was missing in pmap(process_table,{tab.csv,tab2csv}) instead of pmap(process_table,{tab.csv,tab2.csv}) The program works perfectly, I have to change my glasses 8-)
[julia-users] Selective dispatching on an Int
I want to implement some functionality in multiple methods and have the dispatch controlled by an Int variable N. The trick is I want one method to be called if N == 0 and another one to be called for all other values of N. Is there a way I can do this with Val{N} without making the method applicable to everything? That is, can I write a generic method func(::Val{N}) and constrain N to be an Int only?
[julia-users] Re: Some DataFrames questions
I don't think the @where macro will help you in this case, since it creates a new dataframe out of the selected subsets. If there is a way to use the macro as-is actually to modify the input dataframe, I don't see it. However, I don't know if you really need macros here. First, you can use string interpolation to avoid writing out (convert(Symbol, col1_*string(i)): julia i=1 1 julia symbol(col1_$i) :col1_1 We can do even better by defining a shorthand. * is used for string concatenation, so why not symbol concatenation? julia *(a::Symbol, i::Int)=symbol($a*$i) * (generic function with 133 methods) julia :col1_*i :col1_1 Now you can write a loop like the following, where n is the number of rows in df: for i in firstyear:lastyear for row in 1:n (df[:col1_*i] .= 2*(df[:colx_*i]) | df[:col1_*i] . 400*(df[:colx_*i]) | df[:col2_*i] . 5000) (df[row, :col_*i] = NA) end end Does that work for you? Let me know. I agree it's not as clean as the Stata version, but I don't think it's hopeless. Also, why do you have your year numbers in your column names? Maybe if you had a single Year column that would then determine values for col, col1, col2 and colx then you would be better off. On Wednesday, May 20, 2015 at 12:57:27 PM UTC-4, Nils Gudat wrote: I think I have to give up and grudgingly revert to pandas/R - I just tried to do this within a loop, dropping observations based on comparisons of a number of columns numbered by years with some transformations of other columns in the corresponding year. This is my (failed) attempt: for i = firstyear:lastyear @where(df, array((convert(Symbol, col1_*string(i)) .= 2*convert(Symbol, colx_*string(i))) | (convert(Symbol, col1_*string(i)) . 400*convert(Symbol, colx_*string(i))) | (convert(Symbol, col2_*string(i)) . 5000) | (convert(Symbol, col2_*string(i)) . 500), false))[:col] = NA end I think this is beyond salvation and maybe not really feasible with DataFrames at the moment. For comparison, this would be the Stata command: replace col`i'=. if col1_`i'= 2*colx_`i' | col1_`i' 400*colx_`i' | col2_`i' 5000 | col2_`i' 500 Of course a highly optimized software package like Stata is an unfair comparison, but still the difference is pretty striking...
Re: [julia-users] Re: Construct range with custom type
That particular error was just because the = operator was implemented and there was no fallback method to give an informative error. I sent in a PR to fix that: #11372 https://github.com/JuliaLang/julia/pull/11372. Beyond that, I managed to get it working by adding a couple more methods. It was a pain though because it would often crash or give some strange name instead of telling me which method had not been implemented. So I had to search through the Base code to see what was being called. Here is my full working code that is adapted from yours: import Base: show, convert, promote_rule, nextfloat, trunc, round, floor immutable JDate : FloatingPoint t::Float64 end show(io::IO, x::JDate) = print(io, JDate($(x.t))) convert(::Type{Float64}, x::JDate) = x.t convert{T:Integer}(::Type{T}, x::JDate) = T(x.t) convert{T:Real}(::Type{JDate}, x::T) = JDate(x) promote_rule(::Type{JDate}, ::Type{Float64}) = JDate promote_rule(::Type{JDate}, ::Type{Float32}) = JDate promote_rule(::Type{JDate}, ::Type{Int64}) = JDate (a::JDate,b::JDate) = (a.t,b.t) =(a::JDate,b::JDate) = =(a.t,b.t) +(a::JDate,b::JDate) = JDate(a.t + b.t) -(a::JDate,b::JDate) = JDate(a.t - b.t) -(a::JDate) = JDate(-a.t) /(a::JDate,b::JDate) = JDate(a.t / b.t) *(a::JDate,b::JDate) = JDate(a.t * b.t) nextfloat(a::JDate,b::Int64) = JDate(nextfloat(a.t, b)) round(a::JDate) = JDate(round(a.t)) trunc(::Type{Int64}, a::JDate) = trunc(Int64, a.t) floor(a::JDate) = JDate(floor(a.t)) rnge = JDate(1):0.5:JDate(2) println(rnge) println(collect(rnge)) Output: JDate(1.0):JDate(0.5):JDate(2.0) JDate[JDate(1.0),JDate(1.5),JDate(2.0)] Note that a couple of your methods were incorrect, like the / and * methods returning a Float64 object. On Tuesday, May 19, 2015 at 4:47:27 PM UTC-4, Chris wrote: I've been playing for a while now, and I'm hitting a wall. I decided to keep the FloatingPoint subtype, and step through and define all the necessary conversion/promotion rules, operations, etc. Here is what I have now: immutable JDate :FloatingPoint t::Float64 end convert(::Type{JDate}, x::Float64) = JDate(x) convert(::Type{JDate}, x::Int64) = JDate(float64(x)) convert(::Type{Float64}, x::JDate) = x.t convert(::Type{Int64}, x::JDate) = int64(x.t) promote_rule(::Type{JDate}, ::Type{Float64}) = JDate promote_rule(::Type{JDate}, ::Type{Int64}) = JDate (a::JDate,b::JDate) = (float64(a),float64(b)) +(a::JDate,b::JDate) = JDate(float(a.t) + float(b.t)) -(a::JDate,b::JDate) = float(a.t) - float(b.t) /(a::JDate,b::JDate) = /(float64(a),float64(b)) *(a::JDate,b::JDate) = *(float64(a),float64(b)) round(a::JDate) = JDate(round(float64(a))) nextfloat(a::JDate) = JDate(nextfloat(float64(a))) nextfloat(a::JDate,b::Int64) = JDate(nextfloat(float64(a),b)) Then, julia [j1:.5:j2] ERROR: stack overflow in = at promotion.jl:170 (repeats 8 times) Any insight into why this is happening? Thanks, Chris On Thursday, May 14, 2015 at 3:48:48 AM UTC-10, Josh Langsfeld wrote: If you do decide to keep it as a FloatingPoint subtype, you should probably go the other route of just making sure it interacts natively with the standard core operators, promote, convert, etc... Then the colon syntax should work automatically, returning a FloatRange{JDate} (which can become an Array{JDate,1} via collect()). On Wed, May 13, 2015 at 9:06 PM, Chris 7hunde...@gmail.com wrote: Now that you mention it, I think the only reason I made it a subtype of FloatingPoint was some (very) vague notion of type inference and performance. I will re-examine that decision now, I think. Thanks for your help. Chris On Wednesday, May 13, 2015 at 2:30:53 PM UTC-4, Josh Langsfeld wrote: Yeah, I missed that you were subtyping FloatingPoint before. It still worked ok for me though once I also defined colon methods suggested by the ambiguity warnings. in my case it was: colon(::JDate, ::JDate, ::JDate) colon(::JDate, ::FloatingPoint, ::JDate) colon(::JDate, ::Real, ::JDate) It seems to cause a lot of problems to subtype it as a FloatingPoint though, and I'm not sure what benefit you are getting out of it. For example, my installation won't even print a JDate value because it checks for finiteness first which requires subtraction to be defined. But I assume you can work around that by just defining enough methods of operators and promotion rules. On Wednesday, May 13, 2015 at 12:29:30 PM UTC-4, Chris wrote: What should the new method be, precisely? I tried colon(start::JDate, step::Real, stop::JDate) = JDate(colon(float64(start),step,float64(stop)) (I have conversion rules defined for the JDate to Float64 conversions), but I get several warning messages of the form: Warning: New definition colon(JDate,Real,JDate) at path\types.jl:25 is ambiguous with: colon(T:FloatingPoint,T:FloatingPoint,T:FloatingPoint) at range.jl:122. To fix, define colon(JDate,JDate,JDate) before the new definition.
[julia-users] Travis build failures, but Pkg.test() works?
Hi, I've got a problem with LightGraphs right now: Travis is reporting the build failing (see https://travis-ci.org/JuliaGraphs/LightGraphs.jl/jobs/63368942), relevant info copied below: Warning: both LightGraphs and Base export blkdiag; uses of it in module Main must be qualified ERROR: LoadError: LoadError: UndefVarError: blkdiag not defined in include at ./boot.jl:252 in include_from_node1 at loading.jl:134 in anonymous at no file:64 in include at ./boot.jl:252 in include_from_node1 at loading.jl:134 in process_options at ./client.jl:310 in _start at ./client.jl:409 while loading /home/travis/.julia/v0.4/LightGraphs/test/operators.jl, in expression starting on line 14 while loading /home/travis/.julia/v0.4/LightGraphs/test/runtests.jl, in expression starting on line 61 but Pkg.test(LightGraphs) works just fine in my 0-day-old master. How do I fix the Travis build issue?
[julia-users] Re: Selective dispatching on an Int
Ideally, I would like to write func{N::Int}(::Type{Val{N}) = N and get no-method errors if N is a float, symbol, etc... Has there been previous discussion on this topic? On Wednesday, May 20, 2015 at 5:28:26 PM UTC-4, Josh Langsfeld wrote: I want to implement some functionality in multiple methods and have the dispatch controlled by an Int variable N. The trick is I want one method to be called if N == 0 and another one to be called for all other values of N. Is there a way I can do this with Val{N} without making the method applicable to everything? That is, can I write a generic method func(::Val{N}) and constrain N to be an Int only?
[julia-users] Re: Interesting little syntax (not a bug, IMO, just a consequence of the way the parser works)
Now I can't get that to reproduce... I think this must have been a consequence of memory corruption, due to the bug I ran across with large tuples (issue #11330, nicely fixed by yuyichao, not very long after I reported it! [but too late to have saved me from this...]) On Tuesday, May 19, 2015 at 7:26:31 PM UTC-4, Scott Jones wrote: a !=0 # checks if a is not == to 0 a!= 0 # sets a! to 0 a!=0 # checks if a is not == to 0 Spaces are very important in Julia!
Re: [julia-users] Re: Selective dispatching on an Int
On Wed, May 20, 2015 at 6:43 PM, Josh Langsfeld jdla...@gmail.com wrote: Ideally, I would like to write func{N::Int}(::Type{Val{N}) = N and get no-method errors if N is a float, symbol, etc... Has there been previous discussion on this topic? According to this comment[1], this have been brought up but not yet implemented. [1] https://github.com/JuliaLang/julia/issues/9580#issuecomment-101539298 On Wednesday, May 20, 2015 at 5:28:26 PM UTC-4, Josh Langsfeld wrote: I want to implement some functionality in multiple methods and have the dispatch controlled by an Int variable N. The trick is I want one method to be called if N == 0 and another one to be called for all other values of N. Is there a way I can do this with Val{N} without making the method applicable to everything? That is, can I write a generic method func(::Val{N}) and constrain N to be an Int only?
[julia-users] Method ambiguity when defining new Number types
Dear julia users, When looking at e.g. BLAS functions, they have a general format of adding a scaled result array to an existing array, which itself can also be scaled; e.g. AB could be the result of a matrix multiplication of matrices A and B, and the BLAS gemm! function (using Julia's name) allows to store alpha*AB+beta*C into C. Looking at the high-performant microkernels of BLAS, they specialize on the different possibilities for alpha and beta using if constructions: if beta == 0 # do not actually compute C*0 since that could produce NaN if C was not initialized and contains NaN or infinity # instead set C to zero elseif beta != 1 # only scale C if beta is not 1 end if alpha == 1 # immediately add AB, do not scale with alpha else # C+=alpha * AB end In writing something related in Julia, I thought this would be a perfect case for dispatch. The high performant low level function could just contain the general statement C=beta*C+alpha*AB and it would be called in a high level function as (note that I am not actually trying to reimplement gemm!, this is just as an example) gemm!((beta == 1 ? _one : (beta == 0 ?_zero : beta)) , C, (alpha == 1 ?_one : alpha), A,B) in combination with the following definitions immutable Zero : Integer end immutable One : Integer end const _zero = Zero() const _one = One() Base.promote_rule{T:Number}(::Type{Zero}, ::Type{T}) = T Base.promote_rule{T:Number}(::Type{One}, ::Type{T}) = T Base.convert{T:Number}(::Type{T}, ::Zero) = zero(T) Base.convert{T:Number}(::Type{T}, ::One) = one(T) # add special rules, the most essential of which are: +(::Zero, a::Number) = a +(::Number, a::Zero) = a *(::Zero, a::Number) = _zero *(a::Number, ::Zero) = _zero *(::One, a::Number) = a *(a::Number, ::One) = a Unfortunately this produces a lot of ambiguity warnings. Of course I need to add the rules for +(::Zero,::Zero) etc, i.e. the interaction of my newly defined types with themselves. But this is not sufficient. The remaining addition and multiplication ambiguities can be avoided by defining them separately for a::Real and a::Complex. But the most difficult one is the convert definition, which is ambiguous with almost any other number type out there. I am aware of the many ambiguity related issues and the proposal to make those runtime errors instead of warnings, but I have the feeling that there might be a more specific solution for what I am trying to accomplish and that I am missing something trivial. I know there are several other number types defined in packages, and I assume the corresponding authors must have faced similar problems? So I appreciate any tips or input.
[julia-users] IDE Julia
IDE Julia como cuando Anaconda o Spyder ?? Sería el factor determinante para la expansión del lenguaje de programación.
[julia-users] Re: IDE Julia
En general, escribimos en ingles en esta lista. Has probado Juno? -- John On Wednesday, May 20, 2015 at 3:33:08 PM UTC-7, perico garcia wrote: IDE Julia como cuando Anaconda o Spyder ?? Sería el factor determinante para la expansión del lenguaje de programación.
Re: [julia-users] Re: Construct range with custom type
Wow, thanks for the effort you put in, I really appreciate it. Wanted to give you some feedback. I tried copy/pasting your code into the REPL (v0.3.8), and got a segfault: julia rnge = JDate(1):0.5:JDate(2) signal (11): Segmentation fault: 11 _ZNK4llvm5Value10getContextEv at /Applications/Julia-0.3.8.app/Contents/Resources/julia/lib/julia/libjulia.dylib (unknown line) _ZNK4llvm11Instruction15getMetadataImplENS_9StringRefE at /Applications/Julia-0.3.8.app/Contents/Resources/julia/lib/julia/libjulia.dylib (unknown line) _ZNK4llvm11Instruction11getMetadataENS_9StringRefE at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./cgutils.cpp:645 _ZL13emit_getfieldP11_jl_value_tP9_jl_sym_tP12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:1442 _ZL15emit_known_callP11_jl_value_tPS0_mP12jl_codectx_tPPN4llvm5ValueEPP14_jl_function_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2050 _ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2204 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2669 _ZL12emit_unboxedP11_jl_value_tP12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2774 _ZNK4llvm5Value7getTypeEv at /Users/vagrant/buildbot/slave/package_osx10_9/build/usr/include/llvm/IR/Value.h:108 _ZL15emit_known_callP11_jl_value_tPS0_mP12jl_codectx_tPPN4llvm5ValueEPP14_jl_function_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2050 _ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2204 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2669 _ZL12emit_unboxedP11_jl_value_tP12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./intrinsics.cpp:203 _ZL14emit_intrinsicN4JL_I9intrinsicEPP11_jl_value_tmP12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./intrinsics.cpp:957 _ZL15emit_known_callP11_jl_value_tPS0_mP12jl_codectx_tPPN4llvm5ValueEPP14_jl_function_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:1583 _ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2204 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2669 _ZL12emit_unboxedP11_jl_value_tP12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./intrinsics.cpp:203 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2662 _ZL13emit_functionP17_jl_lambda_info_tb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:3864 _Z19jl_eh_restore_stateP13_jl_handler_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./julia.h:1176 jl_compile at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:657 jl_get_specialization at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/gf.c:1352 _ZL15emit_known_callP11_jl_value_tPS0_mP12jl_codectx_tPPN4llvm5ValueEPP14_jl_function_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:1608 _ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2204 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2669 _ZL15emit_assignmentP11_jl_value_tS0_P12jl_codectx_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2486 _ZL13emit_functionP17_jl_lambda_info_tb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:3864 _Z19jl_eh_restore_stateP13_jl_handler_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./julia.h:1176 jl_compile at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:657 jl_get_specialization at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/gf.c:1352 _ZL15emit_known_callP11_jl_value_tPS0_mP12jl_codectx_tPPN4llvm5ValueEPP14_jl_function_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:1608 _ZL9emit_callPP11_jl_value_tmP12jl_codectx_tS0_ at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2204 _ZL9emit_exprP11_jl_value_tP12jl_codectx_tbb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:2669 _ZL13emit_functionP17_jl_lambda_info_tb at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:3837 _Z19jl_eh_restore_stateP13_jl_handler_t at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/./julia.h:1176 jl_compile at /Users/vagrant/buildbot/slave/package_osx10_9/build/src/codegen.cpp:657 jl_trampoline at
[julia-users] Julia tutorial in Singapore, June 5
Prof. Alan Edelman and I will be presenting a half day Julia tutorial in University Town, Singapore on June 5. The Julia tutorial will be held as part of a full day workshop on emerging high performance cloud computing technologies. Also presenting will be Prof. Saman Amarasinghe, who will be presenting about OpenTuner, an extensible framework for program autotuning. The workshop is free but registration is required. Sign up at http://tinyurl.com/JuliaOpenTuner At this time of writing, over 2/3 of the tickets have been allocated. Interested Julia users are encouraged to sign up soon.
[julia-users] Re: Julia tutorial in Singapore, June 5
Any chance you guys can make a stop in Hong Kong? :) On Thursday, May 21, 2015 at 12:16:45 PM UTC+8, Jiahao Chen wrote: Prof. Alan Edelman and I will be presenting a half day Julia tutorial in University Town, Singapore on June 5. The Julia tutorial will be held as part of a full day workshop on emerging high performance cloud computing technologies. Also presenting will be Prof. Saman Amarasinghe, who will be presenting about OpenTuner, an extensible framework for program autotuning. The workshop is free but registration is required. Sign up at http://tinyurl.com/JuliaOpenTuner At this time of writing, over 2/3 of the tickets have been allocated. Interested Julia users are encouraged to sign up soon.
Re: [julia-users] Convert DataArray to DataFrame
Yep, there was a blank in the first row that I hadn't noticed. Thanks again. On Wednesday, May 20, 2015 at 10:31:13 AM UTC-4, David Anthoff wrote: I think that means you are reading an area where there is an empty cell in the first row of the range. The first row is used for the column names of the DataFrame, and so it can’t have an empty cell in it. Two possible ways out: - Make sure there are no empty cells in the first row of the range you are reading. - Change the range you read to A2:C1885, and then manually provide the names for the columns. Either by passing an array of symbols as colnames, or by passing header=false (in which case you will get auto created colnames) Best, David *From:* julia...@googlegroups.com javascript: [mailto: julia...@googlegroups.com javascript:] *On Behalf Of *Brandon Booth *Sent:* Wednesday, May 20, 2015 10:12 AM *To:* julia...@googlegroups.com javascript: *Subject:* Re: [julia-users] Convert DataArray to DataFrame So I tried it this morning and it works for several sheets, but not for one. When I run this: f = openxl(Data.XLSX) test = readxl(DataFrame, f, Data!A1:C1885) I get the following error: NAException(Cannot convert DataArray with NA's to desired type) while loading In[3], in expression starting on line 2 in convert at C:\.julia\v0.3\DataArrays\src\dataarray.jl:561 in readxl_internal at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:214 in readxl at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:204 Any suggestions? Thanks. Brandon On Tuesday, May 19, 2015 at 7:28:59 PM UTC-4, David Anthoff wrote: Have you tried df = readxl(DataFrame, Filename.xlsx, Sheet1!A1:C4) That would return a DataFrame. Note that there is no readxlsheet that reads into a DataFrame (yet). The eventual API design I had in mind is that one can pass as a first argument the return type one desires. Right now the only option is DataFrame, otherwise it defaults to a DataArray. Cheers, David *From:* julia...@googlegroups.com [mailto:julia...@googlegroups.com] *On Behalf Of *Brandon Booth *Sent:* Tuesday, May 19, 2015 7:22 PM *To:* julia...@googlegroups.com *Subject:* [julia-users] Convert DataArray to DataFrame I feel like this should be simple to do, but I can't seem to do it. I'm using ExcelReaders and it imports as a DataArray whereas I'd like to have the data as a DataFrame. I didn't see anything in the approximately 375 pages of methods for convert. Thanks. Brandon
[julia-users] Some DataFrames questions
I have two questions regarding the usage of DataFrame: 1. How can I subset a DataFrame based on multiple criteria (similar to the pandas np.logical_and)? Consider: df = DataFrame(A = 1:3, B = 1:3) How do I get the subset of the DataFrame for which (for simplicity) A and B are 1? df[:A].==1 and df[:B].==1 give me boolean arrays, but I can't find any way of combining them to give me a single boolean mask - things like df[df[:A].==1 df[:B].==1] won't work, and my first idea of a workaround df[ (df[:A].==1 + df[:B].==1)==2 ] fails as well, as for some reason adding the two boolean arrays gives me false even for the first entry (which should be true+true). 2. How do I deal with NA's when indexing? Consider: df = DataFrame(A = 1:3, B = 1:3, C = @data([1,2,NA])) Here, df[df[:C].==1, :] fails with NAException(cannot index an array with a DataArray containing NA values). One way around this would be df[array(df[:C].==1, false), :] - is this the correct way of doing it or are there other indexing methods that automatically deal with NAs?
RE: [julia-users] Convert DataArray to DataFrame
I think that means you are reading an area where there is an empty cell in the first row of the range. The first row is used for the column names of the DataFrame, and so it can’t have an empty cell in it. Two possible ways out: - Make sure there are no empty cells in the first row of the range you are reading. - Change the range you read to A2:C1885, and then manually provide the names for the columns. Either by passing an array of symbols as colnames, or by passing header=false (in which case you will get auto created colnames) Best, David From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On Behalf Of Brandon Booth Sent: Wednesday, May 20, 2015 10:12 AM To: julia-users@googlegroups.com Subject: Re: [julia-users] Convert DataArray to DataFrame So I tried it this morning and it works for several sheets, but not for one. When I run this: f = openxl(Data.XLSX) test = readxl(DataFrame, f, Data!A1:C1885) I get the following error: NAException(Cannot convert DataArray with NA's to desired type) while loading In[3], in expression starting on line 2 in convert at C:\.julia\v0.3\DataArrays\src\dataarray.jl:561 in readxl_internal at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:214 in readxl at C:\.julia\v0.3\ExcelReaders\src\ExcelReaders.jl:204 Any suggestions? Thanks. Brandon On Tuesday, May 19, 2015 at 7:28:59 PM UTC-4, David Anthoff wrote: Have you tried df = readxl(DataFrame, Filename.xlsx, Sheet1!A1:C4) That would return a DataFrame. Note that there is no readxlsheet that reads into a DataFrame (yet). The eventual API design I had in mind is that one can pass as a first argument the return type one desires. Right now the only option is DataFrame, otherwise it defaults to a DataArray. Cheers, David From: julia...@googlegroups.com javascript: [mailto:julia...@googlegroups.com javascript: ] On Behalf Of Brandon Booth Sent: Tuesday, May 19, 2015 7:22 PM To: julia...@googlegroups.com javascript: Subject: [julia-users] Convert DataArray to DataFrame I feel like this should be simple to do, but I can't seem to do it. I'm using ExcelReaders and it imports as a DataArray whereas I'd like to have the data as a DataFrame. I didn't see anything in the approximately 375 pages of methods for convert. Thanks. Brandon
[julia-users] Winston package problem
Hi all, i have the following problem with REPL (Julia 0.3.8 - windows 7 64 bit): using Winston Warning: could not import Base.Text on Tk Can you help me? Massimo -- View this message in context: http://julia-programming-language.2336112.n4.nabble.com/Winston-package-problem-tp20206.html Sent from the Julia Users mailing list archive at Nabble.com.