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

Layout Resolver enhancement #295

Merged
merged 17 commits into from
Feb 21, 2022
Merged

Layout Resolver enhancement #295

merged 17 commits into from
Feb 21, 2022

Conversation

willmcgugan
Copy link
Collaborator

I can see layout_resolve becoming fairly critical, since it solves a common class of problem we will no doubt see a lot. I've optimized it a little, and added tests.

@@ -72,9 +76,8 @@ def layout_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
# to the following line
remainder = _Fraction(0)
for index, edge in flexible_edges:
size, remainder = divmod(portion * edge.fraction + remainder, 1)
sizes[index] = size
sizes[index], remainder = divmod(portion * edge.fraction + remainder, 1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like how this loop turned out..

Copy link
Member

Choose a reason for hiding this comment

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

Me too :)

@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2022

Codecov Report

Merging #295 (61dc149) into css (386aa6d) will increase coverage by 2.09%.
The diff coverage is 58.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##              css     #295      +/-   ##
==========================================
+ Coverage   38.06%   40.15%   +2.09%     
==========================================
  Files          85       88       +3     
  Lines        6526     6806     +280     
==========================================
+ Hits         2484     2733     +249     
- Misses       4042     4073      +31     
Flag Coverage Δ
unittests 40.15% <58.57%> (+2.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/textual/_animator.py 40.56% <0.00%> (-1.19%) ⬇️
src/textual/app.py 0.00% <0.00%> (ø)
src/textual/css/scalar_animation.py 27.02% <0.00%> (ø)
src/textual/css/tokenizer.py 89.01% <ø> (-0.12%) ⬇️
src/textual/layout.py 29.78% <0.00%> (-0.13%) ⬇️
src/textual/layout_map.py 41.86% <0.00%> (ø)
src/textual/views/_window_view.py 0.00% <ø> (ø)
src/textual/widgets/_scroll_view.py 0.00% <ø> (ø)
src/textual/message_pump.py 31.36% <20.00%> (-0.27%) ⬇️
src/textual/widget.py 50.72% <23.07%> (+<0.01%) ⬆️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c7c7ac...61dc149. Read the comment docs.

src/textual/_layout_resolve.py Outdated Show resolved Hide resolved
src/textual/_layout_resolve.py Show resolved Hide resolved
@@ -72,9 +76,8 @@ def layout_resolve(total: int, edges: Sequence[Edge]) -> List[int]:
# to the following line
remainder = _Fraction(0)
for index, edge in flexible_edges:
size, remainder = divmod(portion * edge.fraction + remainder, 1)
sizes[index] = size
sizes[index], remainder = divmod(portion * edge.fraction + remainder, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Me too :)

@willmcgugan willmcgugan merged commit ab0c43b into css Feb 21, 2022
@willmcgugan willmcgugan deleted the resolve branch February 21, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants