[julia-users] does quote...end really create a QuoteNode?

2016-08-27 Thread Spencer Russell
the metaprogramming docs say that `quote…end` produces a `QuoteNode`, but when 
I try:

julia> quo = quote
   x=2
   y=3
   end
quote  # none, line 2:
x = 2 # none, line 3:
y = 3
end

julia> noquo = :(
   x=2;
   y=3)
quote
x = 2
y = 3
end

and `dump` the results, they both seem the same except for the presence of line 
number nodes in the `quote…end` one (on 0.4.6 and 0.5). Is there something else 
that creates the `QuoteNode`?

Thanks,
Spencer

[julia-users] Re: Pkg.update() error, 0.4.6

2016-08-27 Thread Liye zhang
Andreas, thank you so much!

It is caused by the firewall. 

On Saturday, August 27, 2016 at 5:45:21 PM UTC+8, Andreas Lobinger wrote:
>
> Hello colleague,
>
> On Saturday, August 27, 2016 at 9:20:32 AM UTC+2, Liye zhang wrote:
>>
>> Julia and its packages are installed using the network at my home. When I 
>> try to install new package using the network in my company, there are 
>> errors as mentioned above.
>>
>> When I update using the network at home, there is no error.  So, is this 
>> error caused by the change of the IP, which would be used by git of Julia 
>> package system ?
>>
>> This error occurred many times. Could anyone give me some help? 
>>
>
> company networks usually are firewalled and proxied to the outside 
> internet. So it's not the change of IP only.
> You can check, if running 
>
> git config --global url."https://@".insteadOf git://
>
> on a shell solves this for you (it did for me)
>
>

[julia-users] Re: Can someone please update Winston?

2016-08-27 Thread Chris Rackauckas
Plots.jl has different behavior depending on the chosen backend. It 
defaults to Plotly, which is why it opened in the browser. However, for 
plots which open in their own window, you can try installing PyPlot, GR, 
PlotlyJS, etc.: just checkout the backend 
page: https://juliaplots.github.io/backends/.

I would recommend giving the PyPlot backend for Plots a try. 

On Saturday, August 27, 2016 at 5:15:27 PM UTC-7, K leo wrote:
>
> Thanks for the reply.
>
> I did try Plots.jl, and it appears all plots go to a browser window.  I 
> would still prefer plots have their own private window with sizes under 
> control.  Am I missing anything?
>
> Pkg.checkout("Winston") doesn't get me anything new.
>
>
> On Saturday, August 27, 2016 at 8:19:45 AM UTC+8, Chris Rackauckas wrote:
>>
>> You should really check out Plots.jl. It's a plotting metapackage which 
>> lets you use the same plot commands to use any backend. It's nice because 
>> if you're using it an one package stops getting updated, you can switch to 
>> another plotting backend without changing your plot commands.
>>
>> But I can see that, although Winston hasn't been tagged in almost a year, 
>> there has been some development work. Have you tried 
>> Pkg.checkout("Winston")?
>>
>> On Friday, August 26, 2016 at 3:04:22 PM UTC-7, K leo wrote:
>>>
>>> so that it works with version 0.5. 
>>
>>

[julia-users] Re: @inbounds macro scope, and @simd

2016-08-27 Thread Chris Rackauckas
Check out Matt B.'s in-depth answer 
here: 
http://stackoverflow.com/questions/38901275/inbounds-propagation-rules-in-julia

On Friday, August 26, 2016 at 10:43:08 AM UTC-7, Ben Ward wrote:
>
> Hi, Just wondering, I have the following doube loop:
>
> for site in 1:nsites
> votes[1] = votes[2] = votes[3] = votes[4] = votes[5] = 0
> for seq in 1:neqs
> nuc = mat[seq, site]
> votes[1] += iscompatible(nuc, DNA_A)
> votes[2] += iscompatible(nuc, DNA_C)
> votes[3] += iscompatible(nuc, DNA_G)
> votes[4] += iscompatible(nuc, DNA_T)
> votes[5] += iscompatible(nuc, DNA_Gap)
> end
> end
>
> Say I add an @inbounds macro to the outer loop to eliminate bounds checks, 
> will it's effects extend to setmatrix statements in the inner loop. 
> Inspecting the expanded macro I believe it is the case, as an @inbounds is 
> set to true, and then after the inner loop is popped. But I'm not 100% sure 
> if I am correct that is indeed how it works:
>
> *quote  # REPL[63], line 2:*
>
> *begin *
>
> *$(Expr(:inbounds, true))*
>
> *for site = 1:nsites # REPL[63], line 3:*
>
> *votes[1] = (votes[2] = (votes[3] = (votes[4] = (votes[5] = 
> 0 # REPL[63], line 4:*
>
> *for seq = 1:neqs # REPL[63], line 5:*
>
> *nuc = mat[seq,site] # REPL[63], line 6:*
>
> *votes[1] += iscompatible(nuc,DNA_A) # REPL[63], line 7:*
>
> *votes[2] += iscompatible(nuc,DNA_C) # REPL[63], line 8:*
>
> *votes[3] += iscompatible(nuc,DNA_G) # REPL[63], line 9:*
>
> *votes[4] += iscompatible(nuc,DNA_T) # REPL[63], line 10:*
>
> *votes[5] += iscompatible(nuc,DNA_Gap)*
>
> *end*
>
> *end*
>
> *$(Expr(:inbounds, :pop))*
>
> *end*
>
> *end*
>
> I'd also like someone's opinion. Will I benefit from @simd on the inner 
> loop?
>
> The function `iscompatible` is annotated with @inline, and has no 
> branching:
>
> @inline function iscompatible{T<:Nucleotide}(x::T, y::T)
> return compatbits(x) & compatbits(y) != 0
> end
>
> # Return the compatibility bits of `nt`.
> @inline function compatbits(nt::Nucleotide)
> return reinterpret(UInt8, nt)
> end
>
> As per the assumptions of an simd loop I read in the docs, each iteration 
> is independent, order does not matter.
> I'd just like some advice as if I'm right this will be the first time I 
> use a simd loop to speed up my loops. 
>
> Thanks,
> Ben.
>


[julia-users] Re: Can someone please update Winston?

2016-08-27 Thread K leo
Thanks for the reply.

I did try Plots.jl, and it appears all plots go to a browser window.  I 
would still prefer plots have their own private window with sizes under 
control.  Am I missing anything?

Pkg.checkout("Winston") doesn't get me anything new.


On Saturday, August 27, 2016 at 8:19:45 AM UTC+8, Chris Rackauckas wrote:
>
> You should really check out Plots.jl. It's a plotting metapackage which 
> lets you use the same plot commands to use any backend. It's nice because 
> if you're using it an one package stops getting updated, you can switch to 
> another plotting backend without changing your plot commands.
>
> But I can see that, although Winston hasn't been tagged in almost a year, 
> there has been some development work. Have you tried 
> Pkg.checkout("Winston")?
>
> On Friday, August 26, 2016 at 3:04:22 PM UTC-7, K leo wrote:
>>
>> so that it works with version 0.5. 
>
>

[julia-users] Re: @inbounds macro scope, and @simd

2016-08-27 Thread Blake Johnson
Yes, if you change the first line to

@inbounds for site in 1:nsites

Then that will declare everything inside that outer loop as being in 
bounds. If you'd like to make a more restricted declaration, than you 
should put it on specific lines inside the loop.

On Friday, August 26, 2016 at 1:43:08 PM UTC-4, Ben Ward wrote:
>
> Hi, Just wondering, I have the following doube loop:
>
> for site in 1:nsites
> votes[1] = votes[2] = votes[3] = votes[4] = votes[5] = 0
> for seq in 1:neqs
> nuc = mat[seq, site]
> votes[1] += iscompatible(nuc, DNA_A)
> votes[2] += iscompatible(nuc, DNA_C)
> votes[3] += iscompatible(nuc, DNA_G)
> votes[4] += iscompatible(nuc, DNA_T)
> votes[5] += iscompatible(nuc, DNA_Gap)
> end
> end
>
> Say I add an @inbounds macro to the outer loop to eliminate bounds checks, 
> will it's effects extend to setmatrix statements in the inner loop. 
> Inspecting the expanded macro I believe it is the case, as an @inbounds is 
> set to true, and then after the inner loop is popped. But I'm not 100% sure 
> if I am correct that is indeed how it works:
>
> *quote  # REPL[63], line 2:*
>
> *begin *
>
> *$(Expr(:inbounds, true))*
>
> *for site = 1:nsites # REPL[63], line 3:*
>
> *votes[1] = (votes[2] = (votes[3] = (votes[4] = (votes[5] = 
> 0 # REPL[63], line 4:*
>
> *for seq = 1:neqs # REPL[63], line 5:*
>
> *nuc = mat[seq,site] # REPL[63], line 6:*
>
> *votes[1] += iscompatible(nuc,DNA_A) # REPL[63], line 7:*
>
> *votes[2] += iscompatible(nuc,DNA_C) # REPL[63], line 8:*
>
> *votes[3] += iscompatible(nuc,DNA_G) # REPL[63], line 9:*
>
> *votes[4] += iscompatible(nuc,DNA_T) # REPL[63], line 10:*
>
> *votes[5] += iscompatible(nuc,DNA_Gap)*
>
> *end*
>
> *end*
>
> *$(Expr(:inbounds, :pop))*
>
> *end*
>
> *end*
>
> I'd also like someone's opinion. Will I benefit from @simd on the inner 
> loop?
>
> The function `iscompatible` is annotated with @inline, and has no 
> branching:
>
> @inline function iscompatible{T<:Nucleotide}(x::T, y::T)
> return compatbits(x) & compatbits(y) != 0
> end
>
> # Return the compatibility bits of `nt`.
> @inline function compatbits(nt::Nucleotide)
> return reinterpret(UInt8, nt)
> end
>
> As per the assumptions of an simd loop I read in the docs, each iteration 
> is independent, order does not matter.
> I'd just like some advice as if I'm right this will be the first time I 
> use a simd loop to speed up my loops. 
>
> Thanks,
> Ben.
>


[julia-users] Re: Hard time with Compat and 0.5

2016-08-27 Thread Steven G. Johnson


On Friday, August 26, 2016 at 9:15:23 PM UTC-4, J Luis wrote:
>
> Hi, 
> So I started trying to port my code to 0.5 using Compat and it seams a 
> hell is expecting me. 
> This is one example of what happens when I try to follow the deprecation 
> suggestions. This
>
> t = pointer_to_array(Gb.data, h.size)
> #@compat t = unsafe_wrap(Gb.data, h.size)
>
> warns that
>
> WARNING: pointer_to_array{T}(p::Ptr{T},d::Union{Integer,Tuple{Vararg{
> Integer}}},own::Bool=false) is deprecated, use unsafe_wrap(Array,p,d,own) 
> instead.
>  in depwarn(::String, ::Symbol) at .\deprecated.jl:64
>  in pointer_to_array(::Ptr{Float32}, ::UInt64, ::Bool) at .\deprecated.jl:
> 50 (repeats 2 times)
>  in GMTJL_grid_init(::Ptr{Void}, ::Bool, ::GMT.GMTJL_GRID, ::Array{Any,1}, 
> ::Array{Any,1}, ::Int64) at C:\j\.julia\v0.5\GMT\src\gmt_main.jl:1014
>
> so I make it
>
> @compat t = unsafe_wrap(Gb.data, h.size)
>

No, it is:

t = unsafe_wrap(Array, Gb.data, h.size)

as in the deprecation warning.

(You don't need @compat just for function calls.   You only need @compat 
for things where the syntax changes in a more complicated way.)


[julia-users] Re: ArrayFire.jl - GPU Programming in Julia

2016-08-27 Thread Douglas Bates
On Friday, August 26, 2016 at 6:08:13 PM UTC-5, Min-Woong Sohn wrote:
>
> Does anybody know of any plan to support ArrayFire in GLM or MixedModels 
> any time soon?
>

Do you have a particular application in mind or is this a general question? 
 For MixedModels I would say that, depending upon the configuration of the 
random-effects terms in a model there could be a great advantage or almost 
no advantage in using a GPU, so details are important.

We're always looking for challenging GLM or mixed-effects problems that can 
be used to tune up these packages.  If you have cases that seem to be 
taking a long time and would be suitable for parallel or GPU computing we 
would love to hear about them. 
 

> On Friday, June 10, 2016 at 1:08:42 AM UTC-4, ran...@juliacomputing.com 
> wrote:
>>
>> Hello, 
>>
>> We are pleased to announce ArrayFire.jl, a library for GPU and 
>> heterogeneous computing in Julia: (
>> https://github.com/JuliaComputing/ArrayFire.jl). We look forward to your 
>> feedback and your contributions as well! 
>>
>> For more information, check out Julia Computing's latest blog post: 
>> http://juliacomputing.com/blog/2016/06/09/julia-gpu.html
>>
>> Thanks,
>> Ranjan
>> Julia Computing, Inc. 
>>
>

[julia-users] RFC: Proposing to freeze METADATA for package versions that support Julia 0.3

2016-08-27 Thread Tony Kelman


In the interest of moving nightly PackageEvaluator testing to running 
against 0.4, 0.5, and 0.6-dev, I'm proposing we freeze METADATA for Julia 
0.3. New package versions that support Julia 0.3 would fail the Travis 
check, by default. We can make case-by-case exceptions if absolutely 
needed, but I believe this is the safest path forward to leaving Julia 0.3 
alone - what currently works should remain working, and nothing new could 
break by releasing some new package versions that do support 0.3 when other 
packages that may depend on that package have moved on to only supporting 
Julia 0.4 a while ago.


If you're a package author, check the minimum Julia version dependency in 
your REQUIRE file. If it already says 0.4 or later, you don't need to do 
anything. If it still says 0.3, this change would mean you should raise the 
minimum Julia version to (at least) 0.4 before making your next tag. And 
when you make that new tag, since it's dropping Julia 0.3 support it should 
use a new package minor version via Pkg.tag("Foo", :minor).

If anyone has any comments or objections, let me know at 
https://github.com/JuliaLang/METADATA.jl/pull/6146. I'll be leaving that 
open for at least a few days.



[julia-users] making julia REPL completions available to vim

2016-08-27 Thread a. kramer
I was playing around to try and allow vim access to tab-completions and 
documentation from the julia REPL. I managed to get something that seems to 
work, so I thought I would share it and see if anyone has comments. This is 
a hack, and I'm not a julia, vimscript, or 0mq expert, so I'm sure there 
are better ways to do things. I attached a file of what it looks like in 
action.

The following seems to work. Include this code in the julia REPL:

using ZMQ,JSON

#sends  REPL completions to vim using ZMQ.jl
function zmq_sendcompl(str,zmq_ctx,zmq_s,max_docstring,max_results)
compl = Base.REPLCompletions.completions(str,length(str))[1]

Nresults = min(length(compl),max_results)
#see :help complete-functions in vim for the information that can be 
passed to vim's completion functions
compldict = Array{Dict{String, String},1}(Nresults)
for di in 1:Nresults
if contains(str,".")
#add text before the ".", otherwise vim will overwrite it
entry = str[1:rsearchindex(str,".")]*compl[di]
else
entry = compl[di]
end
if di <= max_docstring
try
entrydoc = string(eval(parse("@doc "*entry)))
compldict[di] =  Dict("word" => entry, "info" => entrydoc)
catch
compldict[di] =  Dict("word" => entry, "info" => " ")
end
else
compldict[di] =  Dict("word" => entry, "info" => " ")
end
end

compljson = JSON.json(compldict)
ZMQ.send(zmq_s,compljson)
end

max_docstring = 50 #maximum number of docstring entries to return (set to 0 
for no docstrings)
max_results = 200 #maximum number of completion results to return
zmq_portnum = 5557

zmq_ctx = Context()
zmq_s = Socket(zmq_ctx, REP)
@async begin
try
ZMQ.bind(zmq_s, "tcp://*:" * string(zmq_portnum))

while true
msg = ZMQ.recv(zmq_s)
out = convert(IOStream, msg)
str = takebuf_string(out)
zmq_sendcompl(str,zmq_ctx,zmq_s,max_docstring,max_results)
end
catch
warn("ZMQ connection to port ",zmq_portnum," failed")
end
ZMQ.close(zmq_s)
ZMQ.close(zmq_ctx)
end

The code uses ZMQ.jl to listen for a string that represents something that 
vim is trying to complete. It then uses Base.REPLCompletions to get the 
completions. It also gets the docstrings and passes everything back as a 
JSON string. Is there a better way to get the docstrings?

On the vim side, place this code in ~/.vim/ftplugin/julia.vim. This 
requires a couple things:
1) A command to make the 0mq request. The simplest one I could find was 
here: https://github.com/plq/zmq, the zmq executable needs to be in your 
PATH.
2) I used a simple call to netstat to make sure that julia is listening, 
but I'm sure there's a better way to do it. And I'm sure the code for 
finding the beginning of the word could be better.
3) If you want to include local completions (strings in the current file) 
alongside those from the REPL, you need 
https://github.com/vim-scripts/CompleteHelper (which requires 
https://github.com/vim-scripts/ingo-library). To include them, uncomment 
the line that calls CompleteHelper.

let g:zmq_portnum = 5557
>
> if exists('g:JLcompletefunc_loaded')
> finish
> endif
> let g:JLcompletefunc_loaded = 1
>
> function JLcompletefunc(findstart,base)
> if a:findstart
> "find current word
> let cursorcol = col('.')
>
> if cursorcol == 1
> return 0
> endif
>
> "get current line
> let line = getline('.')
> "only keep up to the cursor position
> let line = strpart(line,0,cursorcol-1)
> "replace everything except alphanumeric, underscores, and periods 
> with whitespace
> let line = substitute(line,"[^.A-za-z0-9]",' ','g')
> let line = substitute(line,'\^\|\[\|\]',' ','g')
> let prevchar = matchstr(line, '\%' . (cursorcol-1) . 'c.')
> if prevchar == ' '
> return cursorcol
> end
>
> let wordstart = cursorcol
> let linesplit = split(line)
> if len(linesplit) > 0
> let curword = linesplit[-1]
> let wordstart = cursorcol-strlen(curword)-1
> endif
>
> if wordstart < 0
> wordstart = 0
> endif
>
> return wordstart
> else
> "remove everything except alphanumeric, underscores, and periods
> let newbase = substitute(a:base,"[^.A-za-z0-9]",'','g')
> let newbase = substitute(newbase,'\^\|\[\|\]','','g')
> if (strlen(newbase) == 0) || (newbase == ' ')
> return ''
> endif
>
> "get list of keyword completions from the current file using 
> CompleteHelper (comment out if not desired)
> let keywordcompl = []
> "call CompleteHelper#FindMatches(keywordcompl,'\V\<' . 
> escape(newbase, '') . '\k\+',{'complete': '.'})
>
> "check if 

[julia-users] Re: Syntax to create nested types in Julia

2016-08-27 Thread Cedric St-Jean
Your code looks like a good start.

type PhysicalNode{T}
ID::Int
name::AbstractString
x::Float64
y::Float64
inEdges::Vector{T} 
outEdges::Vector{T}
demands::Vector{Any}   # ?
end

type Edge{T}
...
end

function addInEdge!(pn::PhysicalNode, edge::Edge):
push!(pn.inEdges, edge)
end

... etc

If you're just starting out with Julia, I would advise you to leave your 
type fields untyped. You'll get fewer headaches that way. Chances are that 
it'll be fast enough for your purposes already, and you can always add 
types once your code works.

Cédric

On Saturday, August 27, 2016 at 5:27:32 AM UTC-4, Jeffrey Sarnoff wrote:
>
> In an object-oriented language, an instance of a class is an element of 
> computation (1 is an instance of the class Integer, and Integer is a 
> subclass of Number).
> In a type-guided language, a realization of a type is an element of 
> computation (1 is a realization of type Int, and type Int is a subtype of 
> Integer and of Number).
> The work done through the use of classes is taken up through types and 
> methods defined on/over types.  There is no "better" general alternative 
> for translating class-based design than applying Julia's types and methods. 
>  A better question: "How should I define PhysicalNodes in Julia differently 
> than I did in Python?"
>
>
>
>
>
>
> On Saturday, August 27, 2016 at 2:52:24 AM UTC-4, varu...@gmail.com wrote:
>>
>> What are the alternatives to using classes in Julia apart from types? Can 
>> you please explain how I can define the PhysicalNodes class in Julia the 
>> same way like I did in python?
>>
>> On Friday, 26 August 2016 23:16:39 UTC+2, Cedric St-Jean wrote:
>>>
>>> It's not possible in Julia at the moment. There's an issue for it. 
>>>  I think the main 
>>> options are:
>>>
>>> - Don't declare the types. This may make it slower, but depending on the 
>>> use case it might not be a big deal
>>> - Use parametric types, i.e.
>>>
>>> type Node{T}
>>>edges::Vector{T}
>>> end
>>>
>>> type Edge{T}
>>>node::T
>>> end
>>>
>>>
>>>
>>> On Friday, August 26, 2016 at 1:38:38 PM UTC-4, varu...@gmail.com wrote:

 Hello all,

 I'm making a transition from Python to Julia and in the process, I've 
 encountered a small difficulty. While in python, i declared three classes 
 as follows:

 class PHY_NODES:
 def __init__(self, nodeID, nodenum, x, y, demands):
 self.id = nodeID
 self.nodenum = nodenum
 self.x = x
 self.y = y
 self.inEdges = []
 self.outEdges = []
 self.demands = demands

 def __str__(self):
 return "Physical Node ID: nodenum: %4d x: %.3f y: %.3f" %(
 self.id, self.nodenum, self.x, self.y )

 def addInEdge(self, edge):
 self.inEdges.append( edge )

 def addOutEdge(self, edge):
 self.outEdges.append( edge )

 
 class PHY_LINKS:
 def __init__(self, linkID, source, destination, SourceID, 
 DestinationID,):
 self.linkID = linkID
 self.source = source
 self.destination = destination
 self.SourceID = SourceID
 self.DestinationID = DestinationID

 
 def __str__(self):
 return "Physical Link ID: %4d source: %s destination: %s 
 SourceID: %4d DestinationID: %4d " %(self.linkID, self.source, 
 self.destination, self.SourceID, self.DestinationID, )


 class DEMAND:
 def __init__(self, PoP_bdw_up, PoP_stor, PoP_pro, MME_bdw_up, 
 MME_stor, MME_pro,demandID):
 self.PoP_bdw_up = PoP_bdw_up
 self.PoP_stor = PoP_stor
 self.PoP_pro = PoP_pro
 self.MME_bdw_up = MME_bdw_up
 self.MME_stor = MME_stor
 self.MME_pro = MME_pro
 self.demandID = demandID

 
 def __str__(self):
 return " PoPbdwup: %.3f PoPstor: %.3f PoPpro: %.3f MMEbdwup: 
 %.3f MMEstor: %.3f MMEpro: %.3f, self.demandID )

 However, I have some trouble when replicating the same in Julia 
 especially due to the nested classes in PHY_NODES (self.inEdges as well as 
 self,demands)

 The Julia version of the Phy_Node class is as below:

 type PhysicalNodes
 ID:Int
 name:String
 x: Float
 y:Float
 inEdges: ?
 outEdges: ?
 demands: ?
 end

 I don't how to declare the inEdges, outEdges and demands here. Could 
 you please help me with this?



Re: [julia-users] Blob detection and size measurement in Julia?

2016-08-27 Thread Tim Holy
Good catch. Looks like the edge-handling in `findlocalmaxima` needed to be a 
bit more refined---it was discarding results from the first and last sigma-
values supplied by the user.

I may have fixed this in https://github.com/timholy/Images.jl/commit/
7336f35c824b15de9e4d0def8e739bdeb6ed3b3d, can you do `Pkg.checkout("Images")` 
and test?

Best,
--Tim

On Friday, August 26, 2016 8:11:44 PM CDT Alex Mellnik wrote:
> Hi,
> 
> I'm attempting to measure the size and position of roughly spherical,
> well-defined objects in images using Julia.  I don't have any previous
> experience working with images and was wondering if anyone could point me
> toward the appropriate library/function.
> 
> I know that there's a blob_LoG
>  oG> in Images.jl which appears to do roughly what I'm interested in, but I
> may be mistaken and it looks my images will need pre-processing as I
> haven't yet been able to get a non-null result.  There's also the new
> ImageFeatures.jl and bindings for OpenCV, but neither have much in the way
> of documentation yet.
> 
> Thanks for any suggestions you can provide,
> 
> Alex




[julia-users] How should I define PhysicalNodes class in Julia differently than I did in Python

2016-08-27 Thread varun7rs
HI,

Previously, I had posted a question asking for some clarification regarding 
the usage of types in Julia to suit the problem at hand. I had used 
Python's classes for the problem and I would like to know how I can define 
PhysicalNodes and PhysicalLinks classes in Julia differently than I did in 
Python (as suggested By Jeffrey) So I request your help for the same. 
Thanks a lot guys

The python code is as follows:

class PHY_NODES:
def __init__(self, nodeID, nodenum, x, y, demands):
self.id = nodeID
self.nodenum = nodenum
self.x = x
self.y = y
self.inEdges = []
self.outEdges = []
self.demands = demands

def __str__(self):
return "Physical Node ID: nodenum: %4d x: %.3f y: %.3f" %(self.id, 
self.nodenum, self.x, self.y )

def addInEdge(self, edge):
self.inEdges.append( edge )

def addOutEdge(self, edge):
self.outEdges.append( edge )


class PHY_LINKS:
def __init__(self, linkID, source, destination, SourceID, 
DestinationID,):
self.linkID = linkID
self.source = source
self.destination = destination
self.SourceID = SourceID
self.DestinationID = DestinationID


def __str__(self):
return "Physical Link ID: %4d source: %s destination: %s SourceID: 
%4d DestinationID: %4d " %(self.linkID, self.source, self.destination, 
self.SourceID, self.DestinationID, )


class DEMAND:
def __init__(self, PoP_bdw_up, PoP_stor, PoP_pro, MME_bdw_up, MME_stor, 
MME_pro,demandID):
self.PoP_bdw_up = PoP_bdw_up
self.PoP_stor = PoP_stor
self.PoP_pro = PoP_pro
self.MME_bdw_up = MME_bdw_up
self.MME_stor = MME_stor
self.MME_pro = MME_pro
self.demandID = demandID


def __str__(self):
return " PoPbdwup: %.3f PoPstor: %.3f PoPpro: %.3f MMEbdwup: %.3f 
MMEstor: %.3f MMEpro: %.3f, self.demandID )


