dwavesystems / dwavesystems/dimod
add_discrete using dimod.Binary raises error
- Dominant language
- Python
- Stars
- 143
- Forks
- 91
- Avg merge
- 1h 24m
- Merged PRs (30d)
- 3
Description
**Application**
When adding a set of binary variables as a discrete variable, an error is raised that indicates the variable is not hashable. This is not a bug because the function expects variable labels. However, if one is using dimod.Binary or dimod.Integer to build a model, it's convenient to be able to pass a set of such variables to construct a discrete variable.
This raises error,
```
import dimod
n = 10
cqm = dimod.CQM()
x = {}
for i in range(n):
x[i] = dimod.Binary(i)
cqm.add_discrete([v for v in x.values()])
```
currently I can do:
```
import dimod
n = 10
cqm = dimod.CQM()
x = {}
for i in range(n):
x[i] = dimod.Binary(i)
cqm.add_discrete([v.variables[0] for v in x.values()])
```
to get around it.
Contributor guide
Assessment
This issue has not been assessed yet.