-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add doctest example for fill! #19422
Conversation
2×3 Array{Float64,2}: | ||
2.0 2.0 2.0 | ||
2.0 2.0 2.0 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Two thoughts: Perhaps suppress the output of A = zeros(2,3)
for compactness? Perhaps also add examples for the two trip hazards mentioned in the docstring? Best!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like showing the output of zeros
just so people can see that fill!
actually does something, especially since it's an early docstring in stdlib
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers, fair enough :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also looked into adding the examples for objrefs and eval-once but it makes the docstring super long. I think it's ok to leave those un-exampled for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about demos along these lines? Too long? Best!
julia> fill!(Vector{Int}(3), rand(Int))
3-element Array{Int64,1}:
-7884629895546034086
-7884629895546034086
-7884629895546034086
julia> a = [1, 1, 1]; A = fill!(Vector{Vector{Int}}(3), a); a[1] = 2; A
3-element Array{Array{Int64,1},1}:
[2,1,1]
[2,1,1]
[2,1,1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to use rand
in doctests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! An alternative for that demo:
julia> x = 0; f() = (global x += 1; x); fill!(Vector{Int}(3), f())
1
1
1
93372d3
to
fefbd3e
Compare
Added @Sacha0's great suggestions, this was a really easy rebase. |
* Add doctest example for fill! * Add more doctests
* Add doctest example for fill! * Add more doctests
No description provided.