[julia-users] Re: Syntax to create nested types in Julia

2016-08-27 Thread varun7rs
Thanks Jeffrey. So, should I close this post and ask a new question as you 
suggested?

On Saturday, 27 August 2016 11:27:32 UTC+2, Jeffrey Sarnoff wrote:
>
> In an object-oriented language, an instance of a class is an element of 
> computation (1 is an instance of the class Integer, and Integer is a 
> subclass of Number).
> In a type-guided language, a realization of a type is an element of 
> computation (1 is a realization of type Int, and type Int is a subtype of 
> Integer and of Number).
> The work done through the use of classes is taken up through types and 
> methods defined on/over types.  There is no "better" general alternative 
> for translating class-based design than applying Julia's types and methods. 
>  A better question: "How should I define PhysicalNodes in Julia differently 
> than I did in Python?"
>
>
>
>
>
>
> On Saturday, August 27, 2016 at 2:52:24 AM UTC-4, varu...@gmail.com wrote:
>>
>> What are the alternatives to using classes in Julia apart from types? Can 
>> you please explain how I can define the PhysicalNodes class in Julia the 
>> same way like I did in python?
>>
>> On Friday, 26 August 2016 23:16:39 UTC+2, Cedric St-Jean wrote:
>>>
>>> It's not possible in Julia at the moment. There's an issue for it. 
>>>  I think the main 
>>> options are:
>>>
>>> - Don't declare the types. This may make it slower, but depending on the 
>>> use case it might not be a big deal
>>> - Use parametric types, i.e.
>>>
>>> type Node{T}
>>>edges::Vector{T}
>>> end
>>>
>>> type Edge{T}
>>>node::T
>>> end
>>>
>>>
>>>
>>> On Friday, August 26, 2016 at 1:38:38 PM UTC-4, varu...@gmail.com wrote:

 Hello all,

 I'm making a transition from Python to Julia and in the process, I've 
 encountered a small difficulty. While in python, i declared three classes 
 as follows:

 class PHY_NODES:
 def __init__(self, nodeID, nodenum, x, y, demands):
 self.id = nodeID
 self.nodenum = nodenum
 self.x = x
 self.y = y
 self.inEdges = []
 self.outEdges = []
 self.demands = demands

 def __str__(self):
 return "Physical Node ID: nodenum: %4d x: %.3f y: %.3f" %(
 self.id, self.nodenum, self.x, self.y )

 def addInEdge(self, edge):
 self.inEdges.append( edge )

 def addOutEdge(self, edge):
 self.outEdges.append( edge )

 
 class PHY_LINKS:
 def __init__(self, linkID, source, destination, SourceID, 
 DestinationID,):
 self.linkID = linkID
 self.source = source
 self.destination = destination
 self.SourceID = SourceID
 self.DestinationID = DestinationID

 
 def __str__(self):
 return "Physical Link ID: %4d source: %s destination: %s 
 SourceID: %4d DestinationID: %4d " %(self.linkID, self.source, 
 self.destination, self.SourceID, self.DestinationID, )


 class DEMAND:
 def __init__(self, PoP_bdw_up, PoP_stor, PoP_pro, MME_bdw_up, 
 MME_stor, MME_pro,demandID):
 self.PoP_bdw_up = PoP_bdw_up
 self.PoP_stor = PoP_stor
 self.PoP_pro = PoP_pro
 self.MME_bdw_up = MME_bdw_up
 self.MME_stor = MME_stor
 self.MME_pro = MME_pro
 self.demandID = demandID

 
 def __str__(self):
 return " PoPbdwup: %.3f PoPstor: %.3f PoPpro: %.3f MMEbdwup: 
 %.3f MMEstor: %.3f MMEpro: %.3f, self.demandID )

 However, I have some trouble when replicating the same in Julia 
 especially due to the nested classes in PHY_NODES (self.inEdges as well as 
 self,demands)

 The Julia version of the Phy_Node class is as below:

 type PhysicalNodes
 ID:Int
 name:String
 x: Float
 y:Float
 inEdges: ?
 outEdges: ?
 demands: ?
 end

 I don't how to declare the inEdges, outEdges and demands here. Could 
 you please help me with this?



