meta-pytorch / meta-pytorch/data
`.fork(n)` returns original datapipe for `n==1` instead of singleton list
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
pipe.fork(n) returns the original pipe when n == 1 and not a list with 1 element. This introduces two issues:
- It's unexpected to the user
- It requires the user to add extra code to handle this edgecase if the number of forks is dynamically determined during runtime
For instance, consider the following two snippets that will fail if n==1:
pipes = IterableWrapper(self.years).fork(n_vars)
for pipe in pipes:
process_pipe(pipe)
=> iterates over elements of the original pipe and not over the actual pipes.
pipes = IterableWrapper(self.years).fork(n_vars)
for idx in range(n_vars):
process_pipe(pipes[idx])
=> Will raise an NotImplementedError from Dataset.__getitem__().
To handle this case, the user needs to add extra code specifically for n==1.
Versions
nightly / latest
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of IterableWrapper.fork and the Dataset behavior referenced in the examples. Reproduce the n==1 case and compare it with other fork counts; done means the return shape is consistent for one fork, with regression coverage for both iteration and indexing usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100