Repository navigation
Set seed for string testing - #5709
Conversation
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
This PR fixes a test flakiness issue in test_resolve_matching_names_with_joint_name_strings by seeding the random number generator used for shuffling.
Analysis
Problem Being Solved:
The test uses random.shuffle() to randomize a list of 6 joint names before passing them to resolve_matching_names(). With 6 elements, there's a 1/720 (~0.14%) probability that the shuffle produces the exact same order as the original list, causing the assertion names_list != query_list to fail spuriously.
The Fix:
- Creates a local
random.Random(0)instance with a fixed seed - Uses the seeded RNG for shuffling instead of global
random.shuffle()
Review Notes
✅ Correctness: The fix is appropriate. Using a seeded local RNG ensures deterministic test behavior while still exercising the "shuffled input" code path.
✅ Best Practice: Creating a local Random instance rather than calling random.seed(0) globally is the right approach—it avoids polluting the global RNG state that other tests might depend on.
✅ Test Coverage: The test continues to validate that resolve_matching_names() correctly handles inputs in arbitrary order and returns results in target ordering (not query ordering).
✅ Changelog: The .skip changelog fragment appropriately marks this as a test-only change that won't appear in user-facing release notes.
Minor Observation
The seed value 0 will produce a consistent shuffle, but it's worth verifying that this particular shuffle does result in a different order than the original query_list. Given the implementation, seed 0 should produce a valid permutation—the probability of still landing on identity is negligible with a good PRNG.
Verdict
Clean, minimal fix for a real (if rare) test flakiness issue. No concerns.
Automated review by Isaac Lab Review Bot
Greptile SummaryThis PR fixes a low-probability (~1/720) flaky test caused by
Confidence Score: 5/5Safe to merge — the change is test-only, eliminates a real flakiness, and introduces no production code modifications. Both changed files are test infrastructure. The two-line edit swaps a non-deterministic shuffle for a seeded one, directly fixing the documented flakiness without altering production behavior. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant T as Test
participant RNG as random.Random(seed=0)
participant F as resolve_matching_names()
T->>RNG: shuffle(query_list)
Note over RNG: Deterministic permutation<br/>— never equals names_list
RNG-->>T: query_list (shuffled, fixed order)
T->>F: resolve_matching_names(query_list, robot_joint_names)
F-->>T: (index_list, names_list) sorted by robot_joint_names
T->>T: "assert names_list != query_list ✓"
T->>T: "assert index_list == [0,1,4,5,8,9] ✓"
T->>T: "assert names_list == expected ✓"
Reviews (1): Last reviewed commit: "Set seed for string testing" | Re-trigger Greptile |
Description
Following test can occasionally fail when we get very unlucky when shuffled list will be the same as original.
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there