dwavesystems / dwavesystems/dimod

add_discrete using dimod.Binary raises error

Open
#921 5 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.