Re: [julia-users] Signature for function accepting array of parameterised types

2016-02-02 Thread Mauro
uliaLang/julia/issues/6984. But function signatures may change quite a bit in the near future anyway, see for instance: https://github.com/JuliaLang/julia/issues/11310#issuecomment-170421099 > S. > > On Tuesday, 2 February 2016 06:27:10 UTC, Mauro wrote: >> >> On

Re: [julia-users] am i prepared for the arraypocalypse?

2016-02-02 Thread Mauro
ous tupocalypse, when a tuple-type overhaul lead to a few breakages: https://github.com/JuliaLang/julia/search?utf8=%E2%9C%93=tupocalypse=Issues https://github.com/JuliaLang/julia/search?q=tupocolypse=Issues=%E2%9C%93 > On Tuesday, February 2, 2016 at 1:28:26 AM UTC-5, Mauro wrote: >> >&

Re: [julia-users] Parametric Type Question - updating type

2016-02-02 Thread Mauro
ing all the cached fields, like nvp below, is very error prone. It is probably better to have it immutable to just make a new instance once the PricingEngine changes. > On Tue, Feb 2, 2016 at 1:49 AM, Mauro <mauro...@runbox.com> wrote: > >> I haven't been following this thread

Re: [julia-users] Range is not Array, Why?

2016-02-01 Thread Mauro
Ranges are a more compact representation of vectors with evenly spaced elements: julia> xdump(1:5:1000) StepRange{Int64,Int64} start: Int64 1 step: Int64 5 stop: Int64 996 i.e. it only uses 3 numbers instead of 200 (for this example). Anyway, you should be able to use a range just like

Re: [julia-users] Parametric Type Question - updating type

2016-02-01 Thread Mauro
I haven't been following this thread closely, so I have no frame of reference here, I'm like a child who wanders into the middle of a julia-users thread... A few observations: - functions being called with composite types which have some non-concrete fields suffer no performance penalty, as

Re: [julia-users] Signature for function accepting array of parameterised types

2016-02-01 Thread Mauro
On Mon, 2016-02-01 at 18:29, Samuel Powell wrote: > Hi, > > Consider the following: > > abstract TypeA > > type Type1 <: TypeA > end > > type Type2 <: TypeA > end > > type Type3{T<:TypeA} > prof::T > end > > function fun(arr::Array{Type3, 1}) > end > > t1 = Type1() > t2 =

Re: [julia-users] am i prepared for the arraypocalypse?

2016-02-01 Thread Mauro
> my tests run smoothly in the current build of julia 0.5 beta. Is everything > good or are there breaking changes to come? There are always breaking changes to come on Master... that's the point of Master. Expect more to come, as the arraypocalypse has not happened yet (nor it is quite clear

Re: [julia-users] Anonymous functions now faster? Need for functors?

