Repository navigation
warp: make the curve fit independent of the CPU (fixes the flaky fonts-are-current check) #21
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -668,3 +668,31 @@ def test_build_is_deterministic(): | |
| assert [[(p.x, p.y, p.segmentType) for p in c] for c in ga.contours] == \ | ||
| [[(p.x, p.y, p.segmentType) for p in c] for c in gb.contours] | ||
| assert a.kerning == b.kerning and a.features.text == b.features.text | ||
|
|
||
|
|
||
| def test_curve_fit_does_not_depend_on_cpu_features(): | ||
| """NumPy uses other code (AVX-512) for some functions on some CPUs. The | ||
| fitted outlines, and so the fonts, must not change with it: the CI | ||
| machines differ, and the committed fonts are checked against a fresh build.""" | ||
| import subprocess | ||
| import sys | ||
| code = ( | ||
| "import numpy as np\n" | ||
| "from loom import outline as O\n" | ||
| "t = np.random.default_rng(3).random(4000)\n" | ||
| "ctrl = np.array([[0, 0], [37.3, 211.9], [402.1, 98.7], [455.5, 12.4]])\n" | ||
| "pts = O._bez(ctrl, np.linspace(0, 1, 60))\n" | ||
| "u = O._chord_params(pts)\n" | ||
| "fit = O._generate(pts, u, O._unit(ctrl[1] - ctrl[0]), O._unit(ctrl[2] - ctrl[3]))\n" | ||
| "print(O._bez(ctrl, t).tobytes().hex(), fit.tobytes().hex())\n" | ||
| ) | ||
|
|
||
| def run(disable): | ||
| env = {k: v for k, v in __import__("os").environ.items() if k != "NPY_DISABLE_CPU_FEATURES"} | ||
| if disable: | ||
| env["NPY_DISABLE_CPU_FEATURES"] = disable | ||
| r = subprocess.run([sys.executable, "-c", code], cwd=WARP, env=env, capture_output=True, text=True) | ||
| assert r.returncode == 0, r.stderr | ||
| return r.stdout | ||
|
|
||
| assert run("") == run("X86_V4 AVX512_ICL AVX512_SKX AVX512F") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use dispatch names supported by NumPy 2.5.4.
|
||
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.
Script executed:
Repository: machine-made/type
Length of output: 3038
Script executed:
Repository: machine-made/type
Length of output: 2450
Web query:
NumPy 2.5.4 NPY_ENABLE_CPU_FEATURES NPY_DISABLE_CPU_FEATURES cannot both be set npy_cpu_features.cResult:
Clear both NumPy CPU-feature variables before each subprocess run.
If the parent environment contains a non-empty
NPY_ENABLE_CPU_FEATURES, the disabled-feature subprocess inherits it and also setsNPY_DISABLE_CPU_FEATURES. NumPy 2.5.4 rejects both variables during import.Suggested fix
Committable suggestion