dwavesystems / dwavesystems/dwave-optimization

Consider returning a TypeError for ``.has_state()`` for state size 0

Open
#484 2 comments 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
C++
Stars
31
Forks
36
Avg merge
16h 55m
Merged PRs (30d)
8

Description

Currently returns a ValueError with a technically correct but not hugely helpful error message:

```
>>> from dwave.optimization import Model
>>> model = Model()
>>> i = model.integer(3, lower_bound=0, upper_bound=20)
>>> i.has_state()
ValueError: index out of range: 0
```

Would it make sense to capture the ``model.states.size() == 0`` condition and if zero, return a TypeError with an explicit error message?

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.