modular icon indicating copy to clipboard operation
modular copied to clipboard

[stdlib] implement `bit_ceil` and `bit_floor`

Open jiex-liu opened this issue 1 year ago • 6 comments

fix #2682

jiex-liu avatar May 18 '24 09:05 jiex-liu

Implementation of bit_ceil is based on c++ bit_ceil

jiex-liu avatar May 18 '24 09:05 jiex-liu

Should we include the reference in doc string or comment in the future?

soraros avatar May 18 '24 18:05 soraros

Should we include the reference in doc string or comment in the future?

@soraros ops yeah you are right. I'll include it in the docstring for now. @laszlokindrat which one do you think is more suitable?

jiex-liu avatar May 19 '24 05:05 jiex-liu

Should we include the reference in doc string or comment in the future?

@soraros ops yeah you are right. I'll include it in the docstring for now. @laszlokindrat which one do you think is more suitable?

I would prefer to not reference external documentation. Can you please just ensure that the docstrings are (more or less) self explanatory?

laszlokindrat avatar May 20 '24 17:05 laszlokindrat

@laszlokindrat My idea was that performant numerical code can contain a large amount of black magic, thus not very self-explanatory. If we are indeed using an existing implementation (from a paper, libc++, etc) and include a reference to them, it would be less surprising to future maintainers when they see the said magic. If you think a link is not fitting for the doctoring, maybe we could simply leave a comment.

soraros avatar May 20 '24 22:05 soraros

@laszlokindrat I have fixed all the requests. In terms of the reference, I do agree with @soraros in that numerical code does sometime contains "black magic". While these two functions seems pretty ok to understand, there might be functions that has wizardry implementation in the future and adding a reference can definitely help future maintainer. I have taken out the c++ reference. If there is a consent, I can put it back in.

jiex-liu avatar May 21 '24 07:05 jiex-liu

If you think a link is not fitting for the doctoring, maybe we could simply leave a comment.

Yeah, a link within a comment in the implementation is fine, since that's a message to developers working on the stdlib. I just didn't want the generated docs to reference external links (and also, docstrings should explain what the function does, not how). @LJ-9801 could you please do this?

laszlokindrat avatar May 22 '24 23:05 laszlokindrat

!sync

JoeLoser avatar May 22 '24 23:05 JoeLoser

@laszlokindrat @JoeLoser mojo crash on test_reversed.mojo? test crashes sometime on my M1 mac as well. Most of the time they pass. see 332c152

jiex-liu avatar May 23 '24 04:05 jiex-liu

!sync

laszlokindrat avatar May 26 '24 11:05 laszlokindrat

✅🟣 This contribution has been merged 🟣✅

Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the nightly branch during the next Mojo nightly release, typically within the next 24-48 hours.

We use Copybara to merge external contributions, click here to learn more.

modularbot avatar May 26 '24 12:05 modularbot

Landed in abfdac1a7e78e72e148cfd5dec319649fa1d1ca8! Thank you for your contribution 🎉

modularbot avatar May 27 '24 05:05 modularbot