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

[iup] Fix mismatch in behaviour with fonttools #663

Merged
merged 1 commit into from
Oct 17, 2023
Merged

[iup] Fix mismatch in behaviour with fonttools #663

merged 1 commit into from
Oct 17, 2023

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Oct 17, 2023

This patch fixes an issue with iup not resolving, although I do not fully understand the problem.

Basically: in comparing our implementation with the one in fonttools, there is clear divergence in some of the numerical code, where we are using Option in places where python is just using an integer. More importantly, we are using None where Python is using -1, but our comparison code is never checking if a value == None, whereas python does check if a value == -1, which means that python is setting the solution in cases where we are not.

This can be fixed by using checked_sub instead of saturating_sub, at least for this input.

It feels like this is probably fine, since the structure of this loop is such that the only negative value that is possible is -1 (at the start) but it feels a little loose.


let contour_ends = vec![17];

iup_delta_optimize(deltas, coords, 0.5, &contour_ends).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

can the test be further simplified? Do we need the entire outline to reproduce the problem?

(my intuition is it should simplify)

This patch fixes an issue with iup not resolving, although I do not
fully understand the problem.

Basically: in comparing our implementation with the one in fonttools,
there is clear divergence in some of the numerical code, where we are
using Option<usize> in places where python is just using an integer.
More importantly, we are using None where Python is using -1, but our
comparison code is never checking if a value == None, whereas python
*does* check if a value == -1, which means that python is setting the
solution in cases where we are not.

This can be fixed by using `checked_sub` instead of `saturating_sub`, at
least for this input.

It feels like this is probably fine, since the structure of this loop is
such that the only negative value that is possible is -1 (at the start)
but it feels a little loose.
@cmyr cmyr merged commit 4f6c4db into main Oct 17, 2023
8 checks passed
@cmyr cmyr deleted the bug-662 branch October 17, 2023 17:19
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.

IUP failing on certain inputs
2 participants