dwavesystems / dwavesystems/dwave-hybrid
Support non-bijective mapping with Map
- Dominant language
- Python
- Stars
- 90
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
`Map` can easily be generalized to support non-bijective mapping, at least in surjective sense (dropping some outputs).
The same can be achieved with `map | filter` flow, but sometimes non-emitting the output can be done more easily.
Usage example:
```
class IncOdd(Runnable):
def next(self, state):
if state.number % 2:
return state.updated(number=state.number + 1)
inp = States(*(State(number=i) for i in range(5)))
out = Map(IncOdd()).run(inp).result()
exp = States(State(number=1), State(number=3))
assert out == exp
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the Map entry point and its existing behavior for Runnable results. Use the IncOdd example as the expected case: outputs may be omitted when next returns no state, while emitted states remain in order. Done means Map.run produces States(1, 3) for the provided input and existing behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100