-
Notifications
You must be signed in to change notification settings - Fork 72
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
CI: use ruff to format xdsl #3023
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
.pre-commit-config.yaml
Outdated
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.
Config change 1/2
pyproject.toml
Outdated
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.
Config change 2/2
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3023 +/- ##
==========================================
- Coverage 89.85% 89.85% -0.01%
==========================================
Files 412 412
Lines 51816 51816
Branches 8064 8064
==========================================
- Hits 46559 46558 -1
Misses 3967 3967
- Partials 1290 1291 +1 ☔ View full report in Codecov by Sentry. |
Signed numbers are stored as Two's complement, meaning that the highest bit is used as | ||
the sign. Here's a table of values for a three-bit two's complement integer type: | ||
|
||
|------|----------|--------| | ||
| bits | unsigned | signed | | ||
|------|----------|--------| | ||
| 000 | 0 | +0 | | ||
| 001 | 1 | +1 | | ||
| 010 | 2 | +2 | | ||
| 011 | 3 | +3 | | ||
| 100 | 4 | -4 | | ||
| 101 | 5 | -3 | | ||
| 110 | 6 | -2 | | ||
| 111 | 7 | -1 | | ||
|------|----------|--------| | ||
|
||
https://en.wikipedia.org/wiki/Two%27s_complement | ||
|
||
We follow LLVM and MLIR in having a concept of signless integers: | ||
|
||
https://mlir.llvm.org/docs/Rationale/Rationale/#integer-signedness-semantics | ||
|
||
The main idea is to not have the signedness be a property of the type of the value, | ||
and rather be a property of the operation. That means that a signless value can be | ||
interpreted as either a signed or unsigned value at runtime, depending on the | ||
operation that acts on it. | ||
|
||
During interpretation, this gets a little tricky, as the same bit pattern can be | ||
interpreted as two runtime values, meaning that comparing signless values is a little | ||
involved. For example, a signless value of 5 is equal to a signless value of -3, since | ||
their bit representations are the same. | ||
Signed numbers are stored as Two's complement, meaning that the highest bit is used as | ||
the sign. Here's a table of values for a three-bit two's complement integer type: | ||
|
||
|------|----------|--------| | ||
| bits | unsigned | signed | | ||
|------|----------|--------| | ||
| 000 | 0 | +0 | | ||
| 001 | 1 | +1 | | ||
| 010 | 2 | +2 | | ||
| 011 | 3 | +3 | | ||
| 100 | 4 | -4 | | ||
| 101 | 5 | -3 | | ||
| 110 | 6 | -2 | | ||
| 111 | 7 | -1 | | ||
|------|----------|--------| | ||
|
||
https://en.wikipedia.org/wiki/Two%27s_complement | ||
|
||
We follow LLVM and MLIR in having a concept of signless integers: | ||
|
||
https://mlir.llvm.org/docs/Rationale/Rationale/#integer-signedness-semantics | ||
|
||
The main idea is to not have the signedness be a property of the type of the value, | ||
and rather be a property of the operation. That means that a signless value can be | ||
interpreted as either a signed or unsigned value at runtime, depending on the | ||
operation that acts on it. | ||
|
||
During interpretation, this gets a little tricky, as the same bit pattern can be | ||
interpreted as two runtime values, meaning that comparing signless values is a little | ||
involved. For example, a signless value of 5 is equal to a signless value of -3, since | ||
their bit representations are the same. |
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.
❤️
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.
Nice, just a comment on the underlying one about lines length:
The line length change in that PR was to move it to linting only, meaning that the formatter is still at black's default 88 cols |
Runs in
0.04s
on my computer.The Ruff format is designed to be a drop-in replacement for black. As you see, most of the diff is adding a new line at the start of every class, which seems like a good change. I'll comment on the config files with changes for easier reviewing.
Note stacked PR.