[julia-users] Re: Pkg.update() error, 0.4.6

2016-08-27 Thread Andreas Lobinger
Hello colleague,

On Saturday, August 27, 2016 at 9:20:32 AM UTC+2, Liye zhang wrote:
>
> Julia and its packages are installed using the network at my home. When I 
> try to install new package using the network in my company, there are 
> errors as mentioned above.
>
> When I update using the network at home, there is no error.  So, is this 
> error caused by the change of the IP, which would be used by git of Julia 
> package system ?
>
> This error occurred many times. Could anyone give me some help? 
>

company networks usually are firewalled and proxied to the outside 
internet. So it's not the change of IP only.
You can check, if running 

git config --global url."https://@".insteadOf git://

on a shell solves this for you (it did for me)



[julia-users] Re: Syntax to create nested types in Julia

2016-08-27 Thread Jeffrey Sarnoff
In an object-oriented language, an instance of a class is an element of 
computation (1 is an instance of the class Integer, and Integer is a 
subclass of Number).
In a type-guided language, a realization of a type is an element of 
computation (1 is a realization of type Int, and type Int is a subtype of 
Integer and of Number).
The work done through the use of classes is taken up through types and 
methods defined on/over types.  There is no "better" general alternative 
for translating class-based design than applying Julia's types and methods. 
 A better question: "How should I define PhysicalNodes in Julia differently 
than I did in Python?"






On Saturday, August 27, 2016 at 2:52:24 AM UTC-4, varu...@gmail.com wrote:
>
> What are the alternatives to using classes in Julia apart from types? Can 
> you please explain how I can define the PhysicalNodes class in Julia the 
> same way like I did in python?
>
> On Friday, 26 August 2016 23:16:39 UTC+2, Cedric St-Jean wrote:
>>
>> It's not possible in Julia at the moment. There's an issue for it. 
>>  I think the main options 
>> are:
>>
>> - Don't declare the types. This may make it slower, but depending on the 
>> use case it might not be a big deal
>> - Use parametric types, i.e.
>>
>> type Node{T}
>>edges::Vector{T}
>> end
>>
>> type Edge{T}
>>node::T
>> end
>>
>>
>>
>> On Friday, August 26, 2016 at 1:38:38 PM UTC-4, varu...@gmail.com wrote:
>>>
>>> Hello all,
>>>
>>> I'm making a transition from Python to Julia and in the process, I've 
>>> encountered a small difficulty. While in python, i declared three classes 
>>> as follows:
>>>
>>> class PHY_NODES:
>>> def __init__(self, nodeID, nodenum, x, y, demands):
>>> self.id = nodeID
>>> self.nodenum = nodenum
>>> self.x = x
>>> self.y = y
>>> self.inEdges = []
>>> self.outEdges = []
>>> self.demands = demands
>>>
>>> def __str__(self):
>>> return "Physical Node ID: nodenum: %4d x: %.3f y: %.3f" %(
>>> self.id, self.nodenum, self.x, self.y )
>>>
>>> def addInEdge(self, edge):
>>> self.inEdges.append( edge )
>>>
>>> def addOutEdge(self, edge):
>>> self.outEdges.append( edge )
>>>
>>> 
>>> class PHY_LINKS:
>>> def __init__(self, linkID, source, destination, SourceID, 
>>> DestinationID,):
>>> self.linkID = linkID
>>> self.source = source
>>> self.destination = destination
>>> self.SourceID = SourceID
>>> self.DestinationID = DestinationID
>>>
>>> 
>>> def __str__(self):
>>> return "Physical Link ID: %4d source: %s destination: %s 
>>> SourceID: %4d DestinationID: %4d " %(self.linkID, self.source, 
>>> self.destination, self.SourceID, self.DestinationID, )
>>>
>>>
>>> class DEMAND:
>>> def __init__(self, PoP_bdw_up, PoP_stor, PoP_pro, MME_bdw_up, 
>>> MME_stor, MME_pro,demandID):
>>> self.PoP_bdw_up = PoP_bdw_up
>>> self.PoP_stor = PoP_stor
>>> self.PoP_pro = PoP_pro
>>> self.MME_bdw_up = MME_bdw_up
>>> self.MME_stor = MME_stor
>>> self.MME_pro = MME_pro
>>> self.demandID = demandID
>>>
>>> 
>>> def __str__(self):
>>> return " PoPbdwup: %.3f PoPstor: %.3f PoPpro: %.3f MMEbdwup: 
>>> %.3f MMEstor: %.3f MMEpro: %.3f, self.demandID )
>>>
>>> However, I have some trouble when replicating the same in Julia 
>>> especially due to the nested classes in PHY_NODES (self.inEdges as well as 
>>> self,demands)
>>>
>>> The Julia version of the Phy_Node class is as below:
>>>
>>> type PhysicalNodes
>>> ID:Int
>>> name:String
>>> x: Float
>>> y:Float
>>> inEdges: ?
>>> outEdges: ?
>>> demands: ?
>>> end
>>>
>>> I don't how to declare the inEdges, outEdges and demands here. Could you 
>>> please help me with this?
>>>
>>>

[julia-users] Re: Pkg.update() error, 0.4.6

2016-08-27 Thread Liye zhang
Julia and its packages are installed using the network at my home. When I 
try to install new package using the network in my company, there are 
errors as mentioned above.

When I update using the network at home, there is no error.  So, is this 
error caused by the change of the IP, which would be used by git of Julia 
package system ?

This error occurred many times. Could anyone give me some help? 

On Wednesday, August 24, 2016 at 8:52:35 AM UTC+8, Liye zhang wrote:
>
> When I run Pkg.update(), I got the following error:
>
> fata;: read error: Invalid argument
>  ERROR: failed process: Process('git pull --rebase -q', ProcessExited(1)) 
> [1] in pipeline_error at process.jl:555
>
> windows 7, Julia0.4.6
>


[julia-users] Re: Hard time with Compat and 0.5

2016-08-27 Thread DNF
In the first one you are passing in [X.name...] while in the other one you 
are passing in X.name.

Could you not just write:
name = String([X.name...])



On Saturday, August 27, 2016 at 3:29:32 AM UTC+2, J Luis wrote:
>
> Ok, I figured that one (Really needed a first argument 'Array')
>
> But now this
>
> @show(typeof(X.name))
> name = bytestring([X.name...])
>
> typeof(X.name) = Tuple{UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,
> UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8}
> WARNING: bytestring(v::Vector{UInt8}) is deprecated, use String(copy(v)) 
> instead.
>
> changing to as suggested
>
> @compat String(copy(X.name))
>
> yields
>
> WARNING: copy(x::Tuple) is deprecated, use identity(x) instead.
>  in depwarn(::String, ::Symbol) at .\deprecated.jl:64
>  in copy(::Tuple{UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,
> UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8}) at .\deprecated.jl:50
>  in GMTJL_Set_Object(::Ptr{Void}, ::GMT.GMT_RESOURCE, ::Array{Any,1}) at C
> :\j\.julia\v0.5\GMT\src\gmt_main.jl:890
>  in gmt(::String) at C:\j\.julia\v0.5\GMT\src\gmt_main.jl:230
>  in ex02(::String, ::String) at C:\j\.julia\v0.5\GMT\test\gallery.jl:108
>  in gallery(::String, ::String, ::String) at C:\j\.julia\v0.5\GMT\test\
> gallery.jl:22
>  in gallery(::String) at C:\j\.julia\v0.5\GMT\test\gallery.jl:14
>  in eval(::Module, ::Any) at .\boot.jl:234
>  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:46
> while loading no file, in expression starting on line 0
> ERROR: MethodError: Cannot `convert` an object of type Tuple{UInt8,UInt8,
> UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,
> UInt8,UInt8} to an object of type String
> This may have arisen from a call to the constructor String(...),
> since type constructors fall back to convert methods.
>
>
>
>

