Skip to content

Preserve list semantics when slicing spatial inertia sequences - #312

Open
kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-spatial-inertia-slices-nov18
Open

kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-spatial-inertia-slices-nov18

Conversation

@kaushikgunasekaren

Copy link
Copy Markdown

Bug

SpatialInertia inherits the documented list interface from BasePoseList, but its indexing method passes a slice's list of matrices into the singleton-only constructor. Every slice raises ValueError, including inertia[:1], inertia[::-1] and empty slices.

Change

For a slice, create an empty SpatialInertia and store the sliced matrix list. This keeps Python list slice ordering, steps and bounds, and avoids routing a list through the singleton constructor. Integer indexing is unchanged. Like a Python list slice, the new container has independent list storage, not deep-copied matrices.

Validation

  • 32 regression/control cases: 31 fail before the fix; all 32 pass after it.
  • Covers zero, one, three and six-element sequences; full, singleton, empty, reverse, stepped, negative-bound and out-of-range slices; appending without changing the original; integer indexing; velocity/acceleration dynamics; and invalid indices/zero slice steps.
  • Full local suite: 598 passed, 3 skipped, 99 subtests passed (21 warnings), versus 566 passed on the unchanged base.
  • Black 23.10.0 and fatal flake8 checks pass for changed files. Full-repository fatal lint has two pre-existing undefined-name findings in tests/test_dualquaternion.py.

AI assistance was used for investigation, implementation and tests. Validation is local Python testing only; no hardware validation is claimed.

Retain Python list slicing while keeping integer construction unchanged.
Cover empty, singleton and longer sequences, reversed and stepped slices, independent list storage, integer indexing and dynamics.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant