-
Notifications
You must be signed in to change notification settings - Fork 238
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
fix: More intuitive min_bound_range behavior #1136
base: master
Are you sure you want to change the base?
Conversation
Thanks a lot! I had a look at the code, and I think it looks good. 👍 Did you think about how soft bounds should best be handled? They're kind of in between I'll wait for @ildar170975's opinion, too, before merging.
I would actually say, you're proposing a |
Thinking about the soft bounds... The if-then-else will become huge. Maybe something like this might work? (I haven't tested it at all!) const weights = [
min !== undefined && min[0] != '~' ? 0 : 1,
max !== undefined && max[0] != '~' ? 0 : 1,
];
const sum = weights[0] + weights[1];
if (sum > 0) {
boundary = [
boundary[0] + diff * weights[0] / sum,
boundary[1] + diff * weights[1] / sum,
];
} else {
boundary = [
boundary[0] + diff / 2,
boundary[1] + diff / 2,
];
} |
@akloeckner |
@akloeckner I'll test your code and edit this comment when I do! I see it always treats soft bounds as "not a bound", is this the behavior we want it to have? |
To be agreed. I'd say, soft bounds are bound (😄) to be broken. So, they can also be extended by the minimum range. Whereas fixed bounds should stay fixed as long as possible. But you're right. Maybe one soft bound plus one free bound: the soft bound should stay and the free one should be extended? So, my code is not optimal either. Sorry, if I'm over complicating... |
That's what I was thinking, but maybe that's feature creep - your code looks good honestly (it just needed a !== instead of the != to avoid lint errors, and switching two + for -). I haven't really tested it yet as I was away, but it's compiled ready on my pc :) EDIT: tested, and it works well! If I have time today I'll try to adapt the soft bound behavior, but no promises :D tested working code:
|
I thought about it for a bit, and came up with this:
Now if it's defined but a soft bound, and there is no other bound defined, it treats it as a bound. If both are soft bounds then it doesn't care, and if the other bound is a hard bound, the soft one is breached. Tested it on my machine and it works great :) I'll add this to the PR, let's see if we want to treat the soft bounds like this. EDIT: now that I think of it, we could also remove the second"is it defined" check:
as if both boundaries are undefined, they both have a weight of 0 and it uses the old behavior as intended. |
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.
Thanks for looking into it!
Yes, it might be a bit looking too closely. On the other hand, I think, if we touch it, let's think it to the end.
Let's also still wait for @ildar170975's feedback. But for me it's a GO, now.
Co-authored-by: akloeckner <[email protected]>
@akloeckner tested that too, great! now it's more elegant. |
This is a quick and simple change to the behavior of the min_bound_range option, to make it more intuitive to use and more predictable to new users.
Old behavior: it ignores every other bound option and overrides it
New behavior: If lower bound is set, it increases the range "upwards". If upper bound is set, it increases the range "downwards".
If no bound is set, or if both upper AND lower bounds are set, old behavior is used.
This was mentioned in #1047, not an essential groundbreaking feature but it was a simple enough fix that I gave it a try. Tested on my machine.
This is my second ever PR so go easy on me please :)
Did I use the correct semantic title?