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
revised/new patch for improve ratio calculation #4626
base: master
Are you sure you want to change the base?
revised/new patch for improve ratio calculation #4626
Conversation
For the failing test_ratiotile.py test, |
Just keep adding commits to your branch. |
I got the data out and generated some side by side pictures which are only 5k each. |
This was the initial description for a pull request that did not work. But here it is suitable to explain the reasoning behind it. I added a RatioTile(ratio=1) object in my config and noticed that the layout favoured 3 upright elongated windows on a screen that is 1.125 higher than wide. So they are really really slim, 1.125 tall and 0.333 wide. The ratio is 1.125/(1/3)=3.375 But I expected them to be 3 wide "landscape" windows because that would be 1.125/3 tall and 1 wide, which is a better ratio because if you see the ratio as longer_edge_of_window/shorter_edge_of_window then it is 1/(1.125/3)= 2.666 This patch can fulfill the described wish, while keeping overall expected "ratioTile" behaviour. With this patch a GOLDEN_RATIO=1 tries to make the windows "square". If a slightly more landscape tendency is preferred, a default GOLDEN_RATIO of 1.2 probably would work.
d584b12
to
3d38991
Compare
I rebased and force pushed it to clean it up. |
The changed ratio calculation changes the behaviour. This commit modifies the add window test. A sequence of images that draws the window layout that will be visible on the screen with the changed ratio calculation, compared to the layout that is visible without it, is uploaded on github. I extracted the data for the images with a modified version of this test run by writing the "layout_info" in a file together with the expected "layout_info". This test change is probably less worrying than the other one which changes the resizing test.
The changed ratio calculation changes the behaviour. This commit modifies the "test_resizing" test. A sequence of images that draws the window layout that will be visible on the screen with the changed ratio calculation, compared to the layout that is visible without it, is uploaded on github. I extracted the data for the images with a modified version of this test by writing the "layout_info" in a file together with the expected "layout_info". I made this test a bit more extensive than the original one.
3d38991
to
9bd4bdb
Compare
This here is everything summarized and more organized. For the "add_windows" test:branch that made the pictures for the "add_windows" test side-by-side pictures for the "add_windows" testFor the resizing test:branch that made the pictures for the resizing test pictures for the "resizing" test |
Can you explain, in as few words as possible, what the issue is, what your PR does and what the images above show? I'm finding this quite hard to follow but I appreciate you've put a lot of effort in here. |
The issue is, the layout calculation does not make the windows as close to the desired ratio as possible. The issue in detail:If the desired ratio=1 and there are 3 windows on a screen that is 1.125 higher than wide, I know that this is not the most important issue and it requires some time to supervise something like this. |
This PR is stale because it has been open 90 days with no activity. Remove the |
Here is the description about why a change can be considered:
description right at the beginning of this closed pull request
Now, I tested a function that actually works and made screenshots.
It works with upright and landscape ratios and
also with my "ratio-1.0-square" use case.
Ratios > 1 are "landscape" and ratios < 1 are "upright".
It works like this:
the code from below more readable
`
def is_more_golden_than( a, b , gs=1):
goldstandard = gs
ao=a
bo=b
# TODO: use math to refactor the next 6 lines
a = a / goldstandard
b = b / goldstandard
wa = a if a < 1 else -1/a
wb = b if b < 1 else -1/b
wa = abs(abs(wa)-1)
wb = abs(abs(wb)-1)
judgement = True if wa < wb else False
print(f'{ao:>5.3} vs {bo:<5.3} > {wa:+.3f}, {wb:+.3f} golden = {gs:0.2f} {judgement}' )
return judgement
is_more_golden_than(1.5 , 0.66666 , gs=1 )
is_more_golden_than(2.0 , 2.1 , gs=2 )
is_more_golden_than(1.9 , 2.0 , gs=2 )
is_more_golden_than(1.9 , 2.1 , gs=2 )
is_more_golden_than(0.25, 0.75 , gs=0.5)
output:
1.5 vs 0.667 > +0.333, +0.333 golden = 1.00 True
2.0 vs 2.1 > +0.000, +0.048 golden = 2.00 True
1.9 vs 2.0 > +0.050, +0.000 golden = 2.00 False
1.9 vs 2.1 > +0.050, +0.048 golden = 2.00 False
0.25 vs 0.75 > +0.500, +0.333 golden = 0.50 False
`
update here: pictures removed, newer pictures below