I’d like to add the following example too, of using *both* inner and outer, 
to show off the flexibility of repeat:

julia> repeat(A, inner=[1,2], outer=[2,1])
4x4 Array{Int64,2}:
 1  1  2  2
 3  3  4  4
 1  1  2  2
 3  3  4  4

Until I had tried that in the REPL myself, I didn’t really trust that I 
actually understood what keywords really meant. Now I think I do.
// T


On Tuesday, June 17, 2014 2:36:39 PM UTC+2, Bruno Rodrigues wrote:

For outer, I think that it would be clearer to say that it repeats (or 
> clones?) the whole array along the specified dimensions. For inner, I think 
> it's ok.
>
> Looking at the tests for repeat, I think we could use this as an example:
>
>     As an illustrative example, let's consider array A:
>     A = [1 2;3 4]
>
>     2x2 Array{Int64,2}:
>      1  2
>      3  4
>
>     If you want to repeat array A along the second dimension:
>
>     repeat(A,inner=[1,1],outer=[1,2])
>     2x4 Array{Int64,2}:
>      1  2  1  2
>      3  4  3  4
>
>     You can also repeat the columns first:
>
>     repeat(A,inner=[1,2],outer=[1,1])
>     2x4 Array{Int64,2}:
>      1  1  2  2
>      3  3  4  4
>
>
>
>     You can also create a new array that repeats A along a third dimension:
>
>     repeat(A,inner=[1,1],outer=[1,1,2])
>     2x2x2 Array{Int64,3}:
>     [:, :, 1] =
>      1  2
>      3  4
>
>     [:, :, 2] =
>      1  2
>      3  4
>
>
> Is there a limit on how a docstring can be? Could we add more examples?
>
> On Thursday, June 12, 2014 4:59:14 PM UTC+2, John Myles White wrote:
>>
>> Rewriting the documentation for repeat would be great. I’m the guilty 
>> party for that piece of documentation and agree that it’s not very good. 
>> Rewriting it from scratch is probably a good idea.
>>
>> I’m not sure I think `tile` is much better than `outer`. Maybe we should 
>> use something like `perelement` and `perslice` as the keywords? If we 
>> revise the keywords, we should also find terms to describe one additional 
>> piece of functionality I’d like to add to repeat: the ability to repeat 
>> specific elements a distinct number of times. That’s the main thing that 
>> repeat is missing that you’d get from R’s rep function.
>>
>> If you’re looking for good examples for the documentation, there are a 
>> bunch of tests for `repeat` you could use as inspiration: 
>> https://github.com/JuliaLang/julia/blob/b320b66db8fb97cc3b96fe4089b7b15528ab346c/test/arrayops.jl#L302
>>
>>  — John
>>
>> On Jun 12, 2014, at 6:17 AM, Patrick O'Leary <[email protected]> 
>> wrote:
>>
>> On Thursday, June 12, 2014 7:57:03 AM UTC-5, Bruno Rodrigues wrote:
>>>
>>> repeat() is much more useful that Matlab's repmat(), but the docstring 
>>> is unclear, at least for me. Unfortunately, I don't have, right now, any 
>>> proposals to correct it. Could maybe an example be added to the docstring? 
>>> Maybe it could be clearer this way.
>>>
>>
>> I think an example would help make this immediately obvious. I also 
>> wonder if the keyword arguments could be better--I don't have a good 
>> alternative for "inner", but "tile" seems like a good alternative to 
>> "outer". That may at least be useful in a rework of the doc.
>>
>> Note that you don't have to supply both keyword arguments, only one, so 
>> if you're not using the feature of "inner" you can simply omit it. 
>>
>>
>> ​

Reply via email to