dwavesystems / dwavesystems/dwave-system
sample_ising may drop variables when h is a list
- Dominant language
- Python
- Stars
- 98
- Forks
- 67
- Avg merge
- 7m
- Merged PRs (30d)
- 1
Description
For example, using a structured sampler where qubit 0 is not available, the following silently drops the variable and produces an empty sampleset:
```python
DWaveSampler().sample_ising([1], {})
```
whereas using a dict for h that includes an invalid qubit (or as part of J) will raise an error:
```python
DWaveSampler().sample_ising({0: 1}, {})
```
```
BinaryQuadraticModelStructureError: Problem graph incompatible with solver.
```
Documentation for the base class method is:
https://github.com/dwavesystems/dimod/blob/25065ad8d30154098f55d827022b815421822864/dimod/core/sampler.py#L200-L205
Possibilities for addressing this include:
- Deprecating the use of a list for `h` in `sample_ising` (altogether or just for `DWaveSampler`?) Con: may still be value in allowing it from memory efficiency perspective.
- Propagate a warning
- Raise an exception. This would be more consistent with the behavior when `h` is a dict, and it matches the docstring of the original behavior.
Original docstring:
```
*h* --- List or tuple of the linear Ising coefficients. The
:math:`h` value of a non-working qubit must be zero or an
exception will be raised. Inactive qubits are disabled during
annealing and cannot distinguish their states.
```
Relevant code in `DWaveSampler`:
https://github.com/dwavesystems/dwave-system/blob/bedfe5143a8579348be07e4ef5e8fe0646ce81ff/dwave/system/samplers/dwave_sampler.py#L365-L375
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.