-
-
Notifications
You must be signed in to change notification settings - Fork 44.3k
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
Adding multibit-manipulation algorithm implemented with bitwise operations #11418
base: master
Are you sure you want to change the base?
Conversation
Few typos, doctest error
for more information, see https://pre-commit.ci
Blank lines with spaces, trailing spaces at end of line, etc.
Is it or isn't it ?
for more information, see https://pre-commit.ci
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Anything like int(None) is going to cause a loud error. """ | ||
|
||
|
||
def bit_get(bint: int, index: int): |
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.
Please provide return type hint for the function: bit_get
. If the function does not return a value, please provide the type hint as: def function() -> None:
return multibit_get(bint, index, 1) | ||
|
||
|
||
def bit_set(bint: int, index: int, value: int = 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.
Please provide return type hint for the function: bit_set
. If the function does not return a value, please provide the type hint as: def function() -> None:
return multibit_set(bint, index, 1, value) | ||
|
||
|
||
def bit_insert(bint: int, index: int, value: int = 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.
Please provide return type hint for the function: bit_insert
. If the function does not return a value, please provide the type hint as: def function() -> None:
Add type hints and fix leading spaces issues.
for more information, see https://pre-commit.ci
Fixing tabs instead of spaces in comments
for more information, see https://pre-commit.ci
Fixed int | None return hints, mypy error
for more information, see https://pre-commit.ci
Changed return type from None to Exceptions and fix doctests
Few typos, debugging advice
for more information, see https://pre-commit.ci
Fix trailing spaces
Better comments, errors, check bit_length=0 conditions
for more information, see https://pre-commit.ci
Revert to old
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
@@ -0,0 +1,255 @@ | |||
"""Bit integer manipulation, both single bit and multi-bit list-like |
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.
An error occurred while parsing the file: bit_manipulation/multibit_manipulation.py
Traceback (most recent call last):
File "/opt/render/project/src/algorithms_keeper/parser/python_parser.py", line 146, in parse
reports = lint_file(
^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
tokenizer error: inconsistent mixing of tabs and spaces
"""Bit integer manipulation, both single bit and multi-bit list-like
^
for more information, see https://pre-commit.ci
Loooong lines
I think I have multibit-manipulation.py debugged and ready for review. Do you have any suggestions ? Does the module name really describe what it does ? Are the comments unclear or too long ? All the parenthesis in the multi-bit functions are complicated, but they run measurably faster on a Raspberry Pi Pico as a single statement. No garbage collection of course ( especially in 264K ), but Python seems to optimize these constructions beyond just saving memory and reference scavenging. After working with them, I find them readable in a straightforward left-right manner. Kind of harking back to the bit buffers of yesteryear, except they implemented it with hardware. I had a problem with Ruff on my client workstation. There were many validation it didn't check. Is there a TOML configuration file I can use to match my Ruff to yours ?
|
Describe your change:
Checklist: