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

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

On Tue, 2016-01-05 at 06:08, Ismael Venegas Castelló  
wrote:
>
>- What exactly are these SimpleVectors?
>- Why show them as svec?
>- What's their purpose?
>- How to use SimpleVector constructor manually, without using Core.svec?
>
>
> They are not documented at all. All I understand is that they are svec is
> not generic but "intrinsic" / "builtin", I think they are used earlier in
> bootstrap?
>
> Since they don't work with @which, an @whereis kinda macro would be nice to
> give a link to their source code in github, even if it's in C or whatever.
> IMHO we should really differentiate all this "anonymous" (that's what
> typeof tell you) functions and document them.
>
> Couldn't we just wrap them in Julia functions and treat them as the rest?
>
> julia> svec(args...) = Core.svec(args...)
> svec (generic function with 1 method)
>
> julia> svec(1)
> svec(1)


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

2016-01-04 Thread Ismael Venegas Castelló
This would also allow to use @which, `methods` and other reflection 
functions.

El lunes, 4 de enero de 2016, 23:25:29 (UTC-6), Ismael Venegas Castelló 
escribió:
>
> I feel we should either differentiate them or integrate them better, they 
> are not listed anywhere, Steffan provided a complicated way of getting a 
> list of those:
>
> function builtins()
>nams = filter(s -> isdefined(Base, s), names(Base, true, true))
>objs   = map(s -> Base.(s), nams)
>funcs = filter(x -> isa(x, Function) && isa(x.env, Symbol), objs)
>convert(Vector{Symbol}, sort!(map(symbol, unique(funcs
> end
>
> julia> builtins()
> 22-element Array{Symbol,1}:
> :_apply
> :_expr
> :applicable
> :apply_type
> :arrayref
> :arrayset
> :arraysize
> :fieldtype
> :getfield
> :invoke
> ⋮
> :isdefined
> :issubtype
> :kwcall
> :nfields
> :setfield!
> :svec
> :throw
> :tuple
> :typeassert
> :typeof
>
> Here: https://groups.google.com/forum/#!topic/julia-users/m_5t0-bIJ8c
>
> I think that it would be possible to change the names of those builtins to 
> __ instead of , and then in boot.jl, have the julian 
> definitions like (args::types) = __(args). So it would be 
> possible to extend such functions.
>
>
> El lunes, 4 de enero de 2016, 23:08:52 (UTC-6), Ismael Venegas Castelló 
> escribió:
>>
>>
>>- What exactly are these SimpleVectors?
>>- Why show them as svec?
>>- What's their purpose? 
>>- How to use SimpleVector constructor manually, without using 
>>Core.svec? 
>>
>>
>> They are not documented at all. All I understand is that they are svec is 
>> not generic but "intrinsic" / "builtin", I think they are used earlier in 
>> bootstrap?
>>
>> Since they don't work with @which, an @whereis kinda macro would be nice 
>> to give a link to their source code in github, even if it's in C or 
>> whatever. IMHO we should really differentiate all this "anonymous" (that's 
>> what typeof tell you) functions and document them.
>>
>> Couldn't we just wrap them in Julia functions and treat them as the rest?
>>
>> julia> svec(args...) = Core.svec(args...)
>> svec (generic function with 1 method)
>>
>> julia> svec(1)
>> svec(1)
>>
>

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

2016-01-04 Thread Ismael Venegas Castelló
I feel we should either differentiate them or integrate them better, they 
are not listed anywhere, Steffan provided a complicated way of getting a 
list of those:

function builtins()
   nams = filter(s -> isdefined(Base, s), names(Base, true, true))
   objs   = map(s -> Base.(s), nams)
   funcs = filter(x -> isa(x, Function) && isa(x.env, Symbol), objs)
   convert(Vector{Symbol}, sort!(map(symbol, unique(funcs
end

julia> builtins()
22-element Array{Symbol,1}:
:_apply
:_expr
:applicable
:apply_type
:arrayref
:arrayset
:arraysize
:fieldtype
:getfield
:invoke
⋮
:isdefined
:issubtype
:kwcall
:nfields
:setfield!
:svec
:throw
:tuple
:typeassert
:typeof

Here: https://groups.google.com/forum/#!topic/julia-users/m_5t0-bIJ8c

I think that it would be possible to change the names of those builtins to 
__ instead of , and then in boot.jl, have the julian 
definitions like (args::types) = __(args). So it would be 
possible to extend such functions.


El lunes, 4 de enero de 2016, 23:08:52 (UTC-6), Ismael Venegas Castelló 
escribió:
>
>
>- What exactly are these SimpleVectors?
>- Why show them as svec?
>- What's their purpose? 
>- How to use SimpleVector constructor manually, without using 
>Core.svec? 
>
>
> They are not documented at all. All I understand is that they are svec is 
> not generic but "intrinsic" / "builtin", I think they are used earlier in 
> bootstrap?
>
> Since they don't work with @which, an @whereis kinda macro would be nice 
> to give a link to their source code in github, even if it's in C or 
> whatever. IMHO we should really differentiate all this "anonymous" (that's 
> what typeof tell you) functions and document them.
>
> Couldn't we just wrap them in Julia functions and treat them as the rest?
>
> julia> svec(args...) = Core.svec(args...)
> svec (generic function with 1 method)
>
> julia> svec(1)
> svec(1)
>


[julia-users] Why SimpleVector / svec?

2016-01-04 Thread Ismael Venegas Castelló

   
   - What exactly are these SimpleVectors?
   - Why show them as svec?
   - What's their purpose? 
   - How to use SimpleVector constructor manually, without using Core.svec? 
   

They are not documented at all. All I understand is that they are svec is 
not generic but "intrinsic" / "builtin", I think they are used earlier in 
bootstrap?

Since they don't work with @which, an @whereis kinda macro would be nice to 
give a link to their source code in github, even if it's in C or whatever. 
IMHO we should really differentiate all this "anonymous" (that's what 
typeof tell you) functions and document them.

Couldn't we just wrap them in Julia functions and treat them as the rest?

julia> svec(args...) = Core.svec(args...)
svec (generic function with 1 method)

julia> svec(1)
svec(1)


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

2016-01-04 Thread Ismael VC
Just my thoughts:

   - You can’t have Set{R, S} only Set{T}, Set{DataType}([R, S]) for
   example.
   - The moment you want to dispatch on those subtypes you would need to do
   something like Union{Ts...}, where Ts is an array or set of such
   subtypes.
   - Union{R, S} == Union{S, R} is true.
   - Base.length(u::Union) = length(u.types) for cardinality.

It’s an interesting thought experiment! :D
​

Ismael Venegas Castelló

*Data Analyst*

Cel. 044 55 6434 0229

ivene...@richit.com.mx

Cerro San Francisco 357, C.P. 04200

Campestre Churubusco, Coyoacán

Ciudad de México




  

Tel. 6718 1818
richit.com.mx

2016-01-04 21:04 GMT-06:00 Ray Toal :

> All good, but I just can't see it. If I have:
>
> julia> abstract T
> julia> type S <: T; end
> julia> type R <: T; end
>
> and I ask "What are the subtypes of T?" I would expect to get back either
>
> [S,R]
>
> or
>
> [R,S]
>
> or even
>
> Set{R,S}
>
> because each of those things have cardinality 2. Because there are 2
> subsets of T. If instead I were to get back the value
>
> Union{R,S}
>
> then that would be answering the question "What are the subtypes of T?"
> with the answer "This SINGLE type whose values are all the same as the
> original type." That I **can't** understand (and would be surprised if Jeff
> would), but if everyone else thinks it makes sense, no worries! We can
> disagree. Our expectations might differ on this.
>
> I thought it was a fun thought experiment to begin with
>
> Thanks for the discussion.
>
> On Monday, January 4, 2016 at 5:48:53 PM UTC-8, Ismael Venegas Castelló
> wrote:
>>
>> After watching the video: *Jeff Bezanzon: Julia - The base language,
>> future directions and speculations
>>  *as Scott mentions,
>> returning a Union type indeed starts to make sense to me.
>>
>>
>> El sábado, 2 de enero de 2016, 13:09:43 (UTC-6), Scott Jones escribió:
>>>
>>> Going by Jeff's JuliaCon 2015 talk, and the code in
>>> examples/JuliaTypes.jl, I think returning the subtypes as a set of types
>>> (which is the same as a union of types) makes perfect sense.
>>> I'm hoping that this change does make it into 0.5, I think it does clean
>>> up a lot of bad corner cases in the current type system (which Jeff also
>>> mentioned in his talk)
>>>
>>> On Tuesday, December 29, 2015 at 5:45:51 PM UTC-5, Ray Toal wrote:

 But maybe I'm not understanding this correctly? Was it suggested that a
 type union be the result of the subtypes method? I don't think that makes
 sense The subtypes of a type is a set of types, not a type (even if
 that type were the union of all the subtypes). It strikes me as a little
 odd, but I may have misheard, or there might me an interpretation of it
 that I haven't thought about.

 On Tuesday, December 29, 2015 at 7:02:41 AM UTC-8, Scott Jones wrote:
>
> Yes! 😄 I was hoping that Jeff had implemented something super fast
> for type unions.




Re: [julia-users] How do you override the new() function?

2016-01-04 Thread Isaiah Norton
I think some more context would still be helpful here and in the other
question [1]. There, you said that you wanted to set a value in a database
whenever a constructor is called. Is the goal to write something like an
ORM layer?

Coupling database interaction so tightly with object semantics is probably
not workable in Julia (for starters, it is not possible to override field
access or assignment).

An alternate approach is to build synchronization on top of types, either
by explicit serialization/deserialization, or with metaprogramming to
automatically generate hooks (as in e.g. Reactive.jl [2]).

[1] https://groups.google.com/d/msg/julia-users/V-Lp6Ah7Zpk/ICDg1D5oCQAJ
[2] http://julialang.org/Reactive.jl/

On Mon, Jan 4, 2016 at 3:49 PM, Julia Tylors  wrote:

> Topic says it all.
> Thanks
>


Re: [julia-users] Immutable types and arrays

2016-01-04 Thread Isaiah Norton
>
> Are only transitively immutable types stored inline?


Yes. You can check `isbits(T)`, which in this case returns false because
`B.pointerfree == false`.


> Is this documented
> anywhere?


Unfortunately, the only hint at the moment appears to be
http://docs.julialang.org/en/release-0.4/devdocs/reflection/?highlight=isbits

and probably a number of mailing list questions.

The statement there remains true: if you are worried about C-compatible
layout, check whether the type is `isbits`.

On Mon, Jan 4, 2016 at 7:15 PM, Jamie Brandon 
wrote:

> This surprised me:
>
> immutable A
>   a::UInt32
>   b::UInt32
>   c::UInt64
>   d::UInt64
> end
>
> sizeof(A[A(0,0,0,0), A(0,0,0,0)]) # 48
>
> immutable B
>   a::UInt32
>   b::UInt32
>   c::Vector{UInt64}
>   d::Vector{UInt64}
> end
>
> sizeof(B[B(0,0,[],[]), B(0,0,[],[])]) # 16
>
> I expected the latter to also have size 48 ie 2xInt32, 2xPointer. Are
> only transitively immutable types stored inline? Is this documented
> anywhere?
>


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

2016-01-04 Thread Ray Toal
All good, but I just can't see it. If I have:

julia> abstract T
julia> type S <: T; end
julia> type R <: T; end

and I ask "What are the subtypes of T?" I would expect to get back either

[S,R]

or

[R,S]

or even

Set{R,S}

because each of those things have cardinality 2. Because there are 2 
subsets of T. If instead I were to get back the value

Union{R,S}

then that would be answering the question "What are the subtypes of T?" 
with the answer "This SINGLE type whose values are all the same as the 
original type." That I **can't** understand (and would be surprised if Jeff 
would), but if everyone else thinks it makes sense, no worries! We can 
disagree. Our expectations might differ on this.

I thought it was a fun thought experiment to begin with

Thanks for the discussion.

On Monday, January 4, 2016 at 5:48:53 PM UTC-8, Ismael Venegas Castelló 
wrote:
>
> After watching the video: *Jeff Bezanzon: Julia - The base language, 
> future directions and speculations 
>  *as Scott mentions, 
> returning a Union type indeed starts to make sense to me.
>
>
> El sábado, 2 de enero de 2016, 13:09:43 (UTC-6), Scott Jones escribió:
>>
>> Going by Jeff's JuliaCon 2015 talk, and the code in 
>> examples/JuliaTypes.jl, I think returning the subtypes as a set of types 
>> (which is the same as a union of types) makes perfect sense.
>> I'm hoping that this change does make it into 0.5, I think it does clean 
>> up a lot of bad corner cases in the current type system (which Jeff also 
>> mentioned in his talk)
>>
>> On Tuesday, December 29, 2015 at 5:45:51 PM UTC-5, Ray Toal wrote:
>>>
>>> But maybe I'm not understanding this correctly? Was it suggested that a 
>>> type union be the result of the subtypes method? I don't think that makes 
>>> sense The subtypes of a type is a set of types, not a type (even if 
>>> that type were the union of all the subtypes). It strikes me as a little 
>>> odd, but I may have misheard, or there might me an interpretation of it 
>>> that I haven't thought about.
>>>
>>> On Tuesday, December 29, 2015 at 7:02:41 AM UTC-8, Scott Jones wrote:

 Yes! 😄 I was hoping that Jeff had implemented something super fast for 
 type unions.
>>>
>>>

Re: [julia-users] Re: ANN: Kip.jl an alternative module system

2016-01-04 Thread Jake Rosoman
Hey Tim and Tom did the docs I added help you understand how to use Kip. If 
not take another look because I've added some example projects which 
demonstrates aspects of it.

On Monday, December 21, 2015 at 12:24:51 AM UTC+13, Tim Holy wrote:
>
> After reading your README example, I'm still left wondering how one works 
> with 
> Kip, or how it fixes the problems you're describing. To me it's not at all 
> obvious how your example "illustrates" the statements you make in the 
> prose. 
> You might consider explaining the meaning of the various arguments to 
> @require, what an "index" file is and what its format should be, and 
> exactly 
> what the call to the emit function is supposed to demonstrate. 
>
> Best, 
> --Tim 
>
> On Saturday, December 19, 2015 11:26:53 PM Jake Rosoman wrote: 
> > I forgot to actually link to the project <
> https://github.com/jkroso/Kip.jl> 
> > 
> > On Sunday, December 20, 2015 at 8:25:04 PM UTC+13, Jake Rosoman wrote: 
> > > Julia's module system is the one part of it I feel confident enough to 
> say 
> > > is bad. It can't handle several versions of the same package. Is hard 
> (or 
> > > impossible?) to depend on packages that aren't in the registry and 
> hard to 
> > > add (controversial) things to the registry. I also find it ugly and 
> hard 
> > > to 
> > > use but now I'm getting into opinions so I'll stop. 
> > > 
> > > Kip solves all these problems and works fine alongside Julia's current 
> > > module system so you can try it out now. I hope that eventually we can 
> > > replace Julia's module system if people generally agree that it's 
> worth 
> > > doing. I've created a poll to measure the communities opinion 
> > >  and you can change your vote at any time so 
> feel 
> > > free to say no now but follow the discussion. 
>
>

[julia-users] Defining and using Python classes with PyCall

2016-01-04 Thread Alex Dowling
Hello Everyone,

I'd like to use two classes written in Python in Julia. More specifically, 
I'd like to get the follow code example in Python (taken verbatim from here 
)
 
running with PyCall, PyPlot and Julia.

import matplotlib.pyplot as pltimport matplotlib.text as mpl_text
class AnyObject(object):
def __init__(self, text, color):
self.my_text = text
self.my_color = color
class AnyObjectHandler(object):
def legend_artist(self, legend, orig_handle, fontsize, handlebox):
print orig_handle
x0, y0 = handlebox.xdescent, handlebox.ydescent
width, height = handlebox.width, handlebox.height
patch = mpl_text.Text(x=0, y=0, text=orig_handle.my_text, 
color=orig_handle.my_color, verticalalignment=u'baseline', 
horizontalalignment=u'left', 
multialignment=None, 
fontproperties=None, rotation=45, 
linespacing=None, 
rotation_mode=None)
handlebox.add_artist(patch)
return patch

obj_0 = AnyObject("A", "purple")
obj_1 = AnyObject("B", "green")

plt.legend([obj_0, obj_1], ['Model Name A', 'Model Name B'],
   handler_map={obj_0:AnyObjectHandler(), obj_1:AnyObjectHandler()})

plt.show()


I've been using Julia for about 1/2 a year, and its been over 1/2 a decade 
since I used Python seriously. I've looked at the PyCall documentation 
, but I'm still rather confused.

Thanks,
Alex


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

2016-01-04 Thread Ismael Venegas Castelló
After watching the video: *Jeff Bezanzon: Julia - The base language, future 
directions and speculations  *as 
Scott mentions, returning a Union type indeed starts to make sense to me.


El sábado, 2 de enero de 2016, 13:09:43 (UTC-6), Scott Jones escribió:
>
> Going by Jeff's JuliaCon 2015 talk, and the code in 
> examples/JuliaTypes.jl, I think returning the subtypes as a set of types 
> (which is the same as a union of types) makes perfect sense.
> I'm hoping that this change does make it into 0.5, I think it does clean 
> up a lot of bad corner cases in the current type system (which Jeff also 
> mentioned in his talk)
>
> On Tuesday, December 29, 2015 at 5:45:51 PM UTC-5, Ray Toal wrote:
>>
>> But maybe I'm not understanding this correctly? Was it suggested that a 
>> type union be the result of the subtypes method? I don't think that makes 
>> sense The subtypes of a type is a set of types, not a type (even if 
>> that type were the union of all the subtypes). It strikes me as a little 
>> odd, but I may have misheard, or there might me an interpretation of it 
>> that I haven't thought about.
>>
>> On Tuesday, December 29, 2015 at 7:02:41 AM UTC-8, Scott Jones wrote:
>>>
>>> Yes! 😄 I was hoping that Jeff had implemented something super fast for 
>>> type unions.
>>
>>

[julia-users] Recurrence Quantification Analysis

2016-01-04 Thread Helios De Rosario
Hi all. Is anybody working on Recurrence Quantification Analysis (RQA) with 
Julia?

There are libraries for RQA in other languages like Matlab, Python or R 
(http://www.recurrence-plot.tk/), but I have not seen any Julia resources 
by Googling, or discussions about it in this group. The closest work I have 
found is about Convergence Cross Mappings here: 
https://peerj.com/preprints/583v2/

I think that Julia's performance is ideal for this kind of high-dimensional 
problem. In fact I have already being using it with custom functions 
(bundled in a package stub, 
https://github.com/heliosdrm/RecurrenceAnalysis.jl). I would gladly 
contribute a full package, it it may be useful for others.

Best regards
Helios De Rosario


[julia-users] Immutable types and arrays

2016-01-04 Thread Jamie Brandon
This surprised me:

immutable A
  a::UInt32
  b::UInt32
  c::UInt64
  d::UInt64
end

sizeof(A[A(0,0,0,0), A(0,0,0,0)]) # 48

immutable B
  a::UInt32
  b::UInt32
  c::Vector{UInt64}
  d::Vector{UInt64}
end

sizeof(B[B(0,0,[],[]), B(0,0,[],[])]) # 16

I expected the latter to also have size 48 ie 2xInt32, 2xPointer. Are
only transitively immutable types stored inline? Is this documented
anywhere?


Re: [julia-users] How do you override the new() function?

2016-01-04 Thread hustf
That's right. You would need to delete the current context. Sometimes 
workspace() can help you out. For a better approach, read this:

http://discuss.junolab.org/t/announcing-julia-ide-work-in-atom/297


Re: [julia-users] How do you override the new() function?

2016-01-04 Thread Stefan Karpinski
I'm pretty sure that's an unrelated question.

On Mon, Jan 4, 2016 at 5:12 PM, digxx  wrote:

> Hey sorry I was thinking about maybe the same though dont quite get what
> you mean.
> If I have a function
> f(x)=x
> and later want to overwrite f(x) with a variable I cant do that since its
> a function?
> Cant I delete the function other than closing Julia?
>
> Am Montag, 4. Januar 2016 22:18:42 UTC+1 schrieb Stefan Karpinski:
>
>> You can't – new isn't a real function, it is syntax within a type block
>> for making an instance.
>>
>> On Mon, Jan 4, 2016 at 3:49 PM, Julia Tylors  wrote:
>>
>>> Topic says it all.
>>> Thanks
>>>
>>
>>


Re: [julia-users] How do you override the new() function?

2016-01-04 Thread digxx
Hey sorry I was thinking about maybe the same though dont quite get what 
you mean.
If I have a function
f(x)=x
and later want to overwrite f(x) with a variable I cant do that since its a 
function?
Cant I delete the function other than closing Julia?

Am Montag, 4. Januar 2016 22:18:42 UTC+1 schrieb Stefan Karpinski:

> You can't – new isn't a real function, it is syntax within a type block 
> for making an instance.
>
> On Mon, Jan 4, 2016 at 3:49 PM, Julia Tylors  > wrote:
>
>> Topic says it all.
>> Thanks
>>
>
>

[julia-users] Strange behaviour on type dependency of function

2016-01-04 Thread Lutfullah Tomak
You pass correct args to MarginsRnd. However, AFAICT, in that function you pass 
5th argument to __MarginsRnd#2__ as Array{Float64,2} instead of Array{Int64,2}.

Re: [julia-users] How do you override the new() function?

2016-01-04 Thread Stefan Karpinski
You can't – new isn't a real function, it is syntax within a type block for
making an instance.

On Mon, Jan 4, 2016 at 3:49 PM, Julia Tylors  wrote:

> Topic says it all.
> Thanks
>


Re: [julia-users] Re: Only two days left: TRIPLE your support for your favorite open source projects!

2016-01-04 Thread Stefan Karpinski
Actually, so far this is the one that I find most compelling. Just letting
messages disappear into the ether for days at a time is really not
acceptable service.

On Mon, Jan 4, 2016 at 3:38 PM, cdm  wrote:

>
> perhaps, another reason to move ... ?
>
>
> https://groups.google.com/forum/#!searchin/julia-users/mailing$20list/julia-users/xmk3BBvvfKM/F-sia09vAgAJ
>
>
>
>
> On Monday, January 4, 2016 at 9:00:07 AM UTC-8, Stefan Karpinski wrote:
>>
>> Thanks for the offer. We've already got a number of moderators in a
>> variety of time zones. The real problem is that google groups sometimes
>> inexplicably doesn't send notifications for moderation for days – and it
>> isn't possible to moderate posts until the notification shows up. I have no
>> idea how the groups team at google can possibly justify that kind of delay
>> – it seems like a fairly massive bug to me and has been like this forever.
>>
>


[julia-users] Strange behaviour on type dependency of function

2016-01-04 Thread Michael Borregaard
Hi, I have a function MarginsRnd. When I try to use the function, it 
complains that the types are not correct - but I do not see why. Restarting 
Julia and reloading the function does not work. The problem seems to be in 
a strangely defined method. When I run whos() I get:
whos()
  Base  23988 KB Module : Base
   MarginsRnd   3405 bytes  Function : MarginsRnd
  Core   2832 KB Module : Core
  Main  26642 KB Module : Main
Switch 13 KB Module : Switch
 __MarginsRnd#2__ 21 KB Function : __MarginsRnd#2__
   __canonical#0__   1073 bytes  Function : __canonical#0__
   __canonical#1__ 11 KB Function : __canonical#1__
   ans 24 bytes  Tuple{DataType,DataType,
DataType} : (Int64,Array{Int64,1},Array{Int64,1})
 canonical   3383 bytes  Function : canonical
 p104 bytes  13-element Array{Int64,1} : [14
,13,14,10,12,2,10,1,10,11,6,2,17]
 q136 bytes  17-element Array{Int64,1} : [4,
4,11,10,10,8,9,10,8,9,3,10,4,7,9,3,3]

So the function seems to have a #2 method, but not a #0 method for some 
reason. When I run the codes I get error message:

julia> MarginsRnd(2,p,q)
ERROR: MethodError: `__MarginsRnd#2__` has no method matching 
__MarginsRnd#2__(::Array{Float64,2}, 
::ASCIIString, ::ASCIIString, ::ASCIIString, ::Array{Float64,2}, ::Bool, 
::Int64, ::Array{Int64,1}, ::Array{Int64,1})
Closest candidates are:
  __MarginsRnd#2__(::Array{AbstractFloat,2}, ::ASCIIString, ::ASCIIString, 
::AbstractString, ::Array{Int64,2}, ::Any, ::Int64, ::Array{Int64,1}, 
::Array{Int64,1})

I have no idea how the types of the candidates have appeared.
Simple querying shows:

julia> methods(MarginsRnd)
# 1 method for generic function "MarginsRnd":
MarginsRnd(N::Int64, r::Array{Int64,1}, c::Array{Int64,1}) at none:69

julia> map(typeof, (2, p, q))
(Int64,Array{Int64,1},Array{Int64,1})

Anyone who can give me an idea what is wrong here?
Thanks a lot!




[julia-users] How do you override the new() function?

2016-01-04 Thread Julia Tylors
Topic says it all.
Thanks


Re: [julia-users] Re: Only two days left: TRIPLE your support for your favorite open source projects!

2016-01-04 Thread cdm

perhaps, another reason to move ... ?

https://groups.google.com/forum/#!searchin/julia-users/mailing$20list/julia-users/xmk3BBvvfKM/F-sia09vAgAJ




On Monday, January 4, 2016 at 9:00:07 AM UTC-8, Stefan Karpinski wrote:
>
> Thanks for the offer. We've already got a number of moderators in a 
> variety of time zones. The real problem is that google groups sometimes 
> inexplicably doesn't send notifications for moderation for days – and it 
> isn't possible to moderate posts until the notification shows up. I have no 
> idea how the groups team at google can possibly justify that kind of delay 
> – it seems like a fairly massive bug to me and has been like this forever.
>


Re: [julia-users] Density plot using colour scale

2016-01-04 Thread Tim Holy
Not exactly sure what you're asking, but Winston's imagesc and Gadfly's 
histogram2d or hexbin might do what you want.

http://dcjones.github.io/Gadfly.jl/geom_histogram2d.html

Best,
--Tim

On Monday, January 04, 2016 09:42:14 AM 'Antoine Messager' via julia-users 
wrote:
> Hi all,
> 
> I can not find any function that plots the density of a real 2 column
> vector. I have a vector [X,Y] and I would like to see what areas are the
> densest using a colour scale. Would you know if there is any package that
> could do that?
> 
> Thank you very much,
> Antoine



Re: [julia-users] ANN: Float128 and Float{256,512,1024} for common math

2016-01-04 Thread Jeffrey Sarnoff
Revised module links and type names:

this module allows any one or more of the four precisions to be selected:  
ArbFloats.jl 
these modules export each ArbFloatNN type separately: 

   ArbFloats30.jl    exports 
ArbFloat30  ( 30 digits)
   ArbFloats70.jl    exports 
ArbFloat70  ( 70 digits)
   ArbFloats140.jl   exports 
ArbFloat140 (140 digits)
   ArbFloats300.jl   exports 
ArbFloat300 (300 digits)

>
>

Re: [julia-users] Re: covnert method

2016-01-04 Thread Abel Siqueira
In `a = Foo(12)`, the type is defined implicitly as the type of 12, which
is Int64.
In convert(Foo{Int64}, 12), you're trying to convert a Int64 to a
Foo{Int64}, and there is no
intruction for how to do it. See

http://docs.julialang.org/en/release-0.4/manual/types/#parametric-composite-types


Abel Soares Siqueira

2016-01-04 17:01 GMT-02:00 Julia Tylors :

> But if I am to instantiate it normally a =Foo(12), it continues and
> completes without me defining a convert method. What is really happening
> here?
> Thanks
>
>
> On Monday, January 4, 2016 at 10:53:54 AM UTC-8, Julia Tylors wrote:
>>
>> I have a question about the convert method, Look at the example below, It
>> tells me to define convert method here.
>> Thanks
>>
>> julia> type Foo{T}
>>x::T
>>end
>>
>> julia> a = convert(Foo{Int64},12)
>> ERROR: MethodError: `convert` has no method matching
>> convert(::Type{Foo{Int64}}, ::Int64)
>> This may have arisen from a call to the constructor Foo{Int64}(...),
>> since type constructors fall back to convert methods.
>> Closest candidates are:
>>   Foo{T}(::Any)
>>   call{T}(::Type{T}, ::Any)
>>   convert{T}(::Type{T}, ::T)
>>
>>
>> But if I am to instantiate it normally a =Foo(12), it doesn't complete.
>> And it calls some convert method which does the conversion right? How is
>> this happening?
>>
>> Thanks
>>
>


[julia-users] Re: covnert method

2016-01-04 Thread Julia Tylors
But if I am to instantiate it normally a =Foo(12), it continues and 
completes without me defining a convert method. What is really happening 
here?
Thanks

On Monday, January 4, 2016 at 10:53:54 AM UTC-8, Julia Tylors wrote:
>
> I have a question about the convert method, Look at the example below, It 
> tells me to define convert method here. 
> Thanks
>
> julia> type Foo{T}
>x::T
>end
>
> julia> a = convert(Foo{Int64},12)
> ERROR: MethodError: `convert` has no method matching 
> convert(::Type{Foo{Int64}}, ::Int64)
> This may have arisen from a call to the constructor Foo{Int64}(...),
> since type constructors fall back to convert methods.
> Closest candidates are:
>   Foo{T}(::Any)
>   call{T}(::Type{T}, ::Any)
>   convert{T}(::Type{T}, ::T)
>
>
> But if I am to instantiate it normally a =Foo(12), it doesn't complete. 
> And it calls some convert method which does the conversion right? How is 
> this happening?
>
> Thanks
>


[julia-users] covnert method

2016-01-04 Thread Julia Tylors
I have a question about the convert method, Look at the example below, It 
tells me to define convert method here. 
Thanks

julia> type Foo{T}
   x::T
   end

julia> a = convert(Foo{Int64},12)
ERROR: MethodError: `convert` has no method matching 
convert(::Type{Foo{Int64}}, ::Int64)
This may have arisen from a call to the constructor Foo{Int64}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  Foo{T}(::Any)
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)


But if I am to instantiate it normally a =Foo(12), it doesn't complete. And 
it calls some convert method which does the conversion right? How is this 
happening?

Thanks


Re: [julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Stefan Karpinski
You can also just use the `in` infix operator.

On Mon, Jan 4, 2016 at 1:04 PM, Cameron McBride 
wrote:

> Also, in the REPL you can use the help files. For example, try typing "?∈"
> (which shows this is basically the in() function, hence the \inTAB
> suggestion by Kristoffer).
>
> Cameron
>
> On Mon, Jan 4, 2016 at 12:59 PM, Kristoffer Carlsson <
> kcarlsso...@gmail.com> wrote:
>
>> You can enter \in and then press TAB in the REPL.
>>
>> Here is a list:
>> http://docs.julialang.org/en/release-0.4/manual/unicode-input/
>>
>> Many editors have packages that support entering these type of unicode
>> characters.
>>
>
>


Re: [julia-users] Unions and TypeVar lower bounds

2016-01-04 Thread Fábio Cardeal
Thanks Tim, that seems to be it. I insisted on putting "lower bound" on my
searches, so I didn't find that PR or the related issue. Thanks for working
on this problem, best of luck!

2016-01-04 10:46 GMT-03:00 Tim Holy :

> Hi Fábio,
>
> Probably relevant:
> https://github.com/JuliaLang/julia/pull/11805
>
> --Tim
>
> On Wednesday, December 30, 2015 09:50:27 AM Fábio Cardeal wrote:
> > Given this:
> >
> >   T = TypeVar(:T, Int, Any)
> >
> >
> > I was wondering why while this happens:
> >
> >   julia> Int <: Integer
> >   true
> >
> >   julia> Integer <: T
> >   true
> >
> >
> > This also happens:
> >
> >   julia> Int <: Union{Int,Char}
> >   true
> >
> >   julia> Union{Int,Char} <: T
> >   false
> >
> >
> > Is this intended behaviour and I am just not understanding type variable
> > lower bounds, or a missed corner case?
>


Re: [julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Cameron McBride
Also, in the REPL you can use the help files. For example, try typing "?∈"
(which shows this is basically the in() function, hence the \inTAB
suggestion by Kristoffer).

Cameron

On Mon, Jan 4, 2016 at 12:59 PM, Kristoffer Carlsson 
wrote:

> You can enter \in and then press TAB in the REPL.
>
> Here is a list:
> http://docs.julialang.org/en/release-0.4/manual/unicode-input/
>
> Many editors have packages that support entering these type of unicode
> characters.
>


Re: [julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Kristoffer Carlsson
You can enter \in and then press TAB in the REPL.

Here is a list: http://docs.julialang.org/en/release-0.4/manual/unicode-input/

Many editors have packages that support entering these type of unicode 
characters.


[julia-users] Density plot using colour scale

2016-01-04 Thread 'Antoine Messager' via julia-users
Hi all,

I have a 2D vector [x,y] and I would like to plot the density on a 2D map 
using a colour scale. Would you know if there is anything else already 
implemented than Unicode 
? 

Thank you very much,

Antoine 


[julia-users] Density plot using colour scale

2016-01-04 Thread 'Antoine Messager' via julia-users
Hi all,

I can not find any function that plots the density of a real 2 column 
vector. I have a vector [X,Y] and I would like to see what areas are the 
densest using a colour scale. Would you know if there is any package that 
could do that?

Thank you very much,
Antoine


Re: [julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Forrest Curo
Yes! Thanks!

Unsure how to generate a '∈', however. Copied yours; and I guess there's no
problem once I've pasted it into a .jl file as needed... but where's a
handy reference to such symbols, while I'm at it?

On Mon, Jan 4, 2016 at 9:17 AM, Steven G. Johnson 
wrote:

>
>
> On Monday, January 4, 2016 at 9:57:35 AM UTC-7, Forrest Curo wrote:
>>
>> I can do something like the following with no complaint:
>> julia> ns = Dict{Int8,Set{Int8}}
>>
>
> What you've created is the type, but what you want is an instance of the
> type.  Do
>
>   ns = Dict{Int8,Set{Int8}}()
>
> and then it should work as expected.  e.g.
>
> ns[1] = Set{Int8}([3,7])
>
> push!(ns[1], 17)
>
> isempty(ns[1])
>
> 3 ∈ ns[1]
>
>
> work.
>


Re: [julia-users] ANN: Float128 and Float{256,512,1024} for common math

2016-01-04 Thread Jeffrey Sarnoff
Ok, ArbFloatNN it will be.

On Mon, Jan 4, 2016 at 12:12 PM, Stefan Karpinski 
wrote:

> I think the ArbFloatNN names seem clearest. Calling these DigitsNN does
> seem misleading since digits are technically only decimal.
>
> On Sun, Jan 3, 2016 at 11:05 PM, Jeffrey Sarnoff <
> jeffrey.sarn...@gmail.com> wrote:
>
>> I thought DecimalNN would be decimal format.  I chose Digits30 because it
>> is geared to display 30 digits (base 10) accurately.
>> To call these BallNN or ArbNN would be doing a disservice to the Arb
>> software .. I am using Arb, but only partially and not as an
>> interval-valued entity.
>> For that reason, I do not want to use BallNN or ArbNN for this.  Thoughts?
>>
>>
>> On Sunday, January 3, 2016 at 11:01:31 PM UTC-5, Scott Jones wrote:
>>>
>>> I think the DIGITSxxx names makes it sound like this might be a decimal
>>> format, which seems a bit of a concern.
>>> What about Ball128, Ball256, etc. or Arb*, or ArbFloat*?
>>> Distinguishing Arb floating types from plain old IEEE floats is good,
>>> IMO, since these seem a lot more interesting! ;-)
>>>
>>> On Sunday, January 3, 2016 at 4:53:31 PM UTC-5, Jeffrey Sarnoff wrote:

 FloatHigher.jl  has been
 revised.  It now exports Digits30, Digits70, Digits140, Digits300 instead
 of FloatNN type names.  Additionally, showball(x) is available (see README
 for examples).
 The individual files will follow, renamed DIGITS30.jl
 , DIGITS70.jl
 , DIGITS140.jl
 , DIGITS300.jl
 .

 The choice of digit lengths is a balance of utility and internal
 efficiency.

>>>
>


[julia-users] Re: dictionaries of sets -- or arrays of sets

2016-01-04 Thread Steven G. Johnson


On Monday, January 4, 2016 at 9:57:35 AM UTC-7, Forrest Curo wrote:
>
> I can do something like the following with no complaint:
> julia> ns = Dict{Int8,Set{Int8}}
>

What you've created is the type, but what you want is an instance of the 
type.  Do

  ns = Dict{Int8,Set{Int8}}()

and then it should work as expected.  e.g.

ns[1] = Set{Int8}([3,7])

push!(ns[1], 17)

isempty(ns[1])

3 ∈ ns[1]


work.


Re: [julia-users] ANN: Float128 and Float{256,512,1024} for common math

2016-01-04 Thread Stefan Karpinski
Fredrik: thanks for joining the discussion here, for the corrections, and
for all the other useful info.

On Sun, Jan 3, 2016 at 12:31 PM, Fredrik Johansson <
fredrik.johans...@gmail.com> wrote:

>
> On Saturday, January 2, 2016 at 5:50:58 PM UTC+1, Scott Jones wrote:
>>
>> This is very interesting!  I'm curious as to how it will compare to
>> Unums, as it seems both Fredrik Johannson's Arb and Unums are trying to fix
>> a lot of the same problems with current floating point.
>>
>
> Arb is a library for arbitrary-precision interval arithmetic, the most
> significant difference compared to e.g. MPFI being that it uses a mid-rad
> representation instead of an inf-sup representation.
>
> The mid-rad representation is worse for representing "wide" intervals, but
> superior for "narrow" intervals. It goes very well together with
> high-precision arithmetic. If you're doing floating-point arithmetic with
> 128+ bits of precision, you may as well carry along a low-precision error
> bound, because updating the error bound costs much less than the
> high-precision midpoint arithmetic.
>
> Mid-rad arithmetic an old idea (there are earlier implementations in
> Mathemagix, iRRAM, and probably others). There is a nice paper by Joris van
> der Hoeven on "ball arithmetic" [1]. It should be noted that Arb does "ball
> arithmetic" for real numbers, and builds everything else out of those real
> numbers, rather than using higher-level "balls"; you get rectangular
> enclosures (and not mid-rad disks) for complex numbers, entrywise error
> bounds (and not matrix-norm "matricial balls") for matrices, and so on.
> This has pros and cons.
>
> A few the technical details in the blog post that Stefan Karpinski linked
> to are outdated now; I've rewritten the underlying floating-point
> arithmetic in Arb to improve efficiency. It now uses a custom
> arbitrary-precision floating-point type (arf_t) for midpoints and a
> fixed-precision unsigned floating-point type (mag_t) for error bounds. The
> reason why Arb uses custom floating-point types instead of MPFR has a
> little to do with efficiency, and a little to do with aesthetics.
>
> Concerning efficiency, the arf_t mantissa is allocated dynamically to the
> number of used bits rather than to the full working precision (MPFR always
> zero-pads to full precision); this helps when working with integer-valued
> coefficients and mixed-precision floating-point values. The arf_t type also
> avoids separate memory allocations completely up to 128 bits of precision;
> the 256-bit arf_t struct then stores the whole value directly without a
> separate heap allocation for the mantissa. The mag_t type, of course, is a
> lot faster than an arbitrary-precision type.
>
> As a result, Arb sometimes uses less memory than MPFR, and less than half
> as much memory as MPFI, and has less overhead for temporary allocations and
> deallocations. However, arithmetic operations are not currently as well
> optimized as MPFR in all cases; additions are a bit slower, for example. I
> hope to work more on this in the future (for example, by always throwing
> away bits that are insignificant compared to the error bound).
>
> Concerning aesthetics, I wanted bignum exponents and I wanted to avoid
> having any kind of global (or thread-local) state for default precision,
> exponent ranges, and exception flags.
>
> Anyway, the number representation makes some overall difference in
> efficiency, but the biggest difference comes from algorithms. The selling
> point of Arb is that I've spent a lot of time optimizing high-precision
> computation of transcendental functions (this was the subject of my PhD
> thesis). You can find more details in the docs, in my papers, and on my
> blog. The implementation of elementary functions in Arb for precisions up
> to a few thousands of bits is described in [2].
>
> Obviously, Arb is not meant to be competitive with double precision
> software. It seems to be competitive with some of the existing software for
> quad precision (~100 bits) arithmetic. At even higher precision, it should
> do well overall, if you know its limitations.
>
> Fundamentally, interval arithmetic suffers from the dependency problem. It
> works perfectly in some instances, not at all in others. I wrote Arb mainly
> for doing computational number theory, where it typically happens to work
> very well.
>
> It turns out to work quite nicely as a black box for isolated parts of
> floating-point computations, too -- you need to evaluate, say, some complex
> Bessel functions; you feed it a floating-point number, you get an interval
> back and convert it to a floating-point approximation that is guaranteed to
> be accurate, and you go on doing floating-point arithmetic, being confident
> that at least the part with the Bessel function isn't going to cause
> trouble. I recently wrote a simple Arb wrapper implementing transcendental
> functions for C99 complex doubles this way [3].
>
> I'm not an expert on unums, thoug

Re: [julia-users] ANN: Float128 and Float{256,512,1024} for common math

2016-01-04 Thread Stefan Karpinski
I think the ArbFloatNN names seem clearest. Calling these DigitsNN does
seem misleading since digits are technically only decimal.

On Sun, Jan 3, 2016 at 11:05 PM, Jeffrey Sarnoff 
wrote:

> I thought DecimalNN would be decimal format.  I chose Digits30 because it
> is geared to display 30 digits (base 10) accurately.
> To call these BallNN or ArbNN would be doing a disservice to the Arb
> software .. I am using Arb, but only partially and not as an
> interval-valued entity.
> For that reason, I do not want to use BallNN or ArbNN for this.  Thoughts?
>
>
> On Sunday, January 3, 2016 at 11:01:31 PM UTC-5, Scott Jones wrote:
>>
>> I think the DIGITSxxx names makes it sound like this might be a decimal
>> format, which seems a bit of a concern.
>> What about Ball128, Ball256, etc. or Arb*, or ArbFloat*?
>> Distinguishing Arb floating types from plain old IEEE floats is good,
>> IMO, since these seem a lot more interesting! ;-)
>>
>> On Sunday, January 3, 2016 at 4:53:31 PM UTC-5, Jeffrey Sarnoff wrote:
>>>
>>> FloatHigher.jl  has been
>>> revised.  It now exports Digits30, Digits70, Digits140, Digits300 instead
>>> of FloatNN type names.  Additionally, showball(x) is available (see README
>>> for examples).
>>> The individual files will follow, renamed DIGITS30.jl
>>> , DIGITS70.jl
>>> , DIGITS140.jl
>>> , DIGITS300.jl
>>> .
>>>
>>> The choice of digit lengths is a balance of utility and internal
>>> efficiency.
>>>
>>


Re: [julia-users] Re: Why does this code never return?

2016-01-04 Thread Stefan Karpinski
What would it mean to reload a module rather than a file?

On Sun, Jan 3, 2016 at 4:19 AM,  wrote:

> Reload reloads the *package* not the module, see
> http://docs.julialang.org/en/release-0.4/stdlib/base/#Base.reload.
>
>
> On Sunday, January 3, 2016 at 5:16:07 PM UTC+10, Greg Plowman wrote:
>>
>> This seemed a little non-obvious to me as well.
>>
>> I guess the take-away is that "loading" a module (via any means, not just
>> reload??) loads the entire *file* containing the module, not just the
>> stuff between module Foo end.
>> Only the stuff between module Foo end is scoped to the module, but the
>> entire file is loaded.
>>
>> Is this correct?
>>
>>
>> On Sunday, January 3, 2016 at 3:50:58 AM UTC+11, Alexander Ranaldi wrote:
>>
>>> Hello,
>>>
>>> Consider the following code which is in the file Foo.jl
>>>
>>> module Foo
>>>
>>>
>>> function bar(x, y)
>>> x + y
>>> end
>>>
>>>
>>> end
>>>
>>> reload("Foo")
>>>
>>>
>>> Then, at the REPL:
>>>
>>> julia> include("Foo.jl")
>>>
>>> Julia does not return. Can someone help me understand what is happening
>>> here? Is the module being infinitely reloaded?
>>>
>>> Thank you
>>>
>>


Re: [julia-users] Re: Only two days left: TRIPLE your support for your favorite open source projects!

2016-01-04 Thread Stefan Karpinski
Thanks for the offer. We've already got a number of moderators in a variety
of time zones. The real problem is that google groups sometimes
inexplicably doesn't send notifications for moderation for days – and it
isn't possible to moderate posts until the notification shows up. I have no
idea how the groups team at google can possibly justify that kind of delay
– it seems like a fairly massive bug to me and has been like this forever.

On Sun, Jan 3, 2016 at 5:06 AM, SundaraRaman R 
wrote:

> On Sunday, January 3, 2016 at 12:40:53 AM UTC+5:30, Stefan Karpinski wrote:
>>
>> Google groups decided that this was spam, so it's too late for this.
>> Thanks, Google.
>>
>
>  Hey, if having one more moderator would help push such non-spam messages
> off the queue quicker, I'm willing to take up the work. I'll be able to
> give it multiple five-minute blocks of time (to a total of 15-30 minutes)
> through the day, and I'm on Indian Standard Time (+5:30hrs), so may be able
> to complement mod work done from other timezones.
>
>
>


[julia-users] dictionaries of sets -- or arrays of sets

2016-01-04 Thread Forrest Curo
I can do something like the following with no complaint:
julia> ns = Dict{Int8,Set{Int8}}
Dict{Int8,Set{Int8}}

but I get method errors any time I try to push! something into ns[1] or 
test isempty(ns[1])

Similarly if I try to make ns an array of sets.

How to get an addressable collection of small sets keyed to some integer 
index, and easily refer to it? 

Would I do better using an array of python dictionaries pointing to python 
lists through PyCall? Or is there a simple way to do this within standard 
julia?


[julia-users] Re: Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Kristoffer Carlsson
FYI Array{AbstractFloat}[] will be slow to work with because the you are 
saying that in each Array the elements can be of any floating type. That 
means that it would be valid to have an array with a Float32 followed by a 
Float64 and then some other user defined type that happens to be a subtype 
of AbstractFloat etc. By doing so it is impossible for the compiler to know 
the memory structure of the array and what method to dispatch to on each 
element. For performance you want to use concrete types, like for example 
Array{Float64, 1}.

On Monday, January 4, 2016 at 1:48:07 PM UTC+1, Charles Santana wrote:
>
> Hi people, 
>
> I would like to work with matrices represented as Arrays of Arrays of 
> AbstractFloats. Something like this:
>
> F=Array{AbstractFloat}[];#initialize the matrix F as an Array of 
> Arrays of Float
> for (i in 1:10)
> Fi = Array(AbstractFloat,0);#initialize the vector Fi as an 
> Array of Float
> for (k in 1:5)
> push!(Fi,k^2+i^2)
> end#end-fork
> push!(F,Fi);
> end#end-fori
>
> typeof(F)
> Array{Array{AbstractFloat,N},1}
>
> But I am experiencing problems to work with rows/columns of such Arrays. I 
> would like to calculate the logarithm of the square of elements of those 
> rows/columns like this:
>
> f = F[1];#a vector of AbstractFloat
>
> typeof(f)
> Array{AbstractFloat,1}
> 
> typeof(f.^2)
> Array{Any,1}
>
> log(f.^2)
> ERROR: MethodError: `log` has no method matching 
> log(::Array{Any,1})
>
>
> I understand this error only happens because I am working with Arrays of 
> Arrays of AbstractFloats. If I run a similar code using a Matrix instead of 
> Array I don't have such problems:
>
>A = rand(10,5);#a matrix of floats (similar to an array of arrays)
>
> typeof(A)
> Array{Float64,2}
> 
> a = A[1,:];#a vector of Float
> 
> typeof(a)
> Array{Float64,2}
> 
> typeof(a.^2)
> Array{Float64,2}
> 
> log(a.^2)
>
>
> everything runs smoothly. 
>
> My question: Am I doing something wrong in the way I am dealing with the 
> Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or 
> should I convert its elements to Array of Float instead of Array of Any? 
> Any other suggestion?
>
> Thanks for your attention and for any advice!
>
> Charles
>
> -- 
> Um axé! :)
>
> --
> Charles Novaes de Santana, PhD
> http://www.imedea.uib-csic.es/~charles
>


Re: [julia-users] Making ccall to c functions exported from executable

2016-01-04 Thread Isaiah Norton
>
> However it is not clear how this function is being looked up? How does
> ccall know where to look for this function?
>

This is apparently undocumented behavior: the single argument (symbol-only)
form of `ccall` looks in the symbol table for the process, so it should
find symbols in any library that has been `dlopen`ed (modulo dlopen binding
options).

If you are linking your executable against libjulia then I think this form
will "just work" as long as you export your symbols correctly.

On Wed, Dec 30, 2015 at 12:12 PM, Lance Larsen 
wrote:

> I would like to embed julia in an executable and use julia to call some
> routines exported from the executable. I noticed that the julia executable
> exports some functions, and I read that julia can read symbols from the
> executable. However, I have been unable to find a ccall example where a
> symbol is loaded directly from the executable. I do see some places where
> ccall is called without specifying a library file that the function is
> located in. For example in REPL.jl there is a call:
>
>   ccall(:jl_raise_debugger, Int, ())
>
> However it is not clear how this function is being looked up? How does
> ccall know where to look for this function?
>


Re: [julia-users] Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Tim Holy
Unlike Int, Float32/Float64 is not architecture-specific. Common misperception.

--Tim

On Monday, January 04, 2016 02:17:14 PM Charles Novaes de Santana wrote:
> Thanks a lot for your message, Tim.
> 
> I was wondering that it could be because of the AbstractFloat too. It makes
> sense.
> 
> I am using AbstractFloat because I want to make it clear that the matrix
> has Float elements, but I don't want to specify the architecture of the
> machine of the user, because I had problems with users using 32bits
> machines.
> 
> I will definitely read the link you sent me. And I will let you know what I
> decide to use in our code. Thanks for your suggestion too!!
> 
> Best,
> 
> Charles
> 
> On 4 January 2016 at 14:03, Tim Holy  wrote:
> > It has nothing to do with whether you're using a Matrix (which is just an
> > Array{T,2}) or general Arrays. The question is, do you have to use
> > AbstractFloat?
> > 
> > julia> a = Float64[1,2,3]
> > 
> > 3-element Array{Float64,1}:
> >  1.0
> >  2.0
> >  3.0
> > 
> > julia> b = AbstractFloat[1,2,3]
> > 
> > 3-element Array{AbstractFloat,1}:
> >  1.0
> >  2.0
> >  3.0
> > 
> > julia> log(a.^2)
> > 
> > 3-element Array{Float64,1}:
> >  0.0
> >  1.38629
> >  2.19722
> > 
> > julia> log(b.^2)
> > ERROR: MethodError: `log` has no method matching log(::Array{Any,1})
> > 
> > julia> typeof(a.^2)
> > Array{Float64,1}
> > 
> > julia> typeof(b.^2)
> > Array{Any,1}
> > 
> > julia> Base.return_types(*, (AbstractFloat, AbstractFloat))
> > 
> > 8-element Array{Any,1}:
> >  Float32
> >  Float64
> >  Float16
> >  BigFloat
> >  BigFloat
> >  BigFloat
> >  Union{}
> >  Any
> > 
> > You could do this:
> > julia> b2 = AbstractFloat[v^2 for v in b]
> > 
> > 3-element Array{AbstractFloat,1}:
> >  1.0
> >  4.0
> >  9.0
> > 
> > julia> log(b2)
> > 
> > 3-element Array{Any,1}:
> >  0.0
> >  1.38629
> >  2.19722
> > 
> > But overall, I highly recommend reading the performance tips page and
> > these
> > two sections of the FAQ:
> > http://docs.julialang.org/en/stable/manual/faq/#what-does-type-stable-mean
> > 
> > http://docs.julialang.org/en/stable/manual/faq/#how-do-abstract-or-ambiguo
> > us-fields-in-types-interact-with-the-compiler
> > 
> > Best,
> > --Tim
> > 
> > On Monday, January 04, 2016 01:47:44 PM Charles Novaes de Santana wrote:
> > > Hi people,
> > > 
> > > I would like to work with matrices represented as Arrays of Arrays of
> > > 
> > > AbstractFloats. Something like this:
> > > F=Array{AbstractFloat}[];#initialize the matrix F as an Array of
> > > 
> > > Arrays of Float
> > > 
> > > for (i in 1:10)
> > > 
> > > Fi = Array(AbstractFloat,0);#initialize the vector Fi as an
> > > 
> > > Array of Float
> > > 
> > > for (k in 1:5)
> > > 
> > > push!(Fi,k^2+i^2)
> > > 
> > > end#end-fork
> > > push!(F,Fi);
> > > 
> > > end#end-fori
> > > 
> > > typeof(F)
> > > Array{Array{AbstractFloat,N},1}
> > > 
> > > But I am experiencing problems to work with rows/columns of such Arrays.
> > 
> > I
> > 
> > > would like to calculate the logarithm of the square of elements of those
> > > 
> > > rows/columns like this:
> > > f = F[1];#a vector of AbstractFloat
> > > 
> > > typeof(f)
> > > Array{AbstractFloat,1}
> > > 
> > > typeof(f.^2)
> > > Array{Any,1}
> > > 
> > > log(f.^2)
> > > ERROR: MethodError: `log` has no method matching
> > 
> > log(::Array{Any,1})
> > 
> > > I understand this error only happens because I am working with Arrays of
> > > Arrays of AbstractFloats. If I run a similar code using a Matrix instead
> > 
> > of
> > 
> > > Array I don't have such problems:
> > >A = rand(10,5);#a matrix of floats (similar to an array of
> > >arrays)
> > >
> > > typeof(A)
> > > Array{Float64,2}
> > > 
> > > a = A[1,:];#a vector of Float
> > > 
> > > typeof(a)
> > > Array{Float64,2}
> > > 
> > > typeof(a.^2)
> > > Array{Float64,2}
> > > 
> > > log(a.^2)
> > > 
> > > everything runs smoothly.
> > > 
> > > My question: Am I doing something wrong in the way I am dealing with the
> > > Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or
> > > should I convert its elements to Array of Float instead of Array of Any?
> > > Any other suggestion?
> > > 
> > > Thanks for your attention and for any advice!
> > > 
> > > Charles



Re: [julia-users] Unions and TypeVar lower bounds

2016-01-04 Thread Tim Holy
Hi Fábio,

Probably relevant: 
https://github.com/JuliaLang/julia/pull/11805

--Tim

On Wednesday, December 30, 2015 09:50:27 AM Fábio Cardeal wrote:
> Given this:
> 
>   T = TypeVar(:T, Int, Any)
> 
> 
> I was wondering why while this happens:
> 
>   julia> Int <: Integer
>   true
> 
>   julia> Integer <: T
>   true
> 
> 
> This also happens:
> 
>   julia> Int <: Union{Int,Char}
>   true
> 
>   julia> Union{Int,Char} <: T
>   false
> 
> 
> Is this intended behaviour and I am just not understanding type variable
> lower bounds, or a missed corner case?


Re: [julia-users] Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Charles Novaes de Santana
Thanks a lot for your message, Tim.

I was wondering that it could be because of the AbstractFloat too. It makes
sense.

I am using AbstractFloat because I want to make it clear that the matrix
has Float elements, but I don't want to specify the architecture of the
machine of the user, because I had problems with users using 32bits
machines.

I will definitely read the link you sent me. And I will let you know what I
decide to use in our code. Thanks for your suggestion too!!

Best,

Charles

On 4 January 2016 at 14:03, Tim Holy  wrote:

> It has nothing to do with whether you're using a Matrix (which is just an
> Array{T,2}) or general Arrays. The question is, do you have to use
> AbstractFloat?
>
> julia> a = Float64[1,2,3]
> 3-element Array{Float64,1}:
>  1.0
>  2.0
>  3.0
>
> julia> b = AbstractFloat[1,2,3]
> 3-element Array{AbstractFloat,1}:
>  1.0
>  2.0
>  3.0
>
> julia> log(a.^2)
> 3-element Array{Float64,1}:
>  0.0
>  1.38629
>  2.19722
>
> julia> log(b.^2)
> ERROR: MethodError: `log` has no method matching log(::Array{Any,1})
>
> julia> typeof(a.^2)
> Array{Float64,1}
>
> julia> typeof(b.^2)
> Array{Any,1}
>
> julia> Base.return_types(*, (AbstractFloat, AbstractFloat))
> 8-element Array{Any,1}:
>  Float32
>  Float64
>  Float16
>  BigFloat
>  BigFloat
>  BigFloat
>  Union{}
>  Any
>
>
>
> You could do this:
> julia> b2 = AbstractFloat[v^2 for v in b]
> 3-element Array{AbstractFloat,1}:
>  1.0
>  4.0
>  9.0
>
> julia> log(b2)
> 3-element Array{Any,1}:
>  0.0
>  1.38629
>  2.19722
>
>
> But overall, I highly recommend reading the performance tips page and these
> two sections of the FAQ:
> http://docs.julialang.org/en/stable/manual/faq/#what-does-type-stable-mean
>
> http://docs.julialang.org/en/stable/manual/faq/#how-do-abstract-or-ambiguous-fields-in-types-interact-with-the-compiler
>
> Best,
> --Tim
>
> On Monday, January 04, 2016 01:47:44 PM Charles Novaes de Santana wrote:
> > Hi people,
> >
> > I would like to work with matrices represented as Arrays of Arrays of
> > AbstractFloats. Something like this:
> >
> > F=Array{AbstractFloat}[];#initialize the matrix F as an Array of
> > Arrays of Float
> > for (i in 1:10)
> > Fi = Array(AbstractFloat,0);#initialize the vector Fi as an
> > Array of Float
> > for (k in 1:5)
> > push!(Fi,k^2+i^2)
> > end#end-fork
> > push!(F,Fi);
> > end#end-fori
> >
> > typeof(F)
> > Array{Array{AbstractFloat,N},1}
> >
> > But I am experiencing problems to work with rows/columns of such Arrays.
> I
> > would like to calculate the logarithm of the square of elements of those
> > rows/columns like this:
> >
> > f = F[1];#a vector of AbstractFloat
> >
> > typeof(f)
> > Array{AbstractFloat,1}
> >
> > typeof(f.^2)
> > Array{Any,1}
> >
> > log(f.^2)
> > ERROR: MethodError: `log` has no method matching
> log(::Array{Any,1})
> >
> >
> > I understand this error only happens because I am working with Arrays of
> > Arrays of AbstractFloats. If I run a similar code using a Matrix instead
> of
> > Array I don't have such problems:
> >
> >A = rand(10,5);#a matrix of floats (similar to an array of arrays)
> >
> > typeof(A)
> > Array{Float64,2}
> >
> > a = A[1,:];#a vector of Float
> >
> > typeof(a)
> > Array{Float64,2}
> >
> > typeof(a.^2)
> > Array{Float64,2}
> >
> > log(a.^2)
> >
> >
> > everything runs smoothly.
> >
> > My question: Am I doing something wrong in the way I am dealing with the
> > Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or
> > should I convert its elements to Array of Float instead of Array of Any?
> > Any other suggestion?
> >
> > Thanks for your attention and for any advice!
> >
> > Charles
>
>


-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles


Re: [julia-users] Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Tim Holy
It has nothing to do with whether you're using a Matrix (which is just an 
Array{T,2}) or general Arrays. The question is, do you have to use 
AbstractFloat?

julia> a = Float64[1,2,3]
3-element Array{Float64,1}:
 1.0
 2.0
 3.0

julia> b = AbstractFloat[1,2,3]
3-element Array{AbstractFloat,1}:
 1.0
 2.0
 3.0

julia> log(a.^2)
3-element Array{Float64,1}:
 0.0
 1.38629
 2.19722

julia> log(b.^2)
ERROR: MethodError: `log` has no method matching log(::Array{Any,1})

julia> typeof(a.^2)
Array{Float64,1}

julia> typeof(b.^2)
Array{Any,1}

julia> Base.return_types(*, (AbstractFloat, AbstractFloat))
8-element Array{Any,1}:
 Float32 
 Float64 
 Float16 
 BigFloat
 BigFloat
 BigFloat
 Union{} 
 Any 



You could do this:
julia> b2 = AbstractFloat[v^2 for v in b]
3-element Array{AbstractFloat,1}:
 1.0
 4.0
 9.0

julia> log(b2)
3-element Array{Any,1}:
 0.0
 1.38629
 2.19722


But overall, I highly recommend reading the performance tips page and these 
two sections of the FAQ:
http://docs.julialang.org/en/stable/manual/faq/#what-does-type-stable-mean
http://docs.julialang.org/en/stable/manual/faq/#how-do-abstract-or-ambiguous-fields-in-types-interact-with-the-compiler

Best,
--Tim

On Monday, January 04, 2016 01:47:44 PM Charles Novaes de Santana wrote:
> Hi people,
> 
> I would like to work with matrices represented as Arrays of Arrays of
> AbstractFloats. Something like this:
> 
> F=Array{AbstractFloat}[];#initialize the matrix F as an Array of
> Arrays of Float
> for (i in 1:10)
> Fi = Array(AbstractFloat,0);#initialize the vector Fi as an
> Array of Float
> for (k in 1:5)
> push!(Fi,k^2+i^2)
> end#end-fork
> push!(F,Fi);
> end#end-fori
> 
> typeof(F)
> Array{Array{AbstractFloat,N},1}
> 
> But I am experiencing problems to work with rows/columns of such Arrays. I
> would like to calculate the logarithm of the square of elements of those
> rows/columns like this:
> 
> f = F[1];#a vector of AbstractFloat
> 
> typeof(f)
> Array{AbstractFloat,1}
> 
> typeof(f.^2)
> Array{Any,1}
> 
> log(f.^2)
> ERROR: MethodError: `log` has no method matching log(::Array{Any,1})
> 
> 
> I understand this error only happens because I am working with Arrays of
> Arrays of AbstractFloats. If I run a similar code using a Matrix instead of
> Array I don't have such problems:
> 
>A = rand(10,5);#a matrix of floats (similar to an array of arrays)
> 
> typeof(A)
> Array{Float64,2}
> 
> a = A[1,:];#a vector of Float
> 
> typeof(a)
> Array{Float64,2}
> 
> typeof(a.^2)
> Array{Float64,2}
> 
> log(a.^2)
> 
> 
> everything runs smoothly.
> 
> My question: Am I doing something wrong in the way I am dealing with the
> Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or
> should I convert its elements to Array of Float instead of Array of Any?
> Any other suggestion?
> 
> Thanks for your attention and for any advice!
> 
> Charles



[julia-users] Re: Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Charles Novaes de Santana
And (maybe) the most important question:

For which reason the square of an Array{AbstractFloat,1} is Array{Any,1}
instead of Array{AbstractFloat,1}?

julia> typeof(f)
Array{AbstractFloat,1}

julia> typeof(f.^2)
Array{Any,1}

thanks,

Charles

On 4 January 2016 at 13:47, Charles Novaes de Santana <
charles.sant...@gmail.com> wrote:

> Hi people,
>
> I would like to work with matrices represented as Arrays of Arrays of
> AbstractFloats. Something like this:
>
> F=Array{AbstractFloat}[];#initialize the matrix F as an Array of
> Arrays of Float
> for (i in 1:10)
> Fi = Array(AbstractFloat,0);#initialize the vector Fi as an
> Array of Float
> for (k in 1:5)
> push!(Fi,k^2+i^2)
> end#end-fork
> push!(F,Fi);
> end#end-fori
>
> typeof(F)
> Array{Array{AbstractFloat,N},1}
>
> But I am experiencing problems to work with rows/columns of such Arrays. I
> would like to calculate the logarithm of the square of elements of those
> rows/columns like this:
>
> f = F[1];#a vector of AbstractFloat
>
> typeof(f)
> Array{AbstractFloat,1}
>
> typeof(f.^2)
> Array{Any,1}
>
> log(f.^2)
> ERROR: MethodError: `log` has no method matching
> log(::Array{Any,1})
>
>
> I understand this error only happens because I am working with Arrays of
> Arrays of AbstractFloats. If I run a similar code using a Matrix instead of
> Array I don't have such problems:
>
>A = rand(10,5);#a matrix of floats (similar to an array of arrays)
>
> typeof(A)
> Array{Float64,2}
>
> a = A[1,:];#a vector of Float
>
> typeof(a)
> Array{Float64,2}
>
> typeof(a.^2)
> Array{Float64,2}
>
> log(a.^2)
>
>
> everything runs smoothly.
>
> My question: Am I doing something wrong in the way I am dealing with the
> Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or
> should I convert its elements to Array of Float instead of Array of Any?
> Any other suggestion?
>
> Thanks for your attention and for any advice!
>
> Charles
>
> --
> Um axé! :)
>
> --
> Charles Novaes de Santana, PhD
> http://www.imedea.uib-csic.es/~charles
>



-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles


[julia-users] Problems using log and Arrays of AbstractFloats

2016-01-04 Thread Charles Novaes de Santana
Hi people,

I would like to work with matrices represented as Arrays of Arrays of
AbstractFloats. Something like this:

F=Array{AbstractFloat}[];#initialize the matrix F as an Array of
Arrays of Float
for (i in 1:10)
Fi = Array(AbstractFloat,0);#initialize the vector Fi as an
Array of Float
for (k in 1:5)
push!(Fi,k^2+i^2)
end#end-fork
push!(F,Fi);
end#end-fori

typeof(F)
Array{Array{AbstractFloat,N},1}

But I am experiencing problems to work with rows/columns of such Arrays. I
would like to calculate the logarithm of the square of elements of those
rows/columns like this:

f = F[1];#a vector of AbstractFloat

typeof(f)
Array{AbstractFloat,1}

typeof(f.^2)
Array{Any,1}

log(f.^2)
ERROR: MethodError: `log` has no method matching log(::Array{Any,1})


I understand this error only happens because I am working with Arrays of
Arrays of AbstractFloats. If I run a similar code using a Matrix instead of
Array I don't have such problems:

   A = rand(10,5);#a matrix of floats (similar to an array of arrays)

typeof(A)
Array{Float64,2}

a = A[1,:];#a vector of Float

typeof(a)
Array{Float64,2}

typeof(a.^2)
Array{Float64,2}

log(a.^2)


everything runs smoothly.

My question: Am I doing something wrong in the way I am dealing with the
Array of Arrays of AbstractFloat? Should I convert it to a Matrix? Or
should I convert its elements to Array of Float instead of Array of Any?
Any other suggestion?

Thanks for your attention and for any advice!

Charles

-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles


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

2016-01-04 Thread Jeffrey Sarnoff
I meant: typeof(f).name


On Monday, January 4, 2016 at 6:27:43 AM UTC-5, Jeffrey Sarnoff wrote:
>
> try Foo.name (without the '.primary'), and as Mauro says (try not to use 
> it much)
>
>
> On Monday, January 4, 2016 at 5:39:53 AM UTC-5, Mauro wrote:
>>
>> This should do the trick: 
>>
>> Foo.name.primary 
>>
>> (I think this defeats type inference, so try not to use it in 
>> performance critical code) 
>>
>> On Mon, 2016-01-04 at 11:31, Sheehan Olver  wrote: 
>> > If I have a type 
>> > 
>> > ```julia 
>> > immutable Foo{D} 
>> >  x::D 
>> > end 
>> > 
>> > f=Foo(5) 
>> > ``` 
>> > 
>> > 
>> > then `typeof(f)` gives me `Foo{Int}`.  Is it possible to get access to 
>> just 
>> > `Foo`?  I.e., I want to do: 
>> > 
>> > ``` 
>> > F=droptemplates(typeof(f))  # returns pointer to Foo 
>> > F(1.0) 
>> > ``` 
>>
>

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

