Some more examples/refs for array docs#27294
Conversation
| @@ -968,6 +968,22 @@ _unsafe_ind2sub(sz, i) = (@_inline_meta; _ind2sub(sz, i)) | |||
| setindex!(A, X, inds...) | |||
|
|
|||
| Store values from array `X` within some subset of `A` as specified by `inds`. | |||
There was a problem hiding this comment.
While you are at it; append something like
The syntax `A[inds...] = X` (lowers|is equivalent) to `setindex!(A, X, inds...)`
?
Perhaps also change the signature up top to
setindex!(A, X, inds...)
A[inds...] = X
Store values ...
|
|
||
| # Examples | ||
| ```jldoctest | ||
| julia> A = zeros(2, 2, 2, 2); |
There was a problem hiding this comment.
Use a smaller matrix such that we can show if all after setindex!ing? Perhaps also unnecessary to use CartesianIndex? Proposal:
```jldoctest
julia> A = zeros(2,2);
julia> setindex!(A, [10, 20], [1, 2]);
julia> A[[3, 4]] = [30, 40];
julia> A
2×2 Array{Float64,2}:
10.0 30.0
20.0 40.0
```
|
|
||
| # Examples | ||
| ```jldoctest | ||
| julia> ut = Union{Float64, UInt8} |
| julia> Base.bitsunionsize(ut) | ||
| 0x0000000000000008 | ||
|
|
||
| julia> ut = Union{Float64, UInt8, Int128} |
| julia> Base.isbitsunion(ut) | ||
| true | ||
|
|
||
| julia> ut = Union{Float64, String} |
|
|
||
| # Examples | ||
| ```jldoctest | ||
| julia> ut = Union{Float64, UInt8} |
There was a problem hiding this comment.
Also, is there a need to create the variable at all here?
There was a problem hiding this comment.
No, probably cleaner and more concise without it.
e157f44 to
d267e1c
Compare
|
I confirmed this fixed the doctests broken in #27038. The rest of the PR looks great — thanks @kshyatt. The remaining doctest failure is pre-existing and unrelated (Edit: and is now fixed on master through a revert — so this should pass on master now. I'll keep an eye on that worker). |
No description provided.