Re: [julia-users] Nonlinear system solution with Julia's Sundial.jl package and `Kinsol` warning

2015-05-14 Thread Mauro
Have a look at the description in https://computation.llnl.gov/casc/sundials/documentation/kin_guide/node5.html On Wed, 2015-05-13 at 23:04, Pileas wrote: > Hello all, > > I'm trying to solve a system of equations using the Sundials package for > Julia. > > The code is the following: > > #=

Re: [julia-users] solving large system of complex nonlinear ODEs

2015-05-07 Thread Mauro
nts. > > On Thursday, May 7, 2015 at 7:12:40 AM UTC+2, Mauro wrote: >> >> > Any suggestions for solving a nonlinear system of ~1000 coupled ODEs >> with >> > complex coefficients? >> >> Try your luck with the ODE solvers: ODE.jl, DASSL.jl and Sund

Re: [julia-users] can someone please explain Type{Float64} <: DataType <: Type

2015-05-07 Thread Mauro
Here is my understanding of Type. Beware though, it might be completely wrong!!! `Type` in itself is just an ordinary abstract type: julia> typeof(Type) DataType julia> super(Type) Any and DataType is a subtype of it julia> subtypes(Type) 3-element Array{Any,1}: DataType TypeConstru

Re: [julia-users] Asking for generic-data-type definition advice

2015-05-06 Thread Mauro
Have a read through http://docs.julialang.org/en/release-0.3/manual/performance-tips/ Basically, the fields should have a concrete type if used in performance critical code. Otherwise, no annotations are fine. Note that there is not performance gain from annotating with non-concrete types (like

Re: [julia-users] solving large system of complex nonlinear ODEs

2015-05-06 Thread Mauro
> Any suggestions for solving a nonlinear system of ~1000 coupled ODEs with > complex coefficients? Try your luck with the ODE solvers: ODE.jl, DASSL.jl and Sundials.jl. For sundials you will probably have to split the equations into real and imaginary part.

Re: [julia-users] Re: Compilation time

2015-05-06 Thread Mauro
>> For instance your first nzval update could be: >> >> locs = Vector{Int}[[-1, 18, 63, 103], >> [1, 63], >> [1, 18], >> ... >> ] >> function update_nzval!(nzval, v, locs) >> for i =1:length(locs) >> nzval[i] = 0 >> for j=2:

Re: [julia-users] Re: Compilation time

2015-05-06 Thread Mauro
On Wed, 2015-05-06 at 18:25, Stéphane Mottelet wrote: > As I already answered to Steven, these matrices are not just "data" > because their elements change at each iteration of an optimization > process. So i need "code" to update the matrices. Anything you can achieve with metaprogramming you

Re: [julia-users] Issues with tout,yout=ODE.ode4((t,x)->functionName(t,x),t,x) in julia version 0.3.6

2015-05-06 Thread Mauro
Can you provide a self-contained, running test example? Also, there is no need for the anonymous function here: tout,yout=ODE.ode4(functionName,t,x) On Wed, 2015-05-06 at 19:02, Lytu wrote: > I have issues with : > tout,yout=ODE.ode4((t,x)->functionName(t,x),t,x) > it gives the error: BoundsErr

Re: [julia-users] Re: Compilation time

2015-05-06 Thread Mauro
> Yes, this seems like a severe abuse of the compiler. It makes much more > sense for this to be input as data rather than code. Nonetheless, 4.7 seconds compilation time for one function seems a lot. Ok, it is 2000 lines long but pretty simple. What causes this? > On Wed, May 6, 2015 at 8:42 AM

Re: [julia-users] Re: Compilation time

2015-05-06 Thread Mauro
This looks like JIT compiler performance issue to me. Unless someone else more knowledgeable comments you should consider filing an issue. In the meantime, you could try to re-write your code to use loops instead of explicitly unrolling everything. That might increase overall performance even tho

Re: [julia-users] Immutable type creation from array

2015-05-02 Thread Mauro
> Yeah thanks, figured there was a simple solution, is this being > affected by the big tuple/vararg overhaul? You're welcome, and no, I don't think it should be affected. > On 2 May 2015 at 14:37, Mauro wrote: >> Splat the fields? >> >> function mutateimmut

Re: [julia-users] typealias constructors

2015-05-02 Thread Mauro
You need to be on 0.4 to do this. On Sat, 2015-05-02 at 20:40, Krishna Subramanian wrote: > I would like to know how to do something like this- > typealias Corpus Array{Int,1} > > and write a constructor for it. Currently, if I do - > > Corpus() = Array(Int,0) > > I get- > > ERROR: cannot define

Re: [julia-users] Immutable type creation from array

2015-05-02 Thread Mauro
ields=getargs(c) >mutate!(fields) >if length(fields)==1 > return typeof(c)(fields[1]) >elseif length(fields)==2 > return typeof(c)(fields[1],fields[2]) >#etc... >end > end > > On 2 May 2015 at 12:43, Mauro wrote: >> Maybe some pseudo code wou

Re: [julia-users] Immutable type creation from array

2015-05-02 Thread Mauro
Maybe some pseudo code would make understanding your problem easier? On Sat, 2015-05-02 at 10:34, Marcus Appelros wrote: > This is the use case: abstract Component with a getargs(c::Component) that > returns an array with the fields of components, for concreteness lets say a > Der type with the

Re: [julia-users] Re: Scope of variables in julia

2015-04-30 Thread Mauro
On Thu, 2015-04-30 at 18:37, Tom Breloff wrote: > I actually wonder if the bug is that Versions 1 and 4 *should* produce an > error, but they secretly work. In your version 1: > > for i=1:2 > if i>=2; println(z); end > z="Hi" > end > > z should be local to each iteration of the loop,

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

2015-04-30 Thread Mauro
>> Can anyone point me in the right direction of the files/functions in the >> core library where dispatch is handled? I'd like to explore a little so I >> can make comments that account for the relative ease at implementing some >> of the changes suggested. >> > > Start here: > https://github.com

Re: [julia-users] initializing arrays of tuples in julia 0.4

2015-04-30 Thread Mauro
This works: julia> Tuple{Int,Int}[(z, 2z) for z in 1:3] 3-element Array{Tuple{Int64,Int64},1}: (1,2) (2,4) (3,6) because now the type of (2,3) is Tuple{Int,Int} and not (Int,Int) (which is just a tuple of datatypes). On Thu, 2015-04-30 at 11:53, Jim Garrison wrote: > In Julia 0.3, I can crea

Re: [julia-users] Function return type

2015-04-29 Thread Mauro
That issue https://github.com/JuliaLang/julia/issues/1090 is still open, thus the feature does not exist yet. A bit further along is it with anonymous functions https://github.com/JuliaLang/julia/pull/10269. The problem is that with multi-functions it is not that clear how to implement return typ

Re: [julia-users] Re: Scope of variables in julia

2015-04-29 Thread Mauro
Have a look at https://github.com/JuliaLang/julia/issues/10559 and linked issues. But I do think that your Version 3 is a bug. So unless someone comes up with a reason+explanation you should file a report. On Wed, 2015-04-29 at 17:20, Sisyphuss wrote: > Please these four versions: > Version 1:

[julia-users] abs inside vector norm

2015-04-28 Thread Mauro
In ODE.jl, I would like to be able to take the norm of a Vector containing other things than just numbers: type Point x::Float64 y::Float64 end Base.norm(pt::Point, p=2) = norm([pt.x, pt.y], p) norm(Point(3,4)) # == 5 norm([Point(3,4), Point(3,1)]) # does not work: # ERROR: `abs` has no

Re: [julia-users] Code starting to be slow after 30 min of execution

2015-04-27 Thread Mauro
It is a bit hard to tell what is going wrong with essentially no information. Does the memory usage of Julia go up more than you would expect from storing the results? Any difference between 0.3 and 0.4? Anyway, you should try and make a small self-contained runable example and post it otherwise

Re: [julia-users] Re: How to call the original method that was overloaded?

2015-04-26 Thread Mauro
> Thank you! For this question, invoke indeed a good solution :) > > How about a more general case. For example, I already have a function foo > foo(X::Int)=X+1 > in the environment. > > Then I want to overload foo to forbid negative input: > function foo(X::Int) > @assert(X>=0,"X should be a p

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

2015-04-25 Thread Mauro
I don't think it is realistic to expect be able to willy-nilly be 'using' any number of packages and it just works. The way you propose may work most of the time, however, there were some solid arguments made in this thread on how that can lead to hard to catch failures. And maybe more importantl

Re: [julia-users] Re: Custom Array type

2015-04-25 Thread Mauro
ts > a keyword for what to write in place of Array. > > On 25/04/2015, Mauro wrote: >> On Sat, 2015-04-25 at 19:55, Marcus Appelros >> wrote: >>> Feels somehow sufficient to direct all functions to the data field. We can >>> >>> have a macro like >

Re: [julia-users] in-place fn in a higher order fn

2015-04-25 Thread Mauro
>> I think this optimisation should work irrespective of what fn! returns >> by the fact that the value is not used. This and more seems to happen >> in the first-order function. Here a version of first-order >> function which calls a function which returns an inferred Any: >> >> const aa = A

Re: [julia-users] Re: Custom Array type

2015-04-25 Thread Mauro
On Sat, 2015-04-25 at 19:55, Marcus Appelros wrote: > Feels somehow sufficient to direct all functions to the data field. We can > have a macro like > > @foranyfunction f(c::Cubes,a::AnyArgs)=f(c.data,a) https://github.com/JuliaLang/julia/pull/3292 > "What you really want to be able to do is de

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

2015-04-25 Thread Mauro
> I'd love to see interfaces in general, especially for things like > iteration. If I implement a base interface for my type I'd like to be > able to assert that it is fully implemented. Check out Traits.jl (is getting reasonably stable, although I haven't updated it to post #10380 Julia).

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

2015-04-25 Thread Mauro
>> 3) inside my own namespace, modules continue to use exports but I have to >> implement SuperSecretBase modules managing my function collapses. (Or >> minimize the use of modules) >> However, it probably makes sense to define the meaning of your generic functions somewhere centrally. And this i

Re: [julia-users] Help to optimize a loop through a list

2015-04-24 Thread Mauro
> type ParetoPoint > # Design variables. > vars::Array{Float64,1} > # Objective functions. > f::Array{Float64, 1} > end How large are the vectors in vars and f? Are they always the same size? If so, an immutable-isbits datatype might help. > I am creating the list (the Pareto fro

Re: [julia-users] Is there a canonical method name for first and last index of a collection?

2015-04-24 Thread Mauro
There is `first` On Fri, 2015-04-24 at 12:36, Tim Holy wrote: > There's endof(), but I don't know of a corresponding one for the beginning. > > --Tim > > On Friday, April 24, 2015 03:14:26 AM Tomas Lycken wrote: >> I'm implementing a collection of types that implement indexing, but where >> the i

Re: [julia-users] Ode solver thought, numerical recipes

2015-04-24 Thread Mauro
> - In the current implementation of Julia and Python/Scipy, you need to give > all the points t1,...,tn where you want to know y at the very beginning. If > you want to solve the differential equation on [ta,tb] and you want to find a > t such that y(t)=0, you are stuck because you'll most like

Re: [julia-users] Re: Ode solver thought, numerical recipes

2015-04-24 Thread Mauro
It's a tricky business: https://en.wikipedia.org/wiki/Clean_room_design ... On Fri, 2015-04-24 at 10:28, François Fayard wrote: > I'll make sure I won't use a single line of their code and only use the > papers they refer to.

Re: [julia-users] in-place fn in a higher order fn

2015-04-24 Thread Mauro
>> Well it seems Julia should know that nothing is used from fn!, without >> knowing anything about fn!. That is at least what @code_warntype >> suggest (with julia --inline=no). For >> >> function f(ar) >> for i=1:n >> hh!(ar, i) >> end >> end >> >> the loop gives: >> >>

Re: [julia-users] code review: my first outer constructor :)

2015-04-24 Thread Mauro
a few more? All of them? >>> (3) Line 17 asserts that N is an integer, but sqrt(length(P)) could be >>> non-integral. >>> (4) I don't really understand what is going on with countnonzeros, but >>> maybe a pattern matching syntax ala Match.jl could help

Re: [julia-users] in-place fn in a higher order fn

2015-04-24 Thread Mauro
>> >> >> function f(fn!,ar) >> >> >> for i=1:n >> >> >> fn!(ar, i) # fn! updates ar[i] somehow, returns nothing >> >> >> nothing# to make sure output of f is discarded >> >> >> end >> >> >> end > > > I'm curious how you would see it optimised? IIUC Julia doesn't kn

Re: [julia-users] Re: SAVE THE DATE: JuliaCon 2015, June 24 - 28

2015-04-23 Thread Mauro
I'd like to chime in: it would be great to know soon about acceptance and such to book travels. On Thu, 2015-04-23 at 19:35, Carlo di Celico wrote: > Are we there yet? :D > > On Tuesday, February 24, 2015 at 11:50:10 AM UTC-5, Hunter Owens wrote: >> >> Yup! We're shooting for roughly ~March 15th,

Re: [julia-users] in-place fn in a higher order fn

2015-04-23 Thread Mauro
ument inlining" solve all the higher order function problems? And is the problem described below, not quite a bit easier to solve? > On Thursday, April 23, 2015 at 9:34:48 AM UTC-5, Mauro wrote: >> >> Thanks! In that case, I'll file an issue then to get this noted. Also, >

Re: [julia-users] in-place fn in a higher order fn

2015-04-23 Thread Mauro
"up-for-grabs" issue). > > On Thu, Apr 23, 2015 at 9:18 AM Mauro wrote: > >> It is well know that Julia struggles with type inference in higher order >> functions. This usually leads to slow code and memory allocations. >> There are a few hacks to work around

[julia-users] in-place fn in a higher order fn

2015-04-23 Thread Mauro
It is well know that Julia struggles with type inference in higher order functions. This usually leads to slow code and memory allocations. There are a few hacks to work around this. Anyway, the question I have is: Why can't Julia do better with in-place functions? In short, a higher-order funct

Re: [julia-users] type-stable way to get primary type

2015-04-22 Thread Mauro
da06e/base/linalg/symmetric.jl#L34 > > Notice that it requires two method definitions for each type. > > 2015-04-22 8:57 GMT-04:00 Tim Holy : > >> As Jeff says...this is why `similar` exists. >> >> --Tim >> >> On Wednesday, April 22, 2015 10:03:02 AM Mau

Re: [julia-users] type-stable way to get primary type

2015-04-22 Thread Mauro
all))(:jl_alloc_array_1d,$(Expr(:call1, :(top(apply_type)), :Array, Float64, 1)),$(Expr(:call1, :(top(svec)), :Any, :Int)),Array{Float64,1},0,5,0)::Array{Float64,1} end::Array{Float64,1} But is there a way to do this type-stabally in 0.3 too? On Wed, 2015-04-22 at 10:03, Mauro wrote: > Thanks J

Re: [julia-users] How should let this work?

2015-04-22 Thread Mauro
I think this should work: typealias Foo Type{Function, Function} although I don't have a julia build after the merge of #10380 where tuple types were modified. On Wed, 2015-04-22 at 08:44, Miao Yang wrote: > I don't know how to describe my problem, so let me past the code. > > ``` > > julia>

Re: [julia-users] type-stable way to get primary type

2015-04-22 Thread Mauro
> > So you can't generically reconstruct some arbitrary subtype by some generic > rearrangement of its type parameters. > > On Tue, Apr 21, 2015 at 4:34 PM Mauro wrote: > >> I have a parameterized type and want to get the primary-type. For >> example, I got >&

[julia-users] type-stable way to get primary type

2015-04-21 Thread Mauro
I have a parameterized type and want to get the primary-type. For example, I got a = Array{Int,2} is there a type-stable way to get Array? This is non-type stable: f(t::Type) = t.name.primary as the inferred return type is Type. This does not work: f{T, S}(::Type{T{S...}}) = T Any ideas? T

Re: [julia-users] How to create command tools with Julia modules?

2015-04-18 Thread Mauro
Did you see this: http://docs.julialang.org/en/latest/manual/running-external-programs/ On Sat, 2015-04-18 at 10:01, Jiyin Yiyong wrote: > I want to create a command line tool by create a Julia module. But it's not > mentioned in the docs? Is there a quick solution for that?

Re: [julia-users] custom type equality

2015-04-18 Thread Mauro
If you make the Pair immutable then it should work out of the box. (Note that Pair is a datatype in 0.4, so probably you should either use something compatible or something else). Immutables are compared by the value of their fields, whereas mutables by ===, i.e. whether they are same object in me

Re: [julia-users] packages for keyword constructors

2015-04-16 Thread Mauro
I don't think there is a semi-standard. Here my package: https://github.com/mauro3/Parameters.jl/blob/master/examples/ex1.jl On Thu, 2015-04-16 at 12:18, Tamas Papp wrote: > Hi, > > A comment for PR 6122 [1] mentions packages that define keyword > constructors, which ones are these? Several snip

Re: [julia-users] how to test if object is a Vector{(Symbol,T)} with T <: Real

2015-04-13 Thread Mauro
On Mon, 2015-04-13 at 16:22, Tamas Papp wrote: > On Mon, Apr 13 2015, Mauro wrote: > >> Why can you not make it into a function? >> >> function foo!(spec::Symbol, A, i) >> A[i,spec] = 1 >> end >> function foo!{T<:Real}(spec::Vector{(Symbol,T), A

Re: [julia-users] string processing after readdlm

2015-04-13 Thread Mauro
>- > >- > > > cljs > > > > Array{Any,1} > Array{Any,2} > Any["[0.054008985630280115,0.8947273976690304,0.14961853234717193,0.72895523733,0.8907801902141823]"] > > SubString{ASCIIString} > > in both cases I woul

Re: [julia-users] how to test if object is a Vector{(Symbol,T)} with T <: Real

2015-04-13 Thread Mauro
Why can you not make it into a function? function foo!(spec::Symbol, A, i) A[i,spec] = 1 end function foo!{T<:Real}(spec::Vector{(Symbol,T), A, i) @assert(isapprox(sum(map(x -> x[2],spec)),1)) for (obs,prob) = spec A[i,obs] = prob end A[i,spec] = 1 end foo!(spec,

Re: [julia-users] code review: my first outer constructor :)

2015-04-12 Thread Mauro
Hi Andrei, just a general note, unless someone is actually interested in using your code, a code review might be too much to ask of people. Thus the lack in responses. See: https://groups.google.com/forum/#!searchin/julia-users/karpinski$20reivew/julia-users/C5cVjAuGA8U/HLV5rAjIuLMJ The way to

Re: [julia-users] string processing after readdlm

2015-04-12 Thread Mauro
An example which can be copy-pasted would be helpful. M On Sun, 2015-04-12 at 16:47, JKpie wrote: > Hi, > > I am new Julia coder (I started to learn Julia two weeks ago). I have a > problem with writedlm and readdlm functions. > I have an array of vectors: > > Vector Array{Float32,N},4 > > When

Re: [julia-users] Computed type for parametrized method definition

2015-04-09 Thread Mauro
On Thu, 2015-04-09 at 17:57, Benjamin Piwowarski wrote: > Le mardi 10 mars 2015 17:56:40 UTC+1, Mauro a écrit : >> >> >> Have a look at stagedfunction (v0.4). >> >> >> > I tried with the nightly build, but without success (using >> stagedfunctio

Re: [julia-users] Direct access to fields in a type, unjulian?

2015-04-08 Thread Mauro
> Mauro, thanks for the link. I read the paper by Logg and it seems > interesting. Do you have any references for how the mapping from the cells > to the actual finite elements is done? No, I never got that far. But it doesn't contain any nodes, so presumably those are all sep

Re: [julia-users] Direct access to fields in a type, unjulian?

2015-04-08 Thread Mauro
> Can you comment on the performance implications of directly accessing > fields vs your approach? I'm guessing that directly accessing the fields > would be faster? I think usually it should get inlined and there is no difference: julia> immutable A a::Int end julia> function f

Re: [julia-users] Direct access to fields in a type, unjulian?

2015-04-08 Thread Mauro
Nat and I once started on a mesh library which implements some of that: https://bitbucket.org/maurow/mesh.jl but it has gone a bit stale. In the spirit of Tim's response, it defines a big mesh datatype and then helper dataytpes, for instance Vertices, which are just a thin wrapper around the mesh.

Re: [julia-users] A method with an optional parameter may result in a different method being called

2015-04-08 Thread Mauro
On Wed, 2015-04-08 at 15:34, Daan Huybrechs wrote: > I was a little surprised today by the following behaviour: > > julia> f(d=2) = d > f (generic function with 2 methods) > > julia> f(a::Int) = -a > f (generic function with 3 methods) > > julia> f() > -2 > > julia> methods(f) > # 3 methods for g

Re: [julia-users] Re: Default behavior from omitted catch block when a finally block is added.

2015-04-08 Thread Mauro
> If we require a 'catch' block for every "try", it would be cleaner. > Otherwise I suggest we had a note in the documentation to state the > caveats. Particularly for those who come from other background and get too > excited about "try end" terse syntax. I would be happy to make some edits >

Re: [julia-users] Short question about type alias with partially known parameter types

2015-04-07 Thread Mauro
In 0.3 it's not possible in 0.4 this works: julia> type A{T,P} a::T end julia> typealias B{T} A{T, 1} A{T,1} julia> call{T}(::Type{B}, a::T) = B{T}(a) call (generic function with 936 methods) julia> B(1.0) A{Float64,1}(1.0) See https://github.com/JuliaLang/julia/pull/8712 for

Re: [julia-users] Extreme garbage collection time

2015-04-07 Thread Mauro
for your swift replies, this was my first > julia experience and it's great to have such a supportive community. > > On Tuesday, April 7, 2015 at 11:40:49 AM UTC-4, Mauro wrote: >> >> Make Result an immutable: >> >> immutable Result >> pvalue::Float6

Re: [julia-users] Extreme garbage collection time

2015-04-07 Thread Mauro
os to [-10,10] > b = 10 > for k=1:M > ratios[k] = b*(2/(1+exp(-log2(counts[k,i]/counts[k,j])/(b/2)))-1) > end > > compute!(S,ratios,tot_i,i,j,h_cols,c_cols,M) > end > @show (tot_i,tot,tot_i/tot) > end > > end > > S = m

Re: [julia-users] Extreme garbage collection time

2015-04-07 Thread Mauro
On Tue, 2015-04-07 at 06:14, Adam Labadorf wrote: > Thanks for the replies. I took your suggestions (and reread the scope > section of the docs) and am still experiencing the gc creep. Below is the > complete program, with the notable changes that I wrapped the main > computation in a function

Re: [julia-users] Re: Error messages related to macros

2015-04-06 Thread Mauro
I don't know whether that is mentioned in those issues but one trick is to have a function fabricating the expression and call that in the macro: mymacro_fn(args...) = ... macro mymacro(args...) mymacro_fn(args...) end If something goes wrong debug it with calling the function directly which

Re: [julia-users] Union types and contravariance, question

2015-04-02 Thread Mauro
Types in Julia are invariant: If T1<:T2 is true then A1{T1}<:A1{T2} is false (unless T1==T2). Now setting T1=Float64 and T2=Union( Int64, Float64) means Vector{Float64}<:Vector{Union( Int64, Float64)} is false. Thus the no method error. On Thu, 2015-04-02 at 21:32, Michael Francis wrote: > Is

Re: [julia-users] Passing in Dict for Variable Number of Keyword Arguments like Python

2015-03-31 Thread Mauro
> *julia> foo(;kwargs...) = return kwargs* > *foo (generic function with 1 method)* > > *julia> foo(x=1,y=2)* > *2-element Array{Any,1}:* > * (:x,1)* > * (:y,2)* > > *julia> d = { :a=> 97, :b => 95 }* > *Dict{Any,Any} with 2 entries:* > * :b => 95* > * :a => 97* > > *julia> foo(d...)* > *ERROR: `

