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

CI: use ruff to format xdsl #3023

Merged
merged 6 commits into from
Aug 13, 2024
Merged

CI: use ruff to format xdsl #3023

merged 6 commits into from
Aug 13, 2024

Conversation

superlopuh
Copy link
Member

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.

@superlopuh superlopuh added the CI Continuous Integration label Aug 13, 2024
@superlopuh superlopuh self-assigned this Aug 13, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Member Author

@superlopuh superlopuh Aug 13, 2024

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
Copy link
Member Author

@superlopuh superlopuh Aug 13, 2024

Choose a reason for hiding this comment

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

Config change 2/2

Copy link

codecov bot commented Aug 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.85%. Comparing base (ee90d21) to head (ad4c35f).

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.
📢 Have feedback on the report? Share it here.

Comment on lines -2 to +32
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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

Copy link
Collaborator

@PapyChacal PapyChacal left a 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:

Base automatically changed from sasha/ruff/line-length to main August 13, 2024 12:36
@superlopuh
Copy link
Member Author

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

@superlopuh superlopuh merged commit 6d27775 into main Aug 13, 2024
9 checks passed
@superlopuh superlopuh deleted the sasha/ruff/format branch August 13, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants