fonttools icon indicating copy to clipboard operation
fonttools copied to clipboard

[varLib.interpolatable] minimum_spanning_tree is doing something bad

Open simoncozens opened this issue 6 months ago • 6 comments

When varLib.interpolatable is run on the attached font, it finds a kink in glyph two, except when scipy.sparse.csgraph is installed.

Log prints for find_parents_and_order without scipy:

Parents: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
Order: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]

With scipy:

Parents: [None, 0, 0, 0, 0, 0, 0, np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(2), np.int32(2), np.int32(2), np.int32(2), np.int32(3), np.int32(3), np.int32(4), np.int32(4), np.int32(7), np.int32(7), np.int32(7), np.int32(7), np.int32(8), np.int32(8), np.int32(9), np.int32(9), np.int32(12), np.int32(12), np.int32(13), np.int32(13), np.int32(20), np.int32(20), np.int32(21), np.int32(21)]
Order: [0, np.int32(1), np.int32(2), np.int32(3), np.int32(4), np.int32(5), np.int32(6), np.int32(7), np.int32(8), np.int32(9), np.int32(10), np.int32(11), np.int32(12), np.int32(13), np.int32(14), np.int32(15), np.int32(16), np.int32(17), np.int32(18), np.int32(19), np.int32(20), np.int32(21), np.int32(22), np.int32(23), np.int32(24), np.int32(25), np.int32(26), np.int32(27), np.int32(28), np.int32(29), np.int32(30), np.int32(31), np.int32(32), np.int32(33), np.int32(34), np.int32(35)]

Additionally these values are not JSON-serializable so --json doesn't work when scipy is installed.

simoncozens avatar Jun 23 '25 08:06 simoncozens

(The kink is correct, so we want to find it; but with scipy installed there are a bunch of underweight false positives.)

simoncozens avatar Jun 23 '25 08:06 simoncozens

Parents: [None, 0, 0, 0, 0, 0, 0, np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(2), np.int32(2), np.int32(2), np.int32(2), np.int32(3), np.int32(3), np.int32(4), np.int32(4), np.int32(7), np.int32(7), np.int32(7), np.int32(7), np.int32(8), np.int32(8), np.int32(9), np.int32(9), np.int32(12), np.int32(12), np.int32(13), np.int32(13), np.int32(20), np.int32(20), np.int32(21), np.int32(21)]

Thanks. I can reproduce the 0s, but not the np.int32 part.

behdad avatar Jun 27 '25 20:06 behdad

Parents: [None, 0, 0, 0, 0, 0, 0, np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(1), np.int32(2), np.int32(2), np.int32(2), np.int32(2), np.int32(3), np.int32(3), np.int32(4), np.int32(4), np.int32(7), np.int32(7), np.int32(7), np.int32(7), np.int32(8), np.int32(8), np.int32(9), np.int32(9), np.int32(12), np.int32(12), np.int32(13), np.int32(13), np.int32(20), np.int32(20), np.int32(21), np.int32(21)]

Thanks. I can reproduce the 0s, but not the np.int32 part.

Wasn't that part fixed by https://github.com/fonttools/fonttools/commit/a531041f3e1c6ae195485bbace3750630646633a

behdad avatar Jun 27 '25 20:06 behdad

minimum_spanning_tree is not even called when scipy is installed for me.

behdad avatar Jun 28 '25 00:06 behdad

Sorry, my bad. Ignore me for now.

behdad avatar Jun 28 '25 00:06 behdad

Can you do some debugging? The different parent order is expected. But that the kink disappears is unfortunate. But for now, the numpy issue is baffling me.

behdad avatar Jun 28 '25 00:06 behdad