Skip to content
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

docs: fix example for sort and add new doctest #56843

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

rapus95
Copy link
Contributor

@rapus95 rapus95 commented Dec 16, 2024

No description provided.

@rapus95 rapus95 added docs This change adds or pertains to documentation status: waiting for PR reviewer PR is complete and seems ready to merge. Has tests and news/compat if needed. CI failures unrelated. labels Dec 16, 2024
@rapus95 rapus95 changed the title fix example in sort! fix example in sort! docs Dec 16, 2024
@rapus95 rapus95 requested a review from knuesel December 16, 2024 02:28
Copy link
Member

@inkydragon inkydragon left a comment

Choose a reason for hiding this comment

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

Maybe we can make the comment into doctest as well.

julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs))
4-element Vector{Int64}:
 2
 1
 3
 0

julia> ans == sort(0:3, by=x->abs(x-2))
true

Or

julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs))
4-element Vector{Int64}:
 2
 1
 3
 0

julia> sort(0:3, by=x->x-2, order=Base.Order.By(abs)) == sort(0:3, by=x->abs(x-2))
true

@inkydragon inkydragon removed the status: waiting for PR reviewer PR is complete and seems ready to merge. Has tests and news/compat if needed. CI failures unrelated. label Dec 16, 2024
@ViralBShah
Copy link
Member

Looks good - would be great to get the other doctest in also as suggested.

@rapus95
Copy link
Contributor Author

rapus95 commented Dec 16, 2024

never created a doctest before, I'll try to look into it in a few hours, all pointers and hints/tips welcome

Copy link
Member

@knuesel knuesel left a comment

Choose a reason for hiding this comment

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

Agreed it would be nice to have the version in comment tested by the doctest.

@rapus95 the whole Markdown code block in this comment, with all these examples, is one big doctest. It should just be a matter of replacing a part of the code block with another, exactly as proposed by @inkydragon . Then to test the doctest locally you can compile Julia and run the test command as described in CONTRIBUTING.md.

@LilithHafner LilithHafner added the sorting Put things in order label Dec 16, 2024
@rapus95
Copy link
Contributor Author

rapus95 commented Dec 17, 2024

I added the 2nd proposal (which doesn't use ans). Please take a look and merge if nothing else to add :)

@inkydragon inkydragon added the merge me PR is reviewed. Merge when all tests are passing label Dec 18, 2024
@inkydragon inkydragon changed the title fix example in sort! docs docs: fix example for sort and add new doctest Dec 18, 2024
@inkydragon inkydragon merged commit b1007ce into JuliaLang:master Dec 18, 2024
9 checks passed
@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Dec 18, 2024
@rapus95 rapus95 deleted the patch-2 branch December 19, 2024 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation sorting Put things in order
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants