[julia-users] Re: Changing Repositories Without Deleting METADATA

2016-10-02 Thread Tony Kelman
The conclusion I'd take out of that is not to use GitHub Desktop. It tries to 
hide too many important things like this from you. As far as git GUIs go, try 
SourceTree, it has a much more direct mapping between command line operations 
and GUI buttons.

[julia-users] Unexpected results with typeof(DataFrame)

2016-10-02 Thread r5823
I have a custom type ParType.Parjm and two DataFrames,temp and DF, where 
the elements are of this type:

typeof(temp[:A])

DataArrays.DataArray{ParType.Parjm,1}


and 

typeof(DF[:A])

DataArrays.DataArray{ParType.Parjm,1}


However, the following comparison returns false.


typeof(temp[:A]) == typeof(DF[:A])

false


Any thoughts on what is going on here?



[julia-users] ANN: GoogleCloud.jl - Google Cloud JSON API Wrapper for Julia

2016-10-02 Thread joshbode
Hello julia-users,

We have tagged and released v0.0.1 of GoogleCloud.jl 
 - a general wrapper for Google 
Cloud Platform JSON RESTful APIs (Storage, Compute, etc).

A quick-start tutorial is available at: 
https://joshbode.github.io/GoogleCloud.jl/latest/

Currently, the Storage API 
 has been implemented 
in GoogleCloud.jl, with other APIs planned to be added (a process which 
requires little more than to list the HTTP resources/methods for the API).

GoogleCloud.jl includes an OAuth 2.0 component using Google Cloud IAM 
 service-account credentials 
to authenticate (via JWT 

)
This functionality could potentially be spun off as a part of a more 
general OAuth 2.0 package in the future.

GoogleCloud.jl is available via:


  julia> Pkg.update()
  julia> Pkg.add("GoogleCloud")


If you have any feedback on the package, we'd love to hear from you!

Cheers,
Josh and Jock


[julia-users] Re: membership checking in heap

2016-10-02 Thread Athul George Appadan
Thanks a lot..

On Monday, October 3, 2016 at 2:41:13 AM UTC+5:30, Steven G. Johnson wrote:
>
>
>
> On Saturday, October 1, 2016 at 1:17:48 PM UTC-4, Athul George Appadan 
> wrote:
>>
>> I am trying to find a way to check the membership of a user defined type 
>> object in a heap. This is the code I have written:
>>
>> type HeapEntry
>> k::Int
>> dist::Float64
>> end
>>
>> isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>>
>> heap1 = []
>> Collection.heappush!(heap1, HeapEntry(1, 10.0))
>>
>>
>> But HeapEntry(1, 10.0) is returning false. Can anyone explain how to do 
>> it correctly?
>>
>
> == defaults to object equality, so HeapEntry(1, 10.0) == HeapEntry(1, 
> 10.0) returns false unless you define your own == operation.
>
> However, I'm guessing that in this case you want to define an immutable 
> type, rather than a mutable type.  Not only will storage etc be more 
> efficient, but also the default == will do what you want in that case.
>
> immutable HeapEntry
>
>k::Int
>
>dist::Float64
>
> end
>
> Base.isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>
> heap1 = HeapEntry[]
>
> Collections.heappush!(heap1, HeapEntry(1, 10.0))
>
>
> At that point, HeapEntry(1, 10.0) in heap1 returns true.
>
>
> However, note that a heap data structure is not designed for fast 
> membership testing.  It is designed for quickly popping the minimum 
> element.   If you want "x in data" operations to be fast, you should use 
> some other data structure.
>


[julia-users] Re: View (a portion of a) vector as a matrix

2016-10-02 Thread Chris Rackauckas
Fengyang's reshape((@view x[1:6]), (3, 2)) will work well and will be 
essentially cost-free since reshape creates a view, and a view of a view is 
still just a view (no copy). Another way to write it is 
reshape(view(x,1:6), (3, 2)). For example:

function f(t,u,du)
  x = reshape(view(x,1:6), (3, 2))
  # Use x and u[7], u[8], u[9], and u[10] to write directly to du
  nothing
end

 should be a good way to write the function for Sundials.jl, 
DifferentialEquations.jl, ODE.jl (after the iterator PR).

On Sunday, October 2, 2016 at 5:43:01 AM UTC-7, Alexey Cherkaev wrote:
>
> I have the model where it is convenient to represent one of the variables 
> as a matrix. This variable, however, is obtained as a solution of ODEs 
> (among other variables). I'm using Sundials to solve ODEs and 
> `Sundials.cvode` requires the ODE RHS function to take a vector. So, it 
> seems logical to pack the variables into a vector to pass to `cvode` and 
> unpack them for more convenient use in my code.
>
> For example, consider `x = fill(1.0, 10)` and the first 6 entries are 
> actually a matrix of size 3x2, other 4: other variables. So, I can do `s = 
> reshape(x[1:6], (3,2))`. However, this creates a copy, which I would want 
> to avoid. And I couldn't find a way to do the view-reshaping by applying 
> `view()` function or doing `SubArray` directly. For now I settle on to 
> using indices of the form `(i-1)*M + j +1` to retrieve `s[i,j] = x[(i-1)*M 
> + j +1]`. But, (1) julia's 1-based arrays make it awkward to use this 
> notation and (2) matrix (not element-wise) operations are not available.
>


[julia-users] Re: Changing Repositories Without Deleting METADATA

2016-10-02 Thread Chris Rackauckas
Yeah, this is how I used to do it. It's really fragile though when used in 
conjunction with Github Desktop on Windows (it doesn't, at least didn't, 
like multiple remotes). I guess that's the best option unless the package 
manager allows one to choose remotes.

On Sunday, October 2, 2016 at 10:50:29 AM UTC-7, Avik Sengupta wrote:
>
> I usually do this directly in git, and not via Pkg commands. I go into the 
> package directory, and add my fork as an additonal remote. So..
>
> cd /home/chris/v0.5/Sundials
> git remote add  chris https://github.com/ChrisRackauckas/Sundials.jl.git 
> 
> git checkout -b cool-feature
> julia #Develop cool feature, test from Julia
> git push chris cool-feature
>
> I'll then create a pull request from Github's ui. 
>
> On Sunday, 2 October 2016 18:01:28 UTC+1, Chris Rackauckas wrote:
>>
>> Does anyone have a good way to change repositories? A common example for 
>> me is, Sundials is in JuliaDiffEq, so I fork it to my Github account for an 
>> extended PR, but to work on it I need to remove my current Sundials install 
>> and clone from my own repository. However, METADATA does not like this at 
>> all:
>>
>> julia> Pkg.rm("Sundials") # Remove the JuliaDiffEq/Sundials version
>> WARNING: unknown DataFrames commit 84523937, metadata may be ahead of 
>> package cache
>> INFO: No packages to install, update or remove
>> INFO: Package database updated
>>
>> julia> Pkg.clone("https://github.com/ChrisRackauckas/Sundials.jl.git 
>> ")
>>  
>> # Install from my Github
>> INFO: Cloning Sundials from 
>> https://github.com/ChrisRackauckas/Sundials.jl.git
>> ERROR: Sundials already exists
>>  in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
>>  in clone(::String) at .\pkg\entry.jl:221
>>  in 
>> (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() 
>> at .\pkg\dir.jl:31
>>  in 
>> cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, 
>> ::String) at .\file.jl:58
>>  in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, 
>> ::Vararg{Any,N}) at .\pkg\dir.jl:31
>>  in clone(::String) at .\pkg\pkg.jl:151
>>
>> In the past I would just delete METADATA and let it re-create itself, and 
>> that will fix it, but then you have to re-install packages which can be a 
>> mess. Since this is becoming much more common for me, I need a better way 
>> to handle this. Does anyone have a better workflow?
>>
>

Re: [julia-users] metaprogramming and encapsulation

2016-10-02 Thread Fengyang Wang
It is not in general possible to recover the function itself from a method, 
as methods are specific to types and not functions. Multiple functions can 
share methods if those functions have the same type.

In the case of generic (or singleton) functions, you can recover the 
function from the instance field of the type of the method's first 
parameter. That is,

first(method).sig.parameters[1].instance



On Sunday, October 2, 2016 at 11:41:12 AM UTC-4, Carlo Lucibello wrote:
>
> that could be handy indeed, thanks. 
> I would also like to automatize the process using
> ```julia
> mlist = methodswith(A, ModA)
> ```
> but looks like objects of type Method are not callable 
> ```julia
> julia> mlist[1](1)
> ERROR: MethodError: objects of type Method are not callable
>  in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
>  in macro expansion at ./REPL.jl:95 [inlined]
>  in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
> ```
> How do I go from a Method object to the corresponing callable Function 
> object?
>
>
> Il giorno lun 26 set 2016 alle ore 16:39 Mauro  > ha scritto:
>
>> This macro might work for you
>>
>> https://github.com/JuliaLang/DataStructures.jl/blob/8422ca9f66bfaa0f257b2bbbc8637c844d49ea68/src/delegate.jl
>>
>> On Mon, 2016-09-26 at 16:31, Carlo Lucibello > > wrote:
>> > Hi everybody,
>> > I'm looking for a metaprogramming trick to solve the following problem 
>> (I'm
>> > confident it can be done efficiently with julia) . Let's say I have 
>> defined a
>> > type in a module along with some methods:
>> > module ModA
>> > export A,f1,f2,f3
>> >
>> > type A
>> > ...
>> > end
>> >
>> > f1(a::A, x::Int) = ...
>> > f2(x, a::A, y) = ...
>> > f3(a1::A,a2::A) = ...
>> >
>> > end #module
>> > Now I have a second type that encapsulate the first
>> >
>> > using ModA
>> >
>> > type B
>> > a::A
>> > ...
>> > end
>> >
>> > and I would like to define a macro that automatically defines all the 
>> exported
>> > function in ModA for the type B in the trivial way, that is
>> >
>> > f1(b::B, x::Int) = f1(b.a, x)
>> > f2(x, b::B, y) = f1(x, b.a, y)
>> > f3(b1::B, b2::B) = f1(b1.a, b2.a)
>> >
>> > A starting point could be methodswith(A, ModA), but I don't know how to 
>> procede
>> > further. Suggestions?
>> >
>> > Bye,
>> > Carlo
>>
>

[julia-users] Re: View (a portion of a) vector as a matrix

2016-10-02 Thread Fengyang Wang
There should be no copy if you reshape a view.

julia> reshape((@view x[1:6]), (3, 2))
3×2 
Base.ReshapedArray{Float64,2,SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true},Tuple{}}:
 1.0  1.0
 1.0  1.0
 1.0  1.0


On Sunday, October 2, 2016 at 8:43:01 AM UTC-4, Alexey Cherkaev wrote:
>
> I have the model where it is convenient to represent one of the variables 
> as a matrix. This variable, however, is obtained as a solution of ODEs 
> (among other variables). I'm using Sundials to solve ODEs and 
> `Sundials.cvode` requires the ODE RHS function to take a vector. So, it 
> seems logical to pack the variables into a vector to pass to `cvode` and 
> unpack them for more convenient use in my code.
>
> For example, consider `x = fill(1.0, 10)` and the first 6 entries are 
> actually a matrix of size 3x2, other 4: other variables. So, I can do `s = 
> reshape(x[1:6], (3,2))`. However, this creates a copy, which I would want 
> to avoid. And I couldn't find a way to do the view-reshaping by applying 
> `view()` function or doing `SubArray` directly. For now I settle on to 
> using indices of the form `(i-1)*M + j +1` to retrieve `s[i,j] = x[(i-1)*M 
> + j +1]`. But, (1) julia's 1-based arrays make it awkward to use this 
> notation and (2) matrix (not element-wise) operations are not available.
>


[julia-users] Re: Using generators

2016-10-02 Thread Steven G. Johnson


On Sunday, October 2, 2016 at 6:02:13 AM UTC-4, harven wrote:
>
> I see that julia v0.5 has now generators. That looks promising but the 
> example given in the docs is not really interesting,
>
>   sum(1/n^2 for n = 1:1000)
>
> since we have been able to write from start the shorter  and I think as 
> efficient
>
>   sum(n->1/n^2, 1:1000)
>
> My question is, where may/should I use generators?
>

Generator expressions produce an iterator, so they work with any function 
that accepts iterables. 


Re: [julia-users] Re: ASTs of complete modules/packages?

2016-10-02 Thread Jameson
This also sounds similar to some of the issues I dealt with in some 
experimental code I wrote to simulate the result of precompiling modules. 
In `eval_expr`, I dealt with the ability to handle some expressions 
specially (such as `=`) and to recurse into `module` declarations. (The net 
goal of this code was to serialize the result of each statement so that 
deserialize could replay the same results, but faster).
https://github.com/vtjnash/Speed.jl/blob/master/src/Speed.jl#L104

On Monday, September 26, 2016 at 9:58:18 AM UTC-4, Cedric St-Jean wrote:
>
> Cool, thank you.
>
> On Mon, Sep 26, 2016 at 9:09 AM, Yichao Yu  wrote:
>
>> On Mon, Sep 26, 2016 at 8:31 AM, Cedric St-Jean  
>> wrote:
>> > It would make sense to put .jl file-parsing code in a separate,
>> > community-maintained module, because the rules for finding which file a
>> > module corresponds to are not trivial, and can change over time (they 
>> became
>> > case-sensitive in 0.5)
>> >
>> > It's too bad that
>> >
>> > macro module_parser(m)
>> > m
>> > end
>> >
>> > @module_parser module X
>> > a = 10
>> > end
>>
>> julia> macro m(m)
>>Expr(:toplevel, m)
>>end
>> @m (macro with 1 method)
>>
>> julia> @m module A
>>end
>> A
>>
>>
>> >
>> > is a syntax error, because it would be cleaner for instrumentation, and 
>> for
>> > augmenting Julia's syntax.
>> >
>> > Cédric
>> >
>> > On Mon, Sep 26, 2016 at 2:08 AM, Andreas Lobinger 
>> > wrote:
>> >>
>> >> Hello colleague,
>> >>
>> >> On Monday, September 26, 2016 at 12:50:44 AM UTC+2, Cedric St-Jean 
>> wrote:
>> >>>
>> >>> I faced very similar issues with ClobberingReload.jl.
>> >>> 
>> https://github.com/cstjean/ClobberingReload.jl/blob/master/src/ClobberingReload.jl
>> >>> Check out parse_file (courtesy of @stevengj), parse_module, and 
>> creload. I
>> >>> haven't "expanded" the includes, but it seems straight-forward to do 
>> with a
>> >>> comprehension.
>> >>
>> >>
>> >> Thank you. I shortlisted the 'reload' mechanisms anyway, but
>> >> ClobberingReload seems new. Actually i was wondering, if i'm the first 
>> one
>> >> to look into code instrumentation. This should be really straight 
>> forward in
>> >> julia (i did it once in f77 and that clearly not straight forward...).
>> >
>> >
>>
>
>

[julia-users] Re: membership checking in heap

2016-10-02 Thread Steven G. Johnson


On Saturday, October 1, 2016 at 1:17:48 PM UTC-4, Athul George Appadan 
wrote:
>
> I am trying to find a way to check the membership of a user defined type 
> object in a heap. This is the code I have written:
>
> type HeapEntry
> k::Int
> dist::Float64
> end
>
> isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist
>
> heap1 = []
> Collection.heappush!(heap1, HeapEntry(1, 10.0))
>
>
> But HeapEntry(1, 10.0) is returning false. Can anyone explain how to do it 
> correctly?
>

== defaults to object equality, so HeapEntry(1, 10.0) == HeapEntry(1, 10.0) 
returns false unless you define your own == operation.

However, I'm guessing that in this case you want to define an immutable 
type, rather than a mutable type.  Not only will storage etc be more 
efficient, but also the default == will do what you want in that case.

immutable HeapEntry

   k::Int

   dist::Float64

end

Base.isless(e1::HeapEntry, e2::HeapEntry) = e1.dist < e2.dist

heap1 = HeapEntry[]

Collections.heappush!(heap1, HeapEntry(1, 10.0))


At that point, HeapEntry(1, 10.0) in heap1 returns true.


However, note that a heap data structure is not designed for fast 
membership testing.  It is designed for quickly popping the minimum 
element.   If you want "x in data" operations to be fast, you should use 
some other data structure.


[julia-users] Re: julia-i18n: Translators and reviewer needed!

2016-10-02 Thread Mosè Giordano
Hi,

last week I completely translated 
http://julialang.org/downloads/platform.html to Italian (or at least I 
thought I did it), but now most of the translations disappeared, without 
recent changes to 
https://github.com/JuliaLang/julialang.github.com/blob/master/downloads/platform.md.
  
What happened to them?  Did someone else notice similar phenomena?  I'd not 
be very happy to translate the same strings over and over again just 
because they disappear for some random reasons.

Bye,
Mosè


[julia-users] Re: Changing Repositories Without Deleting METADATA

2016-10-02 Thread Avik Sengupta
I usually do this directly in git, and not via Pkg commands. I go into the 
package directory, and add my fork as an additonal remote. So..

cd /home/chris/v0.5/Sundials
git remote add  chris https://github.com/ChrisRackauckas/Sundials.jl.git 

git checkout -b cool-feature
julia #Develop cool feature, test from Julia
git push chris cool-feature

I'll then create a pull request from Github's ui. 

On Sunday, 2 October 2016 18:01:28 UTC+1, Chris Rackauckas wrote:
>
> Does anyone have a good way to change repositories? A common example for 
> me is, Sundials is in JuliaDiffEq, so I fork it to my Github account for an 
> extended PR, but to work on it I need to remove my current Sundials install 
> and clone from my own repository. However, METADATA does not like this at 
> all:
>
> julia> Pkg.rm("Sundials") # Remove the JuliaDiffEq/Sundials version
> WARNING: unknown DataFrames commit 84523937, metadata may be ahead of 
> package cache
> INFO: No packages to install, update or remove
> INFO: Package database updated
>
> julia> Pkg.clone("https://github.com/ChrisRackauckas/Sundials.jl.git 
> ")
>  
> # Install from my Github
> INFO: Cloning Sundials from 
> https://github.com/ChrisRackauckas/Sundials.jl.git
> ERROR: Sundials already exists
>  in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
>  in clone(::String) at .\pkg\entry.jl:221
>  in 
> (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() 
> at .\pkg\dir.jl:31
>  in 
> cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, 
> ::String) at .\file.jl:58
>  in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, 
> ::Vararg{Any,N}) at .\pkg\dir.jl:31
>  in clone(::String) at .\pkg\pkg.jl:151
>
> In the past I would just delete METADATA and let it re-create itself, and 
> that will fix it, but then you have to re-install packages which can be a 
> mess. Since this is becoming much more common for me, I need a better way 
> to handle this. Does anyone have a better workflow?
>


[julia-users] Re: Changing Repositories Without Deleting METADATA

2016-10-02 Thread Kristoffer Carlsson
Just 

git add remote REMOTE_NAME REMOTE_URL

in the package folder and then

git checkout REMOTE_NAME master
git checkout origin master

to swap between the repos.

On Sunday, October 2, 2016 at 7:01:28 PM UTC+2, Chris Rackauckas wrote:
>
> Does anyone have a good way to change repositories? A common example for 
> me is, Sundials is in JuliaDiffEq, so I fork it to my Github account for an 
> extended PR, but to work on it I need to remove my current Sundials install 
> and clone from my own repository. However, METADATA does not like this at 
> all:
>
> julia> Pkg.rm("Sundials") # Remove the JuliaDiffEq/Sundials version
> WARNING: unknown DataFrames commit 84523937, metadata may be ahead of 
> package cache
> INFO: No packages to install, update or remove
> INFO: Package database updated
>
> julia> Pkg.clone("https://github.com/ChrisRackauckas/Sundials.jl.git;) # 
> Install from my Github
> INFO: Cloning Sundials from 
> https://github.com/ChrisRackauckas/Sundials.jl.git
> ERROR: Sundials already exists
>  in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
>  in clone(::String) at .\pkg\entry.jl:221
>  in 
> (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() 
> at .\pkg\dir.jl:31
>  in 
> cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, 
> ::String) at .\file.jl:58
>  in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, 
> ::Vararg{Any,N}) at .\pkg\dir.jl:31
>  in clone(::String) at .\pkg\pkg.jl:151
>
> In the past I would just delete METADATA and let it re-create itself, and 
> that will fix it, but then you have to re-install packages which can be a 
> mess. Since this is becoming much more common for me, I need a better way 
> to handle this. Does anyone have a better workflow?
>


[julia-users] Re: Changing Repositories Without Deleting METADATA

2016-10-02 Thread Kristoffer Carlsson
Just 

git remote add REMOTE_NAME REMOTE_URL

in the package folder and then

git checkout REMOTE_NAME master
git checkout origin master

to swap between the repos.

On Sunday, October 2, 2016 at 7:01:28 PM UTC+2, Chris Rackauckas wrote:
>
> Does anyone have a good way to change repositories? A common example for 
> me is, Sundials is in JuliaDiffEq, so I fork it to my Github account for an 
> extended PR, but to work on it I need to remove my current Sundials install 
> and clone from my own repository. However, METADATA does not like this at 
> all:
>
> julia> Pkg.rm("Sundials") # Remove the JuliaDiffEq/Sundials version
> WARNING: unknown DataFrames commit 84523937, metadata may be ahead of 
> package cache
> INFO: No packages to install, update or remove
> INFO: Package database updated
>
> julia> Pkg.clone("https://github.com/ChrisRackauckas/Sundials.jl.git;) # 
> Install from my Github
> INFO: Cloning Sundials from 
> https://github.com/ChrisRackauckas/Sundials.jl.git
> ERROR: Sundials already exists
>  in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
>  in clone(::String) at .\pkg\entry.jl:221
>  in 
> (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() 
> at .\pkg\dir.jl:31
>  in 
> cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, 
> ::String) at .\file.jl:58
>  in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, 
> ::Vararg{Any,N}) at .\pkg\dir.jl:31
>  in clone(::String) at .\pkg\pkg.jl:151
>
> In the past I would just delete METADATA and let it re-create itself, and 
> that will fix it, but then you have to re-install packages which can be a 
> mess. Since this is becoming much more common for me, I need a better way 
> to handle this. Does anyone have a better workflow?
>


[julia-users] Changing Repositories Without Deleting METADATA

2016-10-02 Thread Chris Rackauckas
Does anyone have a good way to change repositories? A common example for me 
is, Sundials is in JuliaDiffEq, so I fork it to my Github account for an 
extended PR, but to work on it I need to remove my current Sundials install 
and clone from my own repository. However, METADATA does not like this at 
all:

julia> Pkg.rm("Sundials") # Remove the JuliaDiffEq/Sundials version
WARNING: unknown DataFrames commit 84523937, metadata may be ahead of 
package cache
INFO: No packages to install, update or remove
INFO: Package database updated

julia> Pkg.clone("https://github.com/ChrisRackauckas/Sundials.jl.git;) # 
Install from my Github
INFO: Cloning Sundials from 
https://github.com/ChrisRackauckas/Sundials.jl.git
ERROR: Sundials already exists
 in clone(::String, ::SubString{String}) at .\pkg\entry.jl:193
 in clone(::String) at .\pkg\entry.jl:221
 in 
(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() 
at .\pkg\dir.jl:31
 in 
cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, 
::String) at .\file.jl:58
 in #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, 
::Vararg{Any,N}) at .\pkg\dir.jl:31
 in clone(::String) at .\pkg\pkg.jl:151

In the past I would just delete METADATA and let it re-create itself, and 
that will fix it, but then you have to re-install packages which can be a 
mess. Since this is becoming much more common for me, I need a better way 
to handle this. Does anyone have a better workflow?


Re: [julia-users] metaprogramming and encapsulation

2016-10-02 Thread Carlo Lucibello
that could be handy indeed, thanks.
I would also like to automatize the process using
```julia
mlist = methodswith(A, ModA)
```
but looks like objects of type Method are not callable
```julia
julia> mlist[1](1)
ERROR: MethodError: objects of type Method are not callable
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
 in macro expansion at ./REPL.jl:95 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
```
How do I go from a Method object to the corresponing callable Function
object?


Il giorno lun 26 set 2016 alle ore 16:39 Mauro  ha
scritto:

> This macro might work for you
>
> https://github.com/JuliaLang/DataStructures.jl/blob/8422ca9f66bfaa0f257b2bbbc8637c844d49ea68/src/delegate.jl
>
> On Mon, 2016-09-26 at 16:31, Carlo Lucibello 
> wrote:
> > Hi everybody,
> > I'm looking for a metaprogramming trick to solve the following problem
> (I'm
> > confident it can be done efficiently with julia) . Let's say I have
> defined a
> > type in a module along with some methods:
> > module ModA
> > export A,f1,f2,f3
> >
> > type A
> > ...
> > end
> >
> > f1(a::A, x::Int) = ...
> > f2(x, a::A, y) = ...
> > f3(a1::A,a2::A) = ...
> >
> > end #module
> > Now I have a second type that encapsulate the first
> >
> > using ModA
> >
> > type B
> > a::A
> > ...
> > end
> >
> > and I would like to define a macro that automatically defines all the
> exported
> > function in ModA for the type B in the trivial way, that is
> >
> > f1(b::B, x::Int) = f1(b.a, x)
> > f2(x, b::B, y) = f1(x, b.a, y)
> > f3(b1::B, b2::B) = f1(b1.a, b2.a)
> >
> > A starting point could be methodswith(A, ModA), but I don't know how to
> procede
> > further. Suggestions?
> >
> > Bye,
> > Carlo
>


[julia-users] ANN: ParallelDataTransfer.jl

2016-10-02 Thread Chris Rackauckas
ParallelDataTransfer.jl 
 is a library 
for sending and receiving data among processes defined using Julia's 
parallel computing framework. This library can be used to:


   - Send variables to worker processes
   - Directly define variables on worker processes
   - Broadcast a definition statement to all workers
   - Get variables from remote processes
   - Pass variables between processes


 This library is constructed so these operations are done safely and 
easily, with the wait/fetch/sync operations built in. This allows one to do 
parallel programming at a high-level, specifying what data is moving, and 
not the details of how it moves.

Also included are examples of how to use this functionality type-safely. 
Since these functions/macros internally utilize eval statements, the 
variables they define are in the global scope. However, by passing these 
variables into functions or declaring their types, one can easily use this 
library with type-stable functions. Please see the README for details.

If you like this project, please star the repository to show your support. 
Please feel free to suggest features by opening issues (and please report 
bugs as well). Thank you for your attention.


Re: [julia-users] View (a portion of a) vector as a matrix

2016-10-02 Thread Tom Breloff
Look at 'splitview' in CatViews.jl

On Sunday, October 2, 2016, Alexey Cherkaev 
wrote:

> I have the model where it is convenient to represent one of the variables
> as a matrix. This variable, however, is obtained as a solution of ODEs
> (among other variables). I'm using Sundials to solve ODEs and
> `Sundials.cvode` requires the ODE RHS function to take a vector. So, it
> seems logical to pack the variables into a vector to pass to `cvode` and
> unpack them for more convenient use in my code.
>
> For example, consider `x = fill(1.0, 10)` and the first 6 entries are
> actually a matrix of size 3x2, other 4: other variables. So, I can do `s =
> reshape(x[1:6], (3,2))`. However, this creates a copy, which I would want
> to avoid. And I couldn't find a way to do the view-reshaping by applying
> `view()` function or doing `SubArray` directly. For now I settle on to
> using indices of the form `(i-1)*M + j +1` to retrieve `s[i,j] = x[(i-1)*M
> + j +1]`. But, (1) julia's 1-based arrays make it awkward to use this
> notation and (2) matrix (not element-wise) operations are not available.
>


[julia-users] View (a portion of a) vector as a matrix

2016-10-02 Thread Alexey Cherkaev
I have the model where it is convenient to represent one of the variables 
as a matrix. This variable, however, is obtained as a solution of ODEs 
(among other variables). I'm using Sundials to solve ODEs and 
`Sundials.cvode` requires the ODE RHS function to take a vector. So, it 
seems logical to pack the variables into a vector to pass to `cvode` and 
unpack them for more convenient use in my code.

For example, consider `x = fill(1.0, 10)` and the first 6 entries are 
actually a matrix of size 3x2, other 4: other variables. So, I can do `s = 
reshape(x[1:6], (3,2))`. However, this creates a copy, which I would want 
to avoid. And I couldn't find a way to do the view-reshaping by applying 
`view()` function or doing `SubArray` directly. For now I settle on to 
using indices of the form `(i-1)*M + j +1` to retrieve `s[i,j] = x[(i-1)*M 
+ j +1]`. But, (1) julia's 1-based arrays make it awkward to use this 
notation and (2) matrix (not element-wise) operations are not available.


[julia-users] Using generators

2016-10-02 Thread cormullion
Aren't generators to do with when the results are produced (on demand), rather 
than how they're specified?

[julia-users] Using generators

2016-10-02 Thread harven
I see that julia v0.5 has now generators. That looks promising but the 
example given in the docs is not really interesting,

  sum(1/n^2 for n = 1:1000)

since we have been able to write from start the shorter  and I think as 
efficient

  sum(n->1/n^2, 1:1000)

My question is, where may/should I use generators?
 It seems that I can't always use them when an array is expected, e.g. 

julia> reverse([i+1 for i in 'a':'c'])
3-element Array{Char,1}:
 'd'
 'c'
 'b'

julia> reverse(i+1 for i in 'a':'c')
ERROR: MethodError: no method matching
reverse(::Base.Generator{StepRange{Char,Int64},##422#423})
Closest candidates are:
  reverse(!Matched::BitArray{1}) at bitarray.jl:1416
  reverse(!Matched::String) at strings/string.jl:209
  reverse(!Matched::LegacyStrings.ASCIIString) at 
/home/harven/.julia/v0.5/LegacyStrings/src/ascii.jl:90