swizzle_search, tex_mode_probe: say numpy is missing in one line, as tile_probe does #949
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/949"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by barkodr on 2026-11-24T15:37:05Z.
Claimed in the coordination issue as: claiming: tools/bc_feature.py, calibrated_texture.py, tex_mode_probe.py and swizzle_search.py import numpy unconditionally and never say they need it; give them the one-line "numpy is missing" message tools/tile_probe.py uses. Tools only. AI-assisted.
What and why
Without numpy,
tools/swizzle_search.pyandtools/tex_mode_probe.pystopped with a traceback. They now check their arguments first and then print oneERROR: ... needs numpy (python -m pip install numpy)line and exit 2, astools/tile_probe.pydoes.tools/bc_feature.pyandtools/calibrated_texture.pyare left as they are: they are modules with no command line of their own.tex_mode_probe.pynow importsbc_featureonly when numpy is present, andttpf_mips.pyandttpf_assets.pyalready catch theImportErrorfromcalibrated_textureand say what is missing.Tested
On macOS 26.6.2 with Python 3.12.16 (no numpy installed) and on Ubuntu 26.04 (WSL2) with Python 3.14.4, from the checkout root with
python -I:tests/test_swizzle_search.py,tests/test_tex_mode_probe.py,tests/test_text_write_line_endings.pyandtests/test_docs_python_deps.pypass on both. On macOS both tools print the one line and exit 2. With numpy 2.5.5 installed, the four new tests (which hide numpy from a child process) pass, and they fail against the tools onmain. Without numpy,tests/test_tex_mode_probe.pyskips the whole module insetUpModule, so its two new tests only run where numpy is installed.GPUs tested: none (no GPU code changed)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T21:50:02Z.
Reviewed
e61aadd: I ran test_swizzle_search.py (30 OK) and test_tex_mode_probe.py (39 OK) on the PR tree, both on origin/main (28/37 OK), and the PR's test files copied onto main - the four new without-numpy tests fail there and pass here, so they exercise the fix. Also compileall, check_no_game_data, and a direct A/B probe: with numpy simulated missing, main gives an ImportError traceback (rc 1) even for bad arguments, while the PR tools give argument errors and the one-line "needs numpy" (rc 2), matching tile_probe; with numpy present the output is byte-identical to main. Nits for a follow-up: the now-stale comment at tests/test_swizzle_search.py:430, and the...Test-suffixed new classes a plain pytest run would skip (they run underpython -I). AI-assisted review.Recommendation: Merge
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:00:43Z.
Native Windows 11 Verification (
e61aadda9f)Verified
e61aadda9f79c0d594ec289aafdfd108ccae4ca4merged cleanly ontoorigin/main(c7753ed98a56677f10e34078b37eab0540e190ec,git merge-tree --write-treerc=0) on native Windows 11 (26200) across both standard-library-only Python (3.12.10) andnumpy 1.26.4Python:origin/mainc7753ed98a):SwizzleSearchWithoutNumpyTest(FAILED (errors=1)) andTexModeProbeWithoutNumpyTest(FAILED (failures=2)) failed withrc=1and aModuleNotFoundError: No module named 'numpy'traceback before CLI argument validation.origin/main + e61aadda9f):tests/test_swizzle_search.py: passed under both stdlib-only Python andnumpy 1.26.4(rc=0, single-lineERROR: swizzle_search.py needs numpy (python -m pip install numpy)withrc=2whennumpyis absent, and usage errors reported before checkingnumpy).tests/test_tex_mode_probe.py:39/39 OKundernumpy 1.26.4(TexModeProbeWithoutNumpyTestconfirmedrc=2and single-lineERROR: tex_mode_probe.py needs numpy (python -m pip install numpy)).tests/test_tex_mode_probe.py, module-levelsetUpModule()(line 43) andpytestmark(line 36) skip the entire test module when the outer test runner itself lacksnumpy(python -I tests/test_tex_mode_probe.pyunder stdlib-only Python printsRan 0 tests in 0.000s / OK (skipped=1)), soTexModeProbeWithoutNumpyTestis skipped in CI's stdlib-only job unless the skip decorator is scoped to thenumpy-requiring test class/functions (astests/test_swizzle_search.pydoes).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:31:25Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
53b77df14: red 4 failures (SwizzleSearchWithoutNumpyTest.test_missing_file_is_a_usage_error_without_numpy,SwizzleSearchWithoutNumpyTest.test_missing_numpy_is_one_error_line,TexModeProbeWithoutNumpyTest::test_missing_numpy_is_one_error_line,TexModeProbeWithoutNumpyTest::test_unreadable_index_is_a_usage_error_without_numpy) / green 30 OK + 52 passed.e61aadda9.tests/test_swizzle_search.pyrun with unittest (python -I tests/test_swizzle_search.py) using a venv python with numpy/Pillow;tests/test_tex_mode_probe.pyrun withpython -m pytestin a venv built fromtests/requirements.txt(pytest 9.2.0, numpy 2.5.5, Pillow 13.0.0). Both from the repository root.test_swizzle_search.py30 run, 2 failures, 0 skips;test_tex_mode_probe.py2 failed / 50 passed. All four fail withAssertionError: 1 != 2: the tool dies with a traceback (ModuleNotFoundError: import of numpy halted) instead of exiting 2. MEASURED, failing test(s) alone 3 runs, 3/3 fail.git merge --no-ffof this PR, no conflict):test_swizzle_search.py30 run, OK, 0 skips;test_tex_mode_probe.py52 passed. MEASURED, the same test(s) alone 3/3 pass.Red = main + only the test files from this PR (
git checkout pr-949 -- tests/test_swizzle_search.py tests/test_tex_mode_probe.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.AI-assisted: Claude Code (Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T01:35:39Z.
Merged after OreoFR's red/green check (check) (macOS 27.2.1, Apple M5, Python 3.12) and a local re-check here. Merged after local re-verification: this PR merged onto
maind8c10dd5ewithout conflict, and its test file(s) (tests/test_swizzle_search.py,tests/test_tex_mode_probe.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.