Polygraphy: rename the shadowed is_on_gpu test so is_on_cpu is actually tested - #4847
Open
Anai-Guo wants to merge 1 commit into
Open
Polygraphy: rename the shadowed is_on_gpu test so is_on_cpu is actually tested#4847Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
tests/util/test_array.py defines test_is_on_cpu twice. The second definition (which asserts util.array.is_on_gpu) rebinds the name, so pytest only ever collects the GPU parametrization and util.array.is_on_cpu has no coverage at all. Signed-off-by: Anai Guo <antai12232931@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
tools/Polygraphy/tests/util/test_array.pydefinestest_is_on_cputwice:The second
defrebinds the module-level name, so the first function object isdiscarded before pytest ever sees it. The result is that
util.array.is_on_cpuhas no test coverage at all — the four cases that pytest does collect under the
name
test_is_on_cpuare in fact theis_on_gpucases.From the body and the parametrize ids it is clear the second one was meant to be
test_is_on_gpu(it assertsutil.array.is_on_gpu, and its expectations are theexact inverse of the first block's).
Reproduction
Minimal standalone reduction of the same two-
defstructure, before and afterthis change:
Note the ids in the "before" run: the surviving
test_is_on_cpucarries theis_on_gpuexpectations (np-False), confirming the CPU test is gone.Fix
Rename the second definition to
test_is_on_gpu. One line, no behaviouralchange to Polygraphy itself; it restores the four
is_on_cpucases(4 collected → 8 collected in this file).
🤖 Generated with Claude Code