Skip to content

Some more examples/refs for array docs#27294

Merged
mbauman merged 2 commits intomasterfrom
ksh/arraydocsagain
May 29, 2018
Merged

Some more examples/refs for array docs#27294
mbauman merged 2 commits intomasterfrom
ksh/arraydocsagain

Conversation

@kshyatt
Copy link
Copy Markdown
Member

@kshyatt kshyatt commented May 28, 2018

No description provided.

@kshyatt kshyatt added docs This change adds or pertains to documentation arrays [a, r, r, a, y, s] labels May 28, 2018
@kshyatt kshyatt requested a review from fredrikekre May 28, 2018 23:20
Comment thread base/abstractarray.jl
@@ -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`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ...

Comment thread base/abstractarray.jl Outdated

# Examples
```jldoctest
julia> A = zeros(2, 2, 2, 2);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
```

Comment thread base/array.jl Outdated

# Examples
```jldoctest
julia> ut = Union{Float64, UInt8}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

Comment thread base/array.jl Outdated
julia> Base.bitsunionsize(ut)
0x0000000000000008

julia> ut = Union{Float64, UInt8, Int128}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

Comment thread base/array.jl Outdated
julia> Base.isbitsunion(ut)
true

julia> ut = Union{Float64, String}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

Comment thread base/array.jl Outdated

# Examples
```jldoctest
julia> ut = Union{Float64, UInt8}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a need to create the variable at all here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, probably cleaner and more concise without it.

@mbauman
Copy link
Copy Markdown
Member

mbauman commented May 29, 2018

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).

@mbauman mbauman merged commit 0c575eb into master May 29, 2018
@mbauman mbauman deleted the ksh/arraydocsagain branch May 29, 2018 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays [a, r, r, a, y, s] docs This change adds or pertains to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants