Skip to content

Fix: make __getitem__ delegate to states array#53

Open
ftavella wants to merge 1 commit into
Arcascope:mainfrom
ftavella:fix/issue-19
Open

Fix: make __getitem__ delegate to states array#53
ftavella wants to merge 1 commit into
Arcascope:mainfrom
ftavella:fix/issue-19

Conversation

@ftavella
Copy link
Copy Markdown
Member

Summary

Fixes #19

Replaces the old __getitem__ that returned (time, state) tuples with direct indexing into trajectory.states. The new implementation supports the full numpy indexing syntax:

trajectory[0]          # all states at time index 0
trajectory[0, 1]       # state 1 at time index 0
trajectory[0, 1, 2]    # state 1, batch 2 at time index 0
trajectory[:10]        # first 10 time points, all states

Changes

  • __getitem__ on DynamicalTrajectory now delegates directly to self.states[idx]

Tests

Updated test_models.ipynb to replace old tuple-based assertions with tests covering single indexing, multi-dimensional indexing, slicing, and batch indexing.

Replace the old __getitem__ that returned (time, state) tuples with
direct indexing into trajectory.states. This supports the full numpy
indexing syntax: trajectory[t], trajectory[t, s], trajectory[t, s, b],
trajectory[:10], etc.

Also fix pkg_resources import in setup.py for setuptools >= 82.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Unintuitive __getitem__ behavior

1 participant