mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1861] tools/bc_feature: validate block dtype and guard smoothness mip-tail edge shapes #1871
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1871
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1861
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/bc-feature-safety📝 Commits (1)
4e6a9c4Harden bc_feature dtype checks and smoothness mip-tail handling📊 Changes
2 files changed (+61 additions, -2 deletions)
View changed files
📝
tests/test_bc_feature_validation.py(+48 -0)📝
tools/bc_feature.py(+13 -2)📄 Description
Claimed in the coordination issue as: BC-FEATURE-SMOOTHNESS-EDGE-AND-DTYPE-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163663715)
What and why
dtype == np.uint8inbc1_average()andblock_average()intools/bc_feature.pyso wider integer or floating-point arrays fail fast withValueErrorinstead of misinterpreting byte bit-patterns.img.ndim >= 2andimg.size > 0insmoothness(), reject 1D and empty inputs withValueError, guard axis differences when height or width is1(1-row, 1-col, and 1x1 mip tails) so noRuntimeWarningorNaNis produced, and cast non-floating arrays tonp.float32beforenp.diffto avoid unsigned integer underflow wraparound.tests/test_bc_feature_validation.pywith regression tests covering non-uint8block inputs, 1D/empty rejection, degenerate mip-tail warning-free finiteness, anduint8step parity withfloat32.Tested
python -I tests/test_bc_feature_validation.py -v->Ran 8 tests in 0.002s(OK);python -I tests/test_bc_feature.py -v->Ran 15 tests in 0.082s(OK).upstream/main98c2f777with updatedtests/test_bc_feature_validation.pycopied into detached worktree):Ran 8 tests in 0.016s(FAILED (failures=11)).python -I tests/test_ci_registration.py(Ran 16 tests in 4.628s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 12.538s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (numpy array validation and feature-metric unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.