Skip to content

Commit 7afdb54

Browse files
committed
rm docstrings
1 parent 78c6787 commit 7afdb54

File tree

1 file changed

+0
-118
lines changed

1 file changed

+0
-118
lines changed

src/Compat.jl

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -366,127 +366,9 @@ end
366366
if VERSION < v"1.9.0-DEV.1163"
367367
import Base: IteratorSize, HasLength, HasShape, OneTo
368368
export stack
369-
370-
"""
371-
stack(iter; [dims])
372-
373-
Combine a collection of arrays (or other iterable objects) of equal size
374-
into one larger array, by arranging them along one or more new dimensions.
375-
376-
By default the axes of the elements are placed first,
377-
giving `size(result) = (size(first(iter))..., size(iter)...)`.
378-
This has the same order of elements as [`Iterators.flatten`](@ref)`(iter)`.
379-
380-
With keyword `dims::Integer`, instead the `i`th element of `iter` becomes the slice
381-
[`selectdim`](@ref)`(result, dims, i)`, so that `size(result, dims) == length(iter)`.
382-
In this case `stack` reverses the action of [`eachslice`](@ref) with the same `dims`.
383-
384-
The various [`cat`](@ref) functions also combine arrays. However, these all
385-
extend the arrays' existing (possibly trivial) dimensions, rather than placing
386-
the arrays along new dimensions.
387-
They also accept arrays as separate arguments, rather than a single collection.
388-
389-
!!! compat "Julia 1.9"
390-
This function requires at least Julia 1.9.
391-
392-
# Examples
393-
```jldoctest
394-
julia> vecs = (1:2, [30, 40], Float32[500, 600]);
395-
396-
julia> mat = stack(vecs)
397-
2×3 Matrix{Float32}:
398-
1.0 30.0 500.0
399-
2.0 40.0 600.0
400-
401-
julia> mat == hcat(vecs...) == reduce(hcat, collect(vecs))
402-
true
403-
404-
julia> vec(mat) == vcat(vecs...) == reduce(vcat, collect(vecs))
405-
true
406-
407-
julia> stack(zip(1:4, 10:99)) # accepts any iterators of iterators
408-
2×4 Matrix{Int64}:
409-
1 2 3 4
410-
10 11 12 13
411-
412-
julia> vec(ans) == collect(Iterators.flatten(zip(1:4, 10:99)))
413-
true
414-
415-
julia> stack(vecs; dims=1) # unlike any cat function, 1st axis of vecs[1] is 2nd axis of result
416-
3×2 Matrix{Float32}:
417-
1.0 2.0
418-
30.0 40.0
419-
500.0 600.0
420-
421-
julia> x = rand(3,4);
422-
423-
julia> x == stack(eachcol(x)) == stack(eachrow(x), dims=1) # inverse of eachslice
424-
true
425-
```
426-
427-
Higher-dimensional examples:
428-
429-
```jldoctest
430-
julia> A = rand(5, 7, 11);
431369

432-
julia> E = eachslice(A, dims=2); # a vector of matrices
433-
434-
julia> (element = size(first(E)), container = size(E))
435-
(element = (5, 11), container = (7,))
436-
437-
julia> stack(E) |> size
438-
(5, 11, 7)
439-
440-
julia> stack(E) == stack(E; dims=3) == cat(E...; dims=3)
441-
true
442-
443-
julia> A == stack(E; dims=2)
444-
true
445-
446-
julia> M = (fill(10i+j, 2, 3) for i in 1:5, j in 1:7);
447-
448-
julia> (element = size(first(M)), container = size(M))
449-
(element = (2, 3), container = (5, 7))
450-
451-
julia> stack(M) |> size # keeps all dimensions
452-
(2, 3, 5, 7)
453-
454-
julia> stack(M; dims=1) |> size # vec(container) along dims=1
455-
(35, 2, 3)
456-
457-
julia> hvcat(5, M...) |> size # hvcat puts matrices next to each other
458-
(14, 15)
459-
```
460-
"""
461370
stack(iter; dims=:) = _stack(dims, iter)
462371

463-
"""
464-
stack(f, args...; [dims])
465-
466-
Apply a function to each element of a collection, and `stack` the result.
467-
Or to several collections, [`zip`](@ref)ped together.
468-
469-
The function should return arrays (or tuples, or other iterators) all of the same size.
470-
These become slices of the result, each separated along `dims` (if given) or by default
471-
along the last dimensions.
472-
473-
See also [`mapslices`](@ref), [`eachcol`](@ref).
474-
475-
# Examples
476-
```jldoctest
477-
julia> stack(c -> (c, c-32), "julia")
478-
2×5 Matrix{Char}:
479-
'j' 'u' 'l' 'i' 'a'
480-
'J' 'U' 'L' 'I' 'A'
481-
482-
julia> stack(eachrow([1 2 3; 4 5 6]), (10, 100); dims=1) do row, n
483-
vcat(row, row .* n, row ./ n)
484-
end
485-
2×9 Matrix{Float64}:
486-
1.0 2.0 3.0 10.0 20.0 30.0 0.1 0.2 0.3
487-
4.0 5.0 6.0 400.0 500.0 600.0 0.04 0.05 0.06
488-
```
489-
"""
490372
stack(f, iter; dims=:) = _stack(dims, f(x) for x in iter)
491373
stack(f, xs, yzs...; dims=:) = _stack(dims, f(xy...) for xy in zip(xs, yzs...))
492374

0 commit comments

Comments
 (0)