2016-01-04 Thread Jeffrey Sarnoff
try Foo.name (without the '.primary'), and as Mauro says (try not to use it 
much)


On Monday, January 4, 2016 at 5:39:53 AM UTC-5, Mauro wrote:
>
> This should do the trick: 
>
> Foo.name.primary 
>
> (I think this defeats type inference, so try not to use it in 
> performance critical code) 
>
> On Mon, 2016-01-04 at 11:31, Sheehan Olver  > wrote: 
> > If I have a type 
> > 
> > ```julia 
> > immutable Foo{D} 
> >  x::D 
> > end 
> > 
> > f=Foo(5) 
> > ``` 
> > 
> > 
> > then `typeof(f)` gives me `Foo{Int}`.  Is it possible to get access to 
> just 
> > `Foo`?  I.e., I want to do: 
> > 
> > ``` 
> > F=droptemplates(typeof(f))  # returns pointer to Foo 
> > F(1.0) 
> > ``` 
>


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

2016-01-04 Thread Mauro
This should do the trick:

Foo.name.primary

(I think this defeats type inference, so try not to use it in
performance critical code)

On Mon, 2016-01-04 at 11:31, Sheehan Olver  wrote:
> If I have a type
>
> ```julia
> immutable Foo{D}
>  x::D
> end
>
> f=Foo(5)
> ```
>
>
> then `typeof(f)` gives me `Foo{Int}`.  Is it possible to get access to just
> `Foo`?  I.e., I want to do:
>
> ```
> F=droptemplates(typeof(f))  # returns pointer to Foo
> F(1.0)
> ```


[julia-users] How to get untemplated typename?

2016-01-04 Thread Sheehan Olver
If I have a type

```julia
immutable Foo{D}
 x::D
end

f=Foo(5)
```


then `typeof(f)` gives me `Foo{Int}`.  Is it possible to get access to just 
`Foo`?  I.e., I want to do:

```
F=droptemplates(typeof(f))  # returns pointer to Foo
F(1.0)
```