Skip to content

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

@JoelPasvolsky

Description

@JoelPasvolsky

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions