meta-pytorch / meta-pytorch/data

KeyError when wrapping a dict with a SequenceWrapper

Open
#795 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.3k
Forks
179
Avg merge
6d 1h
Merged PRs (30d)
2

Description

🐛 Describe the bug

I get the following errors.

from torchdata.datapipes.map import SequenceWrapper

tuple(SequenceWrapper({'a': 100, 'b': 200, 'c': 300, 'd': 400}))  # produces KeyError: 0
tuple(SequenceWrapper({0: "100", 1: "200"}))  # produces KeyError: 2

I expect them to return (100, 200, 300, 400) and ("100", "200"), respectively, instead.

Versions

torchdata 0.4.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the torchdata.datapipes.map.SequenceWrapper entry point and reproduce both dictionary examples from the issue. Check how iteration handles mappings versus sequences, then verify that both examples yield their values in the expected order and no KeyError occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.