Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Michael Krabbe Borregaard
That's wonderful news, thanks a lot for this. I know .() is just syntactic
sugar, but to me it really feels intuitive and powerful. Thanks again,
Michael

On Thu, Aug 18, 2016 at 8:27 PM, Steven G. Johnson 
wrote:

> (If you want dot calls to work with your own container type, then you just
> need to make broadcast(...) work.  e.g. here is some discussion for
> ApproxFun: https://github.com/ApproxFun/ApproxFun.jl/issues/356)
>


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Steven G. Johnson
(If you want dot calls to work with your own container type, then you just 
need to make broadcast(...) work.  e.g. here is some discussion for 
ApproxFun: https://github.com/ApproxFun/ApproxFun.jl/issues/356)


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Steven G. Johnson


On Thursday, August 18, 2016 at 2:22:13 PM UTC-4, Michael Borregaard wrote:
>
> It'd be nice with a list of the methods a user-defined type would need to 
> define to be amenable to .() in an Array.
>

In 0.6, once #16966 is ironed out, then you won't have to anything (as long 
as you want your type to be treated as a scalar, not as a container); 
user-defined types will just work with "dot calls".   In 0.5, the dot calls 
are mainly for numeric types (because of the limitations of the "broadcast" 
function).


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Michael Krabbe Borregaard
It'd be nice with a list of the methods a user-defined type would need to
define to be amenable to .() in an Array.

On Thu, Aug 18, 2016 at 8:16 PM, Michael Krabbe Borregaard <
mkborrega...@gmail.com> wrote:

> Thanks! Right now it makes a difference for my understanding just to know
> that this is an issue with String, and that .() will otherwise behave like
> map.
>


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Michael Krabbe Borregaard
Thanks! Right now it makes a difference for my understanding just to know
that this is an issue with String, and that .() will otherwise behave like
map.


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Gabriel Gellner


On Thursday, August 18, 2016 at 10:52:42 AM UTC-7, Michael Borregaard wrote:
>
> That sounds right. I wonder if this is not a bug?
>

>From my reading of the all the related issues, it is a known "issue" ;) It 
looks like a good solution is being ironed out. But I don't think this will 
be added to the 0.5.x timeline, but rather be a 0.6.x feature (along with a 
lot of other amazing .() features!).

For your example you can use the workaround at the moment that map deals 
with this case in the expected manner:

map(x->is(x, "b"), ["a", "b"])

will give the array answer (though likely not what you wanted ...)

Gabriel


Re: [julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Michael Krabbe Borregaard
That sounds right. I wonder if this is not a bug?


[julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Gabriel Gellner
My understanding (which can easily be wrong!) is that this stems from 
https://github.com/JuliaLang/julia/issues/16966.
Namely that size("b") throws a method error, whereas your size(2) gives a 
null tuple (). So in general broadcast (which is what the .() is sugar for) 
requires that the element type object that will be vectorizing over has a 
method defined for size.

In general I find Julia's behavior with strings/chars hard to understand. I 
usually just use python when I need to do a lot of string processing.

On Thursday, August 18, 2016 at 7:09:19 AM UTC-7, Michael Borregaard wrote:

> I have a hard time figuring out what functions and types accept the 
> broadcast dot in 0.5. E.g.,
>
> is(1, 2)# false
> is.([1, 2], 2)  # Bool[false, true]
>
> is("a", "b")#false
> is.("["a","b"], "b")#MethodError: no method matching size(::String)
>
> Can anyone give me a hint?
>


[julia-users] Re: When can the broadcast dot (in 0.5) be used?

2016-08-18 Thread Michael Borregaard
Please ignore the erroneous first " in the last code line.