2016-01-31 Thread Mauro
> Hi, > > I just saw this merged PR . > > In the past I used the functor trick of defining a type, and then a call > method for the type, and passing this to a function, to get past the > anonymous function inefficiency. > > Does this PR mean (to a

Re: [julia-users] Julia version mismatch

2016-01-29 Thread Mauro
You have do to a make cleanall and recompile. Happened to me, it's on github somewhere. On Fri, 2016-01-29 at 17:55, Sisyphuss wrote: > I have this problem: > > When I type > Julia --version > > it shows that I am in 0.4.2-pre > > But when I enter the Julia REPL, > I

Re: [julia-users] how to i get number of arguments of a function?

2016-01-28 Thread Mauro
> Wow, thanks a lot, That one I would never had a chance to figure out. It's easy enough, you could figure it out yourself too, knowing just a few tricks. The essentials are here: http://docs.julialang.org/en/release-0.4/devdocs/reflection/ plus the tools: xdump, @less, @edit, @which. In fact,

Re: [julia-users] Julia vs Clojure for Distributed Scientific Simulations

2016-01-27 Thread Mauro
On Wed, 2016-01-27 at 20:34, Joshua Ballanco wrote: > One last point (something I’ve been meaning to look at but haven’t had > the time): reading CSV files off disk was about 10x faster in Clojure > than Julia. Something else to consider. I think this package makes this much

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Mauro
suggest that an immutable type (singular or array) may actually be > worse in this scenario ? > > On Tuesday, January 26, 2016 at 12:03:19 AM UTC-8, Mauro wrote: >> >> > I assume from mutate you mean not changing type of the sub-variable (e.g >> > "vstate"

Re: [julia-users] Immutable vs. Mutable composite types: Trying to understand performance and memory allocations

2016-01-26 Thread Mauro
> I assume from mutate you mean not changing type of the sub-variable (e.g > "vstate" above) ? I plan to change the values inside that vector but the > vector itself, both in length and type, will remain constant. Yes, then I'd use immutable. However, I don't think it will improve performance

Re: [julia-users] What does `type X Int,Int end` do?

2016-01-26 Thread Mauro
Related discussion in: https://github.com/JuliaLang/julia/issues/9443 On Tue, 2016-01-26 at 01:58, Erik Schnetter wrote: > I didn't know that you can write > ```Julia > type B > i::Int > b(x)=2x > B(x)=new(b(x)) > end > ``` > and thus get a very private function

Re: [julia-users] how to i get number of arguments of a function?

2016-01-22 Thread Mauro
> Is it also possible to get a list of names of the variables used in a > function? > > e.g. for > > function f(x,y) > k=0.1 > return x*y+k > end > > I'd like to get a list ["k","x","y"] > > My first thought was to make a method f() that returns this list, but if > its possible to do this

Re: [julia-users] Ambiguous methods warnings for DataFrames and Images

2016-01-21 Thread Mauro
It's a known wart: https://github.com/JuliaLang/julia/issues/6190 But as far as I recall that issue thread, no solution has been found yet. On Thu, 2016-01-21 at 13:32, cormull...@mac.com wrote: > Just wondering if there's a solution in the future for this trivial but > mildly irritating

Re: [julia-users] Type of composite type

2016-01-21 Thread Mauro
Maybe you can adapt this: julia> type Outer{T} A::T B::T end julia> Outer{TT}(a::TT, b::TT) = Outer{TT}(a,b) Outer{T} ## the first {TT} is a function type parameter whereas the second {TT} ## is the type parameter! Very confusing julia> Outer(5,6)

Re: [julia-users] Re: Euler Maruyama for neural networks, slower than python

2016-01-21 Thread Mauro
On my system Julia is also ~4x faster than Python, so it seems that this is mainly a problem with the BLAS library. Did you build Julia yourself or are you using binaries? I see some improvements (20%) using an in-place sig function and some other bits. Together with Pablo's trick this halfs

Re: [julia-users] numpy vs julia benchmarking for random matrix-vector multiplication

2016-01-21 Thread Mauro
> Silly me... > > I was using python anaconda and it seems to be user more than one process... No, OpenBLAS used by Julia should also use several threads. You can change the number of threads like so: ~/julia/tmp >> export OPENBLAS_NUM_THREADS=2 ~/julia/tmp >> julia5 tt.jl I actually get the

Re: [julia-users] Issue with return values from subtypes

2016-01-21 Thread Mauro
you mean why the second errors: julia> Irrational Irrational{sym} julia> Irrational{sym} ERROR: UndefVarError: sym not defined ? Irrational is all that is needed. Would this help: julia> Irrational{TypeVar(:T)} Irrational{T} On Thu, 2016-01-21 at 19:21, Scott Jones

Re: [julia-users] Re: Optimizing Function Injection in Julia

2016-01-21 Thread Mauro
> Guys, it's killing me having to wait hours until my posts are approved. Once you get fully approved by the moderators, your post will go through immediately (most of the time). > (Ability to edit would be nice as well.. Although it looks like I can edit > all of my posts save for the

Re: [julia-users] Re: Examples of integrating Fortran code in Julia

2016-01-19 Thread Mauro
Welcome to Julia! You probably shouldn't necromance such an old thread, instead make a new one and link to the old ones you researched. Anyway, in the old thread, I linked to a blog post of mine on this topic (I just saw that its formatting was all messed up: now fixed):

Re: [julia-users] Dictionary lookup using only the hash value

2016-01-13 Thread Mauro
No, this is not possible. Dicts use the function Base.hashindex to convert a hash into an index into the internal storage arrays (one for keys, one for values, one a bool stating whether used or not, see [1]). However, collisions are likely. For instance, 1 and 18 map to the same index for a

Re: [julia-users] Re: ANN: A potential new Discourse-based Julia forum

2016-01-12 Thread Mauro
I second Tamas: a good email interface is a must. This seems to be lacking currently: https://meta.discourse.org/t/email-interface-suggested-improvements/32140 On Tue, 2016-01-12 at 11:32, Tamas Papp wrote: > On Tue, Jan 12 2016, DNF wrote: > >> Hmm, I didn't consider that. I

Re: [julia-users] Defining function's argument to be either Int or Float

2016-01-10 Thread Mauro
riance_and_contravariance_%28computer_science%29#Arrays >> > Hi Mauro, > > Thanks for the link. That does explain it in the sense that I now know > Vector is invariant in Julia, but that begs the question, can we specify a > constructor to be covariant or contravarian

Re: [julia-users] Defining function's argument to be either Int or Float

2016-01-09 Thread Mauro
> It would be interesting to learn why this is the case because I would think > it should be. Have you read through the, I think linked, wikipedia article? You only need to read the Array section: https://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29#Arrays > To

Re: [julia-users] Re: multiple methods with keyword arguments?

2016-01-06 Thread Mauro
> OK, so that is the long way to do it. > I just thought that, since multiple dispatch does not work on keyword > arguments, they should by definition be the same for all methods, no? > Otherwise you end up with keyword arguments throwing an error because the > type of a different argument

Re: [julia-users] Overriding the = operator

2016-01-05 Thread Mauro
You can't! On Tue, 2016-01-05 at 10:18, Julia Tylors wrote: > Hi, > > How can i override the = operator? > > Thanks > > function ={T}(x::T,y::T) > ... > end > > didn't work > > Thanks

Re: [julia-users] How to get untemplated typename?

2016-01-04 Thread Mauro
This should do the trick: Foo.name.primary (I think this defeats type inference, so try not to use it in performance critical code) On Mon, 2016-01-04 at 11:31, Sheehan Olver wrote: > If I have a type > > ```julia > immutable Foo{D} > x::D > end > > f=Foo(5) > ``` > > >

Re: [julia-users] Why SimpleVector / svec?

2016-01-04 Thread Mauro
As far as I understand: svecs are simple indexable containers; they are used in bootstrap before arrays are defined. Once arrays are defined they are not really useful anymore and thus not intended as a datatype for public consumption. Still, they should get some documentation as one can stumble

Re: [julia-users] Imitating scanf

2016-01-03 Thread Mauro
> function testparse() > parse("4.123456789") > end Try: function testparse() parse(Float64, "4.123456789") end I get 100x speedup. > @time testparse() > @time for i=1:1 > testparse() > end > Running this on the same machine takes about 0.65 seconds. I get similar > results

Re: [julia-users] Cumulative Profiling

2016-01-01 Thread Mauro
> It might also be worth trying out the DevTools.jl profiler: > https://github.com/JunoLab/DevTools.jl A poor man's version of the functionality in the last image in DevTools's readme is: https://github.com/mauro3/ProfileFile.jl Running this julia> @profile f(10^7); julia> using ProfileFile

Re: [julia-users] Setting values of composite types using metaprogramming

2015-12-29 Thread Mauro
You could use the @pack macro from Parameters.jl: @pack ec.title: show, zlevel, z which is equivalent to your ec.title.show = show ec.title.zlevel = zlevel ec.title.z = z Otherwise use `setfield!`: function f(t;kws...) for (s,v) in kws setfield!(t, s, v) end end On Tue,

Re: [julia-users] Setting values of composite types using metaprogramming

2015-12-29 Thread Mauro
Cool. I find the companion macro @unpack super handy too for functions which take as arguments types with many fields. Instead of: show = ec.title.show zlevel = ec.title.zlevel z = ec.title.z do @unpack ec.title: show, zlevel, z Mauro On Tue, 2015-12-29 at 21:16, Randy Zwitch <randy.

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-29 Thread Mauro
I think Scott meant a type union: julia> Union{Int,Float64} Union{Float64,Int64} julia> Int<:ans true which is itself a type. On Tue, 2015-12-29 at 00:53, Ismael VC wrote: > I thougt one advantage of using sets would be the ability to use set > operations, but they

Re: [julia-users] Using MATLAB error

2015-12-28 Thread Mauro
This works for me: julia> using MATLAB julia> x=[1,2,3] 3-element Array{Int64,1}: 1 2 3 julia> @mput x A MATLAB session is open successfully on 0.3 and 0.4.1 (with lots of deprecation warnings) @mxput does not exist: julia> @mxput x ERROR: UndefVarError: @mxput not defined So, as cdm

Re: [julia-users] solve method error?

2015-12-20 Thread Mauro
You'll get better help if you include a minimal not-working example for people to copy-paste. (Also, output from the REPL is better pasted as text than as image). Also, your function call seems odd: no need to do a type assertion with `::` in the function arguments. On Sun, 2015-12-20 at 20:37,

Re: [julia-users] PyPlot and Latex labels using a variable

2015-12-15 Thread Mauro
`latexstring` is what you're looking for. Have a look at the readme of https://github.com/stevengj/LaTeXStrings.jl Example: latexstring("an equation: \$1 + \\alpha^2\$") On Tue, 2015-12-15 at 14:26, Štěpán Starosta wrote: > Hi, > > this works for me > > using PyPlot

Re: [julia-users] PyPlot and Latex labels using a variable

2015-12-15 Thread Mauro
On Tue, 2015-12-15 at 22:00, Yichao Yu <yyc1...@gmail.com> wrote: > On Tue, Dec 15, 2015 at 3:54 PM, Mauro <mauro...@runbox.com> wrote: >>>> Example: >>>> >>>> latexstring("an equation: \$1 + \\alpha^2\$") >>> >>>

Re: [julia-users] PyPlot and Latex labels using a variable

2015-12-15 Thread Mauro
>> Example: >> >> latexstring("an equation: \$1 + \\alpha^2\$") > > I think for PyPlot it works equally well without `latexstring` since > pyplot will handle that directly. Sorry that was a bad example without interpolation. But the original example needs latexstring, no? julia> s =

Re: [julia-users] binary string to hex

2015-12-04 Thread Mauro
This works: julia> a = 0b1010 0xaf julia> parse("0b"*bin(a)) 0xaf but maybe there are better ways. On Fri, 2015-12-04 at 13:33, Martin Somers wrote: > Just wondering binary to hex > a = 0b1010 > bin(a) > "1010" > > this results in a string that can be

Re: [julia-users] Re: InexactError for Arrays

2015-12-03 Thread Mauro
> Thanks, yes, but I had expected that in the second command it would give me > an Int64 Array, This would mean that multiplying a Int32 array by a Int64 would double its size and be considerably slower. If the array is large, then that could be problematic. > similar as in the 1st command I

Re: [julia-users] ANN: DSGE.jl

2015-12-03 Thread Mauro
Their write-up of their transition from Matlab to Julia is a nice read too: https://github.com/FRBNY-DSGE/DSGE.jl/blob/master/doc/MatlabToJuliaTransition.md Adding to that: I found myself that MATLAB.jl can make the migration easier as then it can be done step by step: just call the not yet

Re: [julia-users] getindex for a real number

2015-11-30 Thread Mauro
Your welcome. Your recollection is wrong though, this was possible in 0.2 and 0.3; I just checked (I don't have a 0.1 build but maybe I should...). On Mon, 2015-11-30 at 22:25, Ehsan Eftekhari <e.eftekh...@gmail.com> wrote: > Thanks Mauro. As you predicted, my question was about the

Re: [julia-users] How to create array wrapper with constrains on type and number of dimensions

2015-11-30 Thread Mauro
> I'm trying to do something like this (which doesn't compile in its current > form): > > type ArrayWrapper{T,N,AT <: AbstractArray{T,N}} <: AbstractArray{T,N} >arr::AT{T,N} > end > > That is: > >- wrapper around any type AT inherited from AbstractArray{T,N} >- wrapper should be itself

Re: [julia-users] getindex for a real number

2015-11-30 Thread Mauro
As it says, there is no method for it. You could add it yourself: Base.getindex(f::Float64, ::Colon) = f # or whatever you like However, the philosophical question is: should you be allowed to index into a float (or int)? Julia usually puts convenience before strictness and allows this. I'm

Re: [julia-users] How to create array wrapper with constrains on type and number of dimensions

2015-11-30 Thread Mauro
rayWrapper{T,N,AT<: > AbstractArray{T,N}}(...), > since type constructors fall back to convert methods. > Closest candidates are: > call{T}(::Type{T}, ::Any) > convert{T}(::Type{T}, ::T) > in call at essentials.jl:57 > > Moving constructor outside type definition does

Re: [julia-users] Concatenation without splatting

2015-11-23 Thread Mauro
> That doesn’t quite seem to do what you want, Mauro: Yes, you're right, sorry for the noise! > julia> arr_of_arr = Vector{Int}[[1],[2,3],[4,5]] > 3-element Array{Array{Int64,1},1}: > [1] > [2,3] > [4,5] > > julia> vcat_nosplat(y) = eltype(y[1])[el[1] for el

Re: [julia-users] Best way to pass many arguments to functions

2015-11-23 Thread Mauro
This is for what I put https://github.com/mauro3/Parameters.jl together. Give it a spin! - allows fields with default values - constructors for constructing new instances from old ones with some changes - packing and unpacking macros to save on typing Example: using Parameters @with_kw

Re: [julia-users] Concatenation without splatting

2015-11-22 Thread Mauro
In ODE.jl, I've used vcat_nosplat(y) = eltype(y[1])[el[1] for el in y] # Does vcat(y...) without the splatting I think the eltype might not be needed. There may be better ways though. On Sun, 2015-11-22 at 14:04, Cedric St-Jean wrote: > I have a big vector of

Re: [julia-users] OffsetArrays (Fortran-style indexing)

2015-11-20 Thread Mauro
Probably best to file a bug report. (It is a bit odd that it doesn't work for 0.3.12, presumably it used to work for earlier 0.3 versions.) On Thu, 2015-11-19 at 23:08, Ted Wetherbee wrote: > OffsetArrays, as per its package example, is missing arrayset in 3.12, also > not

Re: [julia-users] Re: indexing with non Integer Reals is deprecated

2015-11-17 Thread Mauro
y3y9JEMra8/9xqvoy_xd6YJ) I think, the devs have found good middle ground in their design of Julia so far. As Julia is evolving, discussions on these topics are important (although not at infinitum...). Mauro On Tue, 2015-11-17 at 12:14, Christoph Ortner <christophortn...@gmail.com> w

[julia-users] Julia #1 on Hacker News

2015-11-15 Thread Mauro
The Moore Foundation's sponsorship of Julia is currently #1 on Hacker News: https://news.ycombinator.com/item?id=10565940 Thanks to Mike for posting!

Re: [julia-users] Moore foundation grant.

2015-11-11 Thread Mauro
In case it is not just me who didn't spot the news, here it is: https://www.moore.org/newsroom/in-the-news/2015/11/10/bringing-julia-from-beta-to-1.0-to-support-data-intensive-scientific-computing Nice! On Wed, 2015-11-11 at 09:00, Viral Shah wrote: > Yes, we are really

Re: [julia-users] filter() & anonymous function

2015-11-05 Thread Mauro
> 1) Is filter an effictient way for doing this ? I assume yes (optionally > using an inplace version filter!() may be advantageous). If you need speed you may need to look into FastAnonymous to define your function. If this is not a bottleneck, then don't bother. > 2) It was surprising to me

Re: [julia-users] Re: Confused about doc strings and macros

2015-10-31 Thread Mauro
Have a look at: https://github.com/JuliaLang/julia/pull/13006 I'm not sure it has been backported yet to 0.4 On Sat, 2015-10-31 at 14:55, andrew cooke wrote: > gah, sorry. linked to the wrong macro package. i don't think this is > particularly relevant, but it should have

Re: [julia-users] Enums in Julia

2015-10-30 Thread Mauro
for @enum: enum1 = MyEnum(f11,f12) enum2 = MyEnum(f21,f22) But it seems a bit strange to have an enumeration which uses two values, as an enumeration suggests that there is a mapping to the integers! Mauro On Fri, 2015-10-30 at 09:37, Eric Forgy <eric.fo...@gmail.com> wrote: > I am

Re: [julia-users] functions on iterable types

2015-10-25 Thread Mauro
> An iterable type is obtained by defining start, next and end methods for > such a type. > Is there a way to obtain the list of all functions that work on iterable > types? No, that is not possible at the moment. Interfaces/traits are implicit in Julia (for now) and it is not (easily) possible

Re: [julia-users] A question of Style: Iterators into regular Arrays

2015-10-21 Thread Mauro
I'd argue that this should work: julia> rand(4,4)*(1:4) ERROR: MethodError: `A_mul_B!` has no method matching A_mul_B!(::Array{Float64,1}, ::Array{Float64,2}, ::UnitRange{Int64}) i.e. ranges should be equivalent to column vectors. But others more knowledgeable on the linear algebra code may

Re: [julia-users] Does anyone have a fork/branch of Sundials.jl that works on 0.4/0.5?

2015-10-16 Thread Mauro
The ODE.jl solvers work with 0.4/0.5 (or if not, report and they will be updated), but presumably you use Sundials.jl because ODE.jl isn't good enough yet. Anyway, it's probably best to file a issue with Sundials.jl. Oh, it's there already: https://github.com/JuliaLang/Sundials.jl/issues/54 On

Re: [julia-users] julia newb seeks critique of a "Defstruct" clone macro

2015-10-14 Thread Mauro
> You might consider supporting full type declaration syntax, i.e.: > > @defwithvals type emp > age=0 > salary=1 > end > > (Though perhaps this is what Mauro's Parameters.jl package does?) Yes (and extra bits)

Re: [julia-users] julia newb seeks critique of a "Defstruct" clone macro

2015-10-14 Thread Mauro
I don't think there is much documentation for Julia-macros around but if you know LISP then you're ahead in the game anyway. So it's mostly learning by looking at other folk's macros: My package https://github.com/mauro3/Parameters.jl does something similar to your example. So you could have a

Re: [julia-users] Re: Does annotating values with abstract data type help?

2015-10-11 Thread Mauro
> Sorry. I wanted to say AbstractInt not Int. `Integer` is the abstract datatype. Anyway the answer is: no, it does not help. To make fast code Julia must know the memory layout of a type, which can only be known for a concrete type. > Then will this abstract annotation help? > > On Sunday,

Re: [julia-users] How to have type parameters T less than Array{AbstractFloat} in the covariant sense?

2015-10-09 Thread Mauro
This is called triangular dispatch and is not currently supported. But it may be in the future: https://github.com/JuliaLang/julia/issues/8974 On Fri, 2015-10-09 at 23:17, cheng wang wrote: > Hello everyone, > > In Julia, T < Array{AbstractFloat} does not mean T in

Re: [julia-users] PSA: New package registration requirements

2015-10-01 Thread Mauro
Thanks! Maybe this should go into METADATA.jl Readme, or into the docs? On Thu, 2015-10-01 at 08:28, Jiahao Chen wrote: > Hello package developers, > > Please note our new policies for accepting entries into METADATA.jl, which > take effect immediately: > >1. New packages

Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-09-30 Thread Mauro
> I, on the other hand, don't understand the obsession with abstraction. I guess reasons to use a high-level language differ, which is good. As long as we don't get too obsessive ;-) > Also, by your argument the following should all be special types rather > than box-standard arrays. > > julia>

Re: [julia-users] Nicer syntax collect(linspace(0,1,n))?

2015-09-30 Thread Mauro
I don't understand this obsession with wanting to store a bunch of numbers in memory which trivially compress. Even more so as most numerical computations are memory bound, so storing more stuff is bad. All the interface functions work with a range (or if not a bug report should be filed), apart

Re: [julia-users] Options fail with Julia 0.4?

2015-09-30 Thread Mauro
Unless someone else knows a fix, could you to put together a small test case and file an issue with Options.jl? On Wed, 2015-09-30 at 18:33, Jan Kybic wrote: > Hello, >after switching to from Julia 0.3 to Julia 0.4 (release > candidate 3), the Options package

Re: [julia-users] Help with a macro

2015-09-30 Thread Mauro
> Hello everyone, > > I am trying to write a macro that transforms an expression like: > > @foo v[1,2] + v[1,3]*v[2,4] -> v[I[1,2]] + v[I[1,3]]*v[I[2,4]] > > Basically, for each getindex I want to insert a lookup of the index in some > other variable. > The reason for this is that I am working

Re: [julia-users] metaprogramming, building full Expr

2015-09-30 Thread Mauro
The easiest and usually best way is to use quotes and interpolate into them: fname = :f1 :($fname(x::Int) = x+31) But that does not always work. Then you have to resort to manipulating expressions which is a bit complicated. xdump is your friend. Also note that you can construct them like so:

Re: [julia-users] Help with a macro

2015-09-30 Thread Mauro
= quote > $f_exp > $e > end > return f_exp > end Yes, this will create nested begin-end blocks. also note that `:().head==:tuple`. Try: exps = initiate(e::Expr) f_exp = quote end append!(f_exp.args, exps) push!(f_exp.args, e) > macro v(e) > v

Re: [julia-users] Help with a macro

2015-09-30 Thread Mauro
rices stored as vectors of length 6 and unsymmetric 3x3 matrices stored > as vectors of length 9. > > As I know you do some FEM Mauro I can describe my problem more > specifically. I am writing a package do more easily deal with Voigt tensors > and I want to add the option of accessin

Re: [julia-users] Passing Array{Array{T,N},1} to a function

2015-09-29 Thread Mauro
I don't think that you need nor that you should use generated functions. But maybe I'm wrong, what are you trying to achieve? This should work as you want: function testfun2!{N}(X,Y::NTuple{N,Float64}) for i in eachindex(X), j in 1:N # much better to have the loop this way X[i][j] =

Re: [julia-users] Passing Array{Array{T,N},1} to a function

2015-09-29 Thread Mauro
ld change depending on some parameter, say the dimensionality of an array. > Thanks, Alan > > > was just an illustration of a the larger piece of code where I am making using > On 29 Sep 2015, at 13:48, Mauro <mauro...@runbox.com> wrote: > >> I don't think that you

Re: [julia-users] Passing Array{Array{T,N},1} to a function

2015-09-29 Thread Mauro
> Thanks Mauro - really useful to know. So it seems that in this > particular instance the number of nested loops does change with N, so > I think the code would fall into the latter case. Sorry, I wasn't clear: no, only the number of iterations would change. With numbers of nested loop

Re: [julia-users] Is there a way to define abstract type from a type in base.jl

2015-09-25 Thread Mauro
Julia's parametric types are invariant (except tuples). To figure out what that means have a read through http://docs.julialang.org/en/release-0.4/manual/types/#parametric-composite-types > How to make Array{BigFloat,1}<:Array{Real,1}? This is always false (that is invariance). But presumably

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

2015-09-25 Thread Mauro
> Marcio: crowdfunded julia packages is a really awesome idea... is there a > platform for this already for other languages? or should we create one? > > On Fri, Sep 25, 2015 at 9:47 AM, Marcio Sales > wrote: > >> all right... Well.. Julia's price will allways be

Re: [julia-users] @code_warntype and for loops

2015-09-24 Thread Mauro
>> This is the lowered and typed abstract syntax tree that you're seeing, >> so two steps removed from what you've typed already (and another two >> steps to go to get to machine code). Thus it gets more verbose. I >> guess it would be nice to translate this typed code back to what you >> wrote

Re: [julia-users] Re: Same native code, different performance

2015-09-24 Thread Mauro
I dissected the bench-method into two, just to be sure (on 0.4-RC2). julia> function bench(N) for i = 1:N f(π/4) end end bench (generic function with 1 method) julia> function bench_f(N) for i = 1:N f_float(π/4) end

Re: [julia-users] @code_warntype and for loops

2015-09-23 Thread Mauro
> Thank you, Kristoffer. I have read the manual and your post about not > getting carried away by the red == bad assumption > . > Yet, for a for loop, one would not expect so

Re: [julia-users] Why does type inference not work for cat? (0.4-rc1)

2015-09-22 Thread Mauro
After looking into this, I think this may be tricky to avoid. But yes, possibly a bug or certainly a feature to improve on. One of the culprits is the following expression inside the cat function: [isa(x,AbstractArray) ? eltype(x) : typeof(x) for x in X] Checking this: f2(X...) =

Re: [julia-users] Check if type "contains" Any

2015-09-21 Thread Mauro
You can access the type parameters with T.parameters. Have a look at https://github.com/mbauman/Tuples.jl. Also note possible complications with vararg types. However, doing this for non-tuple types this is probably a sign of bad design as was recently discussed here:

Re: [julia-users] When does colon indexing get evaluated / converted?

2015-09-21 Thread Mauro
I seem to recall that this was discussed recently, probably by Matt, but cannot find it. I did however find this gist: https://gist.github.com/alsam/8283205, maybe of help. On Mon, 2015-09-21 at 06:38, 'Greg Plowman' via julia-users wrote: > To further clarify, I

Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
> The indices need to all be independent since otherwise you’d end up > producing an array with some rows/columns being of different length, which > isn’t supported by Julia’s Array{T, N}. That’s fine for a loop since for i > = 1:3, j = 1:i isn’t trying to fill up an array directly though.

Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
> Thanks all! I can now see what I was attempting makes no sense with the > array comprehension and why I needed a nested solution. If you end up using it like so: vcat([[zeros(Int, k) for n = 1:binomial(J, k)] for k = 1:K]...) then have a look at https://github.com/mbauman/RaggedArrays.jl >

Re: [julia-users] Re: What's your favourite editor?

2015-09-21 Thread Mauro
> Thanks for all the replies. Having previously tried Sublime, Atom and > LightTable I've spent the year learning Vim and have now switched to Emacs > (evil-mode). > > I'd be grateful to hear from other emacs users regarding your workflows for > Julia development, e.g. if you want to write a

Re: [julia-users] Re: Array of vectors of variable number and lengths

2015-09-21 Thread Mauro
I think this is a limitation of list comprehensions: julia> [(i,j) for i=1:3, j=1:i] ERROR: i not defined in anonymous at no file but doing the loop works: julia> for i=1:3, j=1:i @show i,j end (i,j) => (1,1) (i,j) => (2,1) (i,j) => (2,2) (i,j) => (3,1) (i,j) => (3,2) (i,j) =>

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

2015-09-20 Thread Mauro
> As an interim step, you can also get text profiling information using > Profile.print() if the graphics aren't working. You could also try https://github.com/mauro3/ProfileFile.jl which writes the profile numbers into a file *.pro. Similar to the memory and coverage files. > On Sunday,

Re: [julia-users] planned array changes

2015-09-18 Thread Mauro
> Is there some syntactic sugar planned for Any arrays, in the spirit of > {}? Not as far as I know, but Any[] is pretty short.

Re: [julia-users] Emacs, ESS and julia-mode

2015-09-18 Thread Mauro
>>> >>>>> >>>>> If that looks right, I'll try to add that. >>>>> >>>>> On Thursday, September 17, 2015 at 2:33:29 PM UTC+1, Andrei Zh wrote: >>>>>> >>>>>> ESS mode's integration with

Re: [julia-users] Emacs, ESS and julia-mode

2015-09-18 Thread Mauro
> ob-julia works for me, with Julia 0.3.11. I haven't tried 0.4 yet. I was using 0.4, and I think that did indeed cause some problems.

Re: [julia-users] Re: Get the inferred type of a function call given input argument types only

2015-09-18 Thread Mauro
Is that better than Base.return_types ? On Fri, 2015-09-18 at 14:36, Michael Francis wrote: > function returns(f, types) > rt = [] > if( !isdefined(f, :code) ) > for x in Base._methods(f,types,-1) > linfo = x[3].func.code > (tree, ty) =

Re: [julia-users] Re: opencv python api in Julia

2015-09-18 Thread Mauro
> Wait, so how does this work. Doesn't the license just cover the > implementation? or is the underlying abstract algorithm covered by it? Just the implementation. But by looking at the code you look at the implementation. So, it's ok to look at pseudo-code in a paper (even if that paper is

Re: [julia-users] Re: opencv python api in Julia

2015-09-18 Thread Mauro
September 2015 16:37:59 UTC+2 schrieb Christof Stocker: >> >> Thank god, almost got a heart attack there. I am just looking at the >> papers in my efforts >> >> On 2015-09-18 16:32, Mauro wrote: >> > Just the implementation. But by looking at the code yo

Re: [julia-users] elements' ordering in a set

2015-09-17 Thread Mauro
Sets are based on dictionaries (just the keys no values) and in their current implementation the insertion order is not preserved. There are oredered Sets in https://github.com/JuliaLang/DataStructures.jl On Wed, 2015-09-16 at 22:52, Michela Di Lullo wrote: > Hello

Re: [julia-users] Emacs, ESS and julia-mode

2015-09-17 Thread Mauro
Well, help is not a function in 0.4 anymore. Use ?Pkg.init Can't help with the other ESS things. I've tried it for a bit but it introduced a noticeable lag so I switch back to just using julia-mode.el On Thu, 2015-09-17 at 14:32, Michael Turok wrote: > Anyone here

Re: [julia-users] Allowed module names

2015-09-17 Thread Mauro
No, a minus is a minus On Thu, 2015-09-17 at 15:09, Ján Dolinský wrote: > Hello, > > Is a module name consisting of minus sign allowed ? > E.g. my-new-module > > typing > > using my-new-module > > results in an error > ERROR: syntax: invalid "using" statement > >

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Mauro
outside of foo >> function dostuff(..., ::Type{Spearman}) >> # do spearman specific stuff >> end >> function dostuff(..., ::Type{Pearson}) >> # do pearson specific stuff >> end >> function dostuff(..., ::Type{Kendall}) >># do ken

Re: [julia-users] constrain arguments in function

2015-09-15 Thread Mauro
No, Julia only dispatches on types not on values. The latter sometimes goes under the name of pattern matching. There is a package for that: https://github.com/toivoh/PatternDispatch.jl On Tue, 2015-09-15 at 10:15, Michael Borregaard wrote: > Is there a way in julia to

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

2015-09-12 Thread Mauro
ood feedback for Tuples.jl. > -erik > > On Fri, Sep 11, 2015 at 4:02 PM, Mauro <mauro...@runbox.com> wrote: > >> The interface Matt is prototyping for Tuple{}'s >> https://github.com/mbauman/Tuples.jl >> could (should?) be expanded for any type-parameters. (Or

<    1   2   3   4   5   6   7   >