Skip to content

varLib.interpolatable: normalize SciPy master indices - #4276

Merged
behdad merged 1 commit into
fonttools:mainfrom
CAOShurong:codex/3870-scipy-json-master-indices
Oct 10, 2026
Merged

behdad merged 1 commit into
fonttools:mainfrom
CAOShurong:codex/3870-scipy-json-master-indices

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

SciPy's minimum_spanning_tree returns NumPy row/column indices. These enter
the master graph and reach diagnostic master_1_idx/master_2_idx values,
causing --json to raise TypeError: Object of type int32 is not JSON serializable.

Convert the indices to Python int at graph insertion, following the
SciPy-boundary conversion used for assignment results in #3526. Regression
coverage checks multi-hop, reordered-base, branched and discrete-axis graphs,
plus JSON output from the existing CFF2 variable-font fixture.

This addresses the JSON serialization part of #3870 only. It does not change
the spanning-tree topology or the kink/underweight comparison behavior.

Validation with non-editable wheels on Windows:

  • python -m pytest Tests fontTools: twice, 5415 passed, 13 skipped,
    2 xfailed on Python 3.13.1 with SciPy 1.16.3. Against the unmodified runtime,
    the same suite has 5 new regression failures; all other outcomes match.
  • python -m pytest Tests/varLib/interpolatable_test.py: 19 passed, 1 skipped;
    repeated. The six new cases also pass twice on Python 3.11.16 with SciPy.
  • Actual module and fonttools varLib.interpolatable commands: compatible and
    incompatible designspaces, CFF2 variable fonts, JSON stdout/file output,
    direct UFO input and invalid-input paths. No-SciPy fallback checked separately.
  • Source/wheel/sdist/install contents checked; build, twine check,
    pip check, Black and git diff --check pass.

Rendering, native/Cython builds, other operating systems and the full Python
3.11 suite were not tested. Black's notebook checks were skipped without Jupyter
dependencies; configured mypy checks only plistlib, not this changed module.

@behdad
behdad merged commit feb41a8 into fonttools:main Oct 10, 2026
13 checks passed
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.

2 participants