[julia-users] Re: Syntax to create nested types in Julia

2016-08-27 Thread varun7rs
What are the alternatives to using classes in Julia apart from types? Can 
you please explain how I can define the PhysicalNodes class in Julia the 
same way like I did in python?

On Friday, 26 August 2016 23:16:39 UTC+2, Cedric St-Jean wrote:
>
> It's not possible in Julia at the moment. There's an issue for it. 
>  I think the main options 
> are:
>
> - Don't declare the types. This may make it slower, but depending on the 
> use case it might not be a big deal
> - Use parametric types, i.e.
>
> type Node{T}
>edges::Vector{T}
> end
>
> type Edge{T}
>node::T
> end
>
>
>
> On Friday, August 26, 2016 at 1:38:38 PM UTC-4, varu...@gmail.com wrote:
>>
>> Hello all,
>>
>> I'm making a transition from Python to Julia and in the process, I've 
>> encountered a small difficulty. While in python, i declared three classes 
>> as follows:
>>
>> class PHY_NODES:
>> def __init__(self, nodeID, nodenum, x, y, demands):
>> self.id = nodeID
>> self.nodenum = nodenum
>> self.x = x
>> self.y = y
>> self.inEdges = []
>> self.outEdges = []
>> self.demands = demands
>>
>> def __str__(self):
>> return "Physical Node ID: nodenum: %4d x: %.3f y: %.3f" %(self.id, 
>> self.nodenum, self.x, self.y )
>>
>> def addInEdge(self, edge):
>> self.inEdges.append( edge )
>>
>> def addOutEdge(self, edge):
>> self.outEdges.append( edge )
>>
>> 
>> class PHY_LINKS:
>> def __init__(self, linkID, source, destination, SourceID, 
>> DestinationID,):
>> self.linkID = linkID
>> self.source = source
>> self.destination = destination
>> self.SourceID = SourceID
>> self.DestinationID = DestinationID
>>
>> 
>> def __str__(self):
>> return "Physical Link ID: %4d source: %s destination: %s 
>> SourceID: %4d DestinationID: %4d " %(self.linkID, self.source, 
>> self.destination, self.SourceID, self.DestinationID, )
>>
>>
>> class DEMAND:
>> def __init__(self, PoP_bdw_up, PoP_stor, PoP_pro, MME_bdw_up, 
>> MME_stor, MME_pro,demandID):
>> self.PoP_bdw_up = PoP_bdw_up
>> self.PoP_stor = PoP_stor
>> self.PoP_pro = PoP_pro
>> self.MME_bdw_up = MME_bdw_up
>> self.MME_stor = MME_stor
>> self.MME_pro = MME_pro
>> self.demandID = demandID
>>
>> 
>> def __str__(self):
>> return " PoPbdwup: %.3f PoPstor: %.3f PoPpro: %.3f MMEbdwup: %.3f 
>> MMEstor: %.3f MMEpro: %.3f, self.demandID )
>>
>> However, I have some trouble when replicating the same in Julia 
>> especially due to the nested classes in PHY_NODES (self.inEdges as well as 
>> self,demands)
>>
>> The Julia version of the Phy_Node class is as below:
>>
>> type PhysicalNodes
>> ID:Int
>> name:String
>> x: Float
>> y:Float
>> inEdges: ?
>> outEdges: ?
>> demands: ?
>> end
>>
>> I don't how to declare the inEdges, outEdges and demands here. Could you 
>> please help me with this?
>>
>>

[julia-users] Re: Function only causes segfaults inside package...?

2016-08-27 Thread Chris Rackauckas
Hello everyone,
  I narrowed down the issue to a small example. Check out this repo which 
causes the segfault in just a few lines. 
 An issue for it has 
been posted on JuliaLang. 

On Saturday, August 20, 2016 at 9:57:28 AM UTC-7, Chris Rackauckas wrote:
>
> I was implementing a bunch of Runge-Kutta tableaus and ran into an issue. 
> Specific tableaus which are defined inside of a function inside of 
> DifferentialEquations.jl cause segfaults, but those exact same functions 
> will not segfault when not inside the package. For example, the code (on 
> master):
>
> using DifferentialEquations
> constructVern6()
>
> causes segfaults (the Windows and Linux versions at the bottom of the 
> post) (tested on v0.5 and v0.6). However, I can take that same function:
>
> function constructVern6(T::Type = Float64)
>   c1   =T(3//50)
>   c2   =T(1439//15000)
>   c3   =T(1439//1)
>   c4   =T(4973//1)
>   c5   =T(389//400)
>   c6   =T(1999//2000)
>   a21  =T(3//50)
>   a31  =T(519479//2700)
>   a32  =T(2070721//2700)
>   a41  =T(1439//4)
>   a43  =T(4317//4)
>   a51  =T(109225017611//8282884)
>   a53  =T(-417627820623//8282884)
>   a54  =T(43699198143//10353605000)
>   a61  =T(-8036815292643907349452552172369//191934985946683241245914401600)
>   a63  =T(246134619571490020064824665//1543816496655405117602368)
>   a64  =T(-13880495956885686234074067279//113663489566254201783474344)
>   a65  =T(75500505788994734129//136485922925633667082436)
>   a71 
>  
> =T(-166329984156610209718050498880934230261//30558424506156170307020957791311384232000)
>   a73 
>  =T(130838124195285491799043628811093033//631862949514135618861563657970240)
>   a74 
>  
> =T(-3287100453856023634160618787153901962873//20724314915376755629135711026851409200)
>   a75 
>  =T(2771826790140332140865242520369241//396438716042723436917079980147600)
>   a76  =T(-1799166916139193//96743806114007800)
>   a81 
>  
> =T(-832144750039369683895428386437986853923637763//15222974550069600748763651844667619945204887)
>   a83 
>  =T(818622075710363565982285196611368750//3936576237903728151856072395343129)
>   a84 
>  
> =T(-9818985165491658464841194581385463434793741875//61642597962658994069869370923196463581866011)
>   a85 
>  
> =T(31796692141848558720425711042548134769375//4530254033500045975557858016006308628092)
>   a86  =T(-14064542118843830075//766928748264306853644)
>   a87  =T(-1424670304836288125//2782839104764768088217)
>   a91  =T(382735282417//11129397249634)
>   a94  =T(5535620703125000//21434089949505429)
>   a95  =T(13867056347656250//32943296570459319)
>   a96  =T(626271188750//142160006043)
>   a97  =T(-51160788125000//289890548217)
>   a98  =T(163193540017//946795234)
>   b1   =T(124310637869885675646798613//2890072468789466426596827670)
>   b4   =T(265863151737164990361330921875//1113197271463372303940319369579)
>   b5   =T(3075493557174030806536302953125//6843749922042323876546949699876)
>   b6   =T(6779808733879813263055//29532792147666737550036372)
>   b7   =T(-1099436585155390846238326375//15055706496446408859196167)
>   b8   =T(26171252653086373181571802//368794478890732346033505)
>   b9   =T(1//30)
>
>   return 
> c1,c2,c3,c4,c5,c6,a21,a31,a32,a41,a43,a51,a53,a54,a61,a63,a64,a65,a71,a73,a74,a75,a76,a81,a83,a84,a85,a86,a87,a91,a94,a95,a96,a97,a98,b1,b4,b5,b6,b7,b8,b9
> end
>
> put it in a script, run it, and call the function without segfaulting. I 
> can even put that in a module without segfaulting!
>
> I have been able to pin down the issue to be due to methods which look 
> like this and include items that would be parsed as Rational{BigInt}. Any 
> tableaus which are parsed to BigFloats or Rational{Int} don't have this 
> issue. So it has something to do with the giant rationals (I have a few 
> more examples if needed). @Ismael-VC noted that when he deleted his lib and 
> v0.6 folders and re-installed, the error went away for him (that did not 
> work for me). Thus I am thinking it may have to do with precompilation? 
> Note that my precompiling hinting file does not hint these functions since 
> they are brand new.
>
> I will likely file an issue on the julialang issue if I can pinpoint the 
> example to something which doesn't require installing 
> DifferentialEquations.jl (because it is a large package). However, as I 
> previously noted, I cannot re-create this outside of the package for some 
> reason! Any help would be great!
>
> P.S. For those that are curious, DifferentialEquations.jl does contain 
> over 100 ODE solver algorithms now 
> ,
>  
> with each having convergence tests (except for the handful with this 
> segfault problem)!
>
> -
>
> Linux Segfault Message:
>
> signal (11): Segmentation fault
> while loading console, in