Re: [julia-users] Re: Extending a DataFrame (or, why aren't my imports working?)

2015-03-30 Thread Mauro
Thanks for the summary! I think something like this should go into the manual as it is not particularly clear... On Mon, 2015-03-30 at 17:09, kevin.dale.sm...@gmail.com wrote: > I think I've got my head pretty much wrapped around all of this. I figured > I'd recap just in case anyone else comes

Re: [julia-users] Extending a DataFrame (or, why aren't my imports working?)

2015-03-29 Thread Mauro
function with the same name as a function exported from one of the modules >> it calls using on? This would most likely indicate a mistake, or an >> uncoordinated change in the reverse dependency. >> >> >> Regards >> >> On Mar 28, 2015, at 10:16 PM, kevin.da..

Re: [julia-users] Extending a DataFrame (or, why aren't my imports working?)

2015-03-28 Thread Mauro
> That should be index(mydf). I did get the small test case working, but I > still can't seem to use the same techniques to get my application working. > I just don't understand how these method overrides are supposed to work. > I originally thought that you just needed to have methods with t

Re: [julia-users] Extending a DataFrame (or, why aren't my imports working?)

2015-03-28 Thread Mauro
On Fri, 2015-03-27 at 19:46, kevin.dale.sm...@gmail.com wrote: > Ok, I narrowed it down to a very small test case. The mymodule.jl file is > at the bottom of this posting. If you save that to a file then run this > code, you'll get the same effect as my original problem except with the > 'ind

Re: [julia-users] How to test argument types available on a Function?

2015-03-28 Thread Mauro
> In ApproxFun, a user supplied function is approximated. the > approximation depends on whether the function is univariate or > bivariate How does it work, if the user defines several methods? f(x) = x f(x,y) = x+y >> The method_exists function would probably be a slightly cleaner way >> to do

Re: [julia-users] best way to represent objects with common fields but different sets of moves

2015-03-27 Thread Mauro
> 1. Just define multiple composite types with different move() methods > (pro), listing the same fields and constructor for each (con). The type-def could be done with a macro. > 2. Define a single "state" type that has the necessary fields and > constructor (pro), include a "state" as a field

Re: [julia-users] Calling a function via a reference to a function allocates a lot of memory as compared to directly calling

2015-03-26 Thread Mauro
this. Hopefully this will be >> resolved soon! >> > > Mauro: When you say "Hopefully this will be resolved soon! " does that mean > this is an issue with a planned future fix? I've had a look through the issues and not one fitted exactly, there are several rel

Re: [julia-users] code generation with @eval

2015-03-26 Thread Mauro
> @Mauro Base.$f does not work either. Yes, that is odd: julia> a = :cos :cos julia> eval(:(Base.$a)) cos (generic function with 13 methods) julia> eval(:(Base.$a(x::String) = 5)) ERROR: unsupported or misplaced expression $ I think this might be a bug. Anyway, either construct

Re: [julia-users] code generation with @eval

2015-03-26 Thread Mauro
> I was trying to add a bunch of common functions to DistributedArrays.jl with > the below code block > > for f in [:sum, :minimum, :maximum, :mean] > @eval begin > import Base: ($f) > export ($f) > function ($f)(D::DArray) > refs = [@spawnat p ($f)(localpar

Re: [julia-users] Calling a function via a reference to a function allocates a lot of memory as compared to directly calling

2015-03-25 Thread Mauro
This is a known limitation of Julia. The trouble is that Julia cannot do its type interference with the passed in function. I don't have time to search for the relevant issues but you should be able to find them. Similarly, lambdas also suffer from this. Hopefully this will be resolved soon! On

Re: [julia-users] Performance difference between running in REPL and calling a script?

2015-03-23 Thread Mauro
> I think his question can be rephrased as "is the module scope in Julia a > global scope?" yes > and "if it is, then do modules share the same global scope, or they > have there own global scopes?" each have their own. > > > On Monday, March 23, 2015 at 3:43:08 PM UTC+1, Stefan Karpinski wrot

Re: [julia-users] Performance difference between running in REPL and calling a script?

2015-03-23 Thread Mauro
> Thanks for the reply. So I don't believe I define any global variables in > the script itself. But I'm thinking this line: > "*NOTE:* All code in the REPL is evaluated in global scope, so a variable > defined and assigned at toplevel will be a *global* variable." > > might answer my own questio

Re: [julia-users] Re: Error or supposed to happen? compile

2015-03-19 Thread Mauro
Are you on 0.4? Then it should be UInt8 On Thu, 2015-03-19 at 21:47, Julia User wrote: > I did try your suggestion (`ccall("jl_", Void, (Ptr{Uint8},), "Line 305")` > will probably work.) but got an other Error > > libc.jl > libdl.jl > env.jl > error during bootstrap: > LoadError(at "sysimg.jl"

Re: [julia-users] Error or supposed to happen? compile

2015-03-19 Thread Mauro
A quite complicate bootstrap process is running when compiling Julia. So, there is quite a bit of functionality missing during the bootstrap. Apparently one of them is STDOUT, thus the error > UndefVarError(var=:STDOUT))) Search the list for some tips and tricks on how to debug Julia itself. Alth

Re: [julia-users] Re: Overloading Base functions or creating new ones?

2015-03-18 Thread Mauro
> I'd be interested to know a case where confusion could arise. I remember that I got confused by a python library using the bit-shift operator >> for writing to files (C++ style). Got me confused for sure. I think it makes sense that typing, say, ?map should give you a help text which applies

Re: [julia-users] Working with a custom type - questions

2015-03-17 Thread Mauro
> My thinking being that this would help avoid ambiguity with my code, as I > sometimes work with other units of time (e.g. seconds) that are also > floating point numbers. Of course, this introduced a number of problems in > my existing code, including There is also the Units.jl package, whic

Re: [julia-users] Re: dict comprehension syntax in 0.4

2015-03-16 Thread Mauro
> I do find this unsatisfying, because by the same logic I would expect > `[i=>i for i in 1:2]` to create an array of pairs in the future. But > the syntax currently creates a dictionary and does not seem to be > deprecated. In fact, there seems to be no dict comprehension syntax > consistent wit

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

2015-03-16 Thread Mauro
On Mon, 2015-03-16 at 08:40, Christoph Ortner wrote: > Lex, Stefan: Would it not be possible to throw an exception when the > conversion is considered "unsafe"? That's the current behavior: julia> [1,2][1.0] 1 julia> [1,2][1.0001] ERROR: InexactError() in getindex at array.jl:246 julia> [1

Re: [julia-users] Re: Dispatching on type that is unknown at "code write"-time but known at run time.

2015-03-14 Thread Mauro
> type LinTrig <: FElement > v1::Int > end Here you should probably use `immutable`, that way it will be stored as efficiently as ints. > type LinQuad <: FElement > v1::Int > v2::Int > end > > > type Node > c::Float64 > end > > > type FEMesh > node::Vector{Node} > elements

Re: [julia-users] Re: Memory allocation questions

2015-03-12 Thread Mauro
>> you should be able to write: >> >> @inbounds for y in 1:img.height >> @simd for x in 1:img.wid >> if 1 < x < img.wid >> left = img.data[x-1,y] >> center = img.data[x,y] >> @inbounds right = img.data[x+1,y] >> >> Just curious, why did you get rid of t

Re: [julia-users] Something equivalent to Python's xrange()?

2015-03-12 Thread Mauro
1:10 creates a UnitRange which stores just two numbers, start and stop: julia> typeof(1:10) UnitRange{Int64} (constructor with 1 method) julia> names(UnitRange) 2-element Array{Symbol,1}: :start :stop To actually create the list you'd use collect(1:10) On Thu, 2015-03-12 at 14:19, Ali Rezaee

Re: [julia-users] sum array

2015-03-12 Thread Mauro
> Hi > Mauro - thanks for that as that makes it clear whats happening under the > bonnet. So, what if you then wanted to sum... > 1.4827 > 1.48069 > 0.884897 > 1.22739 > is that possible or am I being a bit dumb here. Just add another sum(ans) after below t

Re: [julia-users] Different ways to create a vector of strings in Julia

2015-03-12 Thread Mauro
> However, I supposed this other way should work too, but it didn't: > names = Array{String}; > push!(names,"word2"); > > It gives me the following error: "ERROR: `push!` has no method matching > push!(::Type{Array{String,N}}, ::ASCIIString)" > > Why is String[] and Array(String,0) different from A

Re: [julia-users] sum array

2015-03-12 Thread Mauro
64,1}: 1.4827 1.48069 0.884897 1.22739 So 1.4827 = ans[1][1]+ans[2][1]+ans[3][1] > On Thursday, 12 March 2015 09:50:19 UTC, Mauro wrote: >> >> > const x = rand(8) >> > [ x[i-4:i-1] for i = 6] .. this gives me a 4 element array. >> >> This seems a bit

Re: [julia-users] sum array

2015-03-12 Thread Mauro
> const x = rand(8) > [ x[i-4:i-1] for i = 6] .. this gives me a 4 element array. This seems a bit odd, what are you trying to achieve here? Anyway it produces a Array{Array{Float64,1},1}, i.e. an array of arrays containing one array. > I now want to sum the ouput - this is what I tried ... > su

Re: [julia-users] Re: Memory allocation questions

2015-03-12 Thread Mauro
Julia is not yet very good with producing fast vectorized code which does not allocate temporaries. The temporaries is what gets you here. However, running your example, I get a slightly different a different *.mem file (which makes more sense to me): - function forward_propagate(nl::Neu

Re: [julia-users] "for" and "function" don't work in the same way in terms of scope

2015-03-12 Thread Mauro
namic scope, which is (I think) a different issue to soft and hard scope. I'll move some of this discussion to https://github.com/JuliaLang/julia/issues/9955 > On Tuesday, March 10, 2015 at 10:40:53 PM UTC+1, Mauro wrote: >> >> I think this is the soft vs hard scope issue.

Re: [julia-users] "for" and "function" don't work in the same way in terms of scope

2015-03-12 Thread Mauro
I think this is the soft vs hard scope issue. See: https://github.com/JuliaLang/julia/issues/9955 That issue could use some fleshing out though... On Tue, 2015-03-10 at 20:03, Wendell Zheng wrote: > *Input 1:* > y = 0 > function foo() > y = 10 > end > foo() > y > > *Output 1:* > 0 > > *Inpu

Re: [julia-users] Specifying return type of a function

2015-03-12 Thread Mauro
Sadly not. Have a look at https://github.com/JuliaLang/julia/issues/1090 and https://github.com/JuliaLang/julia/pull/10269 The complication in Julia is that with its multimethods, it is not so clear what the return type of a generic function actually means. On Tue, 2015-03-10 at 21:24, Shivkumar

Re: [julia-users] permuting rows of a matrix

2015-03-11 Thread Mauro
Have a look at the permute! function in julia: @less permute!([1,2], [1,2]) Modifying it to function permute!!{T<:Integer}(a, i, p::AbstractVector{T}) count = 0 start = 0 while count < length(a) ptr = start = findnext(p, start+1) temp = a[i,start] next = p[star

Re: [julia-users] Specifying return type of a function

2015-03-11 Thread Mauro
ode >> > instead. Nuisance though. >> But you shouldn't need to. Julia is able to find out what the return >> type is as long as you write type-stable code. Can you give more details >> about what you're trying to achieve? >> >> >> Regards

Re: [julia-users] Computed type for parametrized method definition

2015-03-10 Thread Mauro
>> Have a look at stagedfunction (v0.4). >> > I tried with the nightly build, but without success (using stagedfunction > instead of function) - however, it looks like it is the solution, maybe I > will just have to wait until this is implemented (and the syntax set). You will need to adapt the

Re: [julia-users] Computed type for parametrized method definition

2015-03-10 Thread Mauro
> abstract typeA > > immutable typeA1 <: typeA end > immutable typeA2 <: typeA end > > type typeB1 end > type typeB2 end More Julian would be to write: transformType(T::Type{typeA1}) = typeB1 transformType(T::Type{typeA2}) = typeB2 transformType(T::Type) = error("Cannot handle type $T") > functi

Re: [julia-users] Dimension mismatch error in Julia!​

2015-03-10 Thread Mauro
It would be helpful if you could post an example which runs with just copy-paste into the REPL. On Tue, 2015-03-10 at 10:55, Kacem HARIZ wrote: > I got stuck by an error in Julia! please I need help! > > *here is the code:* > > > *w=1;* > *γ=0.01;* > *f(x,y)= [y;-w^2*sin(x)-u*w^2*cos(x) -2γ*y];

Re: [julia-users] I don't have BLAS functions.

2015-03-09 Thread Mauro
On my system I need to qualify it with Base, so Base.axpy! works. On Mon, 2015-03-09 at 11:20, Daniel Carrera wrote: > Hello, > > The Julia documentation says that you can access some BLAS functions: > > http://docs.julialang.org/en/release-0.3/stdlib/linalg/?module-Base.LinAlg.BLAS#module-Base.L

<    1   2   3   4   5   6   7   8   >