Skip to content

dataloader: use positional iloc indexing in __getitem__#11

Closed
SAY-5 wants to merge 1 commit into
ratschlab:mainfrom
SAY-5:fix/issue-7-getitem-iloc
Closed

dataloader: use positional iloc indexing in __getitem__#11
SAY-5 wants to merge 1 commit into
ratschlab:mainfrom
SAY-5:fix/issue-7-getitem-iloc

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 5, 2026

Fixes #7.

CustomDataset.__getitem__ reads cluster labels via Series[idx] where idx is a positional integer from the DataLoader. With non-default obs indexes (string barcodes, or shuffled integers from train_test_split when train_size is set), pandas falls back to label-based lookup, which emits FutureWarning today and raises KeyError on pandas >= 3.0. Switched to .iloc[idx] for positional access and added a regression test that runs without FutureWarning and exercises the broken path.

Fixes ratschlab#7. Series.__getitem__ on a non-default obs_names index falls back
to label-based lookup, which emits FutureWarning today and raises
KeyError on pandas >= 3.0.

Signed-off-by: SAY-5 <saiasish.cnp@gmail.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.

__getitem__ uses label-based pandas indexing instead of positional — KeyError with string obs_names

2 participants