dwavesystems / dwavesystems/dimod

to_numpy_matrix example fails

Open
#801 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
143
Forks
91
Avg merge
1h 24m
Merged PRs (30d)
3

Description

**Description**

The example given at https://docs.ocean.dwavesys.com/projects/dimod/en/stable/reference/bqm/generated/dimod.BinaryQuadraticModel.to_numpy_matrix.html fails to run.

**Steps To Reproduce**

Simply enter the code from the `to_numpy_matrix` example:

```
$ python
Python 3.8.3 (default, Jul 2 2020, 16:21:59)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dimod
>>> import numpy as np
>>> model = dimod.BinaryQuadraticModel({'a': 1, 'b': -1, 'c': .5},
... {('a', 'b'): .5, ('b', 'c'): 1.5},
... 1.4,
... dimod.BINARY)
>>> model.to_numpy_matrix(variable_order=['d', 'c', 'b', 'a'])
Traceback (most recent call last):
File "", line 1, in
File "/home/pakin/.anaconda3/lib/python3.8/site-packages/dimod/core/bqm.py", line 1073, in to_numpy_matrix
raise ValueError("variable_order does not include all variables")
ValueError: variable_order does not include all variables
```

**Expected Behavior**

I expected to see

```
array([[ 0. , 0. , 0. , 0. ],
[ 0. , 0.5, 1.5, 0. ],
[ 0. , 0. , -1. , 0.5],
[ 0. , 0. , 0. , 1. ]])
```

**Environment**
- OS: Ubuntu 20.10
- Python version: 3.8.3
- dimod version: 0.9.13

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.