Skip to content

Commit

Permalink
Merge pull request #37 from arcondello/dimod_vartype_decorator
Browse files Browse the repository at this point in the history
Dimod vartype decorator
  • Loading branch information
arcondello authored Mar 14, 2018
2 parents 28050aa + 49aead8 commit e0141f0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
15 changes: 3 additions & 12 deletions penaltymodel/classes/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import networkx as nx

from dimod import BinaryQuadraticModel, Vartype
import dimod
from dimod import BinaryQuadraticModel
from six import itervalues, iteritems, iterkeys


Expand Down Expand Up @@ -116,6 +117,7 @@ class Specification(object):
interaction - there is an edge between nodes u, v in `graph`.
"""
@dimod.vartype_argument('vartype')
def __init__(self, graph, decision_variables, feasible_configurations, vartype,
ising_linear_ranges=None,
ising_quadratic_ranges=None):
Expand Down Expand Up @@ -169,17 +171,6 @@ def __init__(self, graph, decision_variables, feasible_configurations, vartype,
#
# vartype
#
try:
if isinstance(vartype, str):
vartype = Vartype[vartype]
else:
vartype = Vartype(vartype)
if not (vartype is Vartype.SPIN or vartype is Vartype.BINARY):
raise ValueError
except (ValueError, KeyError):
raise TypeError(("expected input vartype to be one of: "
"Vartype.SPIN, 'SPIN', {-1, 1}, "
"Vartype.BINARY, 'BINARY', or {0, 1}."))
# check that our feasible configurations match
seen_variable_types = set().union(*feasible_configurations)
if not seen_variable_types.issubset(vartype.value):
Expand Down
2 changes: 1 addition & 1 deletion penaltymodel/package_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.13.0'
__version__ = '0.13.1'
__author__ = 'D-Wave Systems Inc.'
__authoremail__ = '[email protected]'
__description__ = 'Utilities and interfaces for using penalty models.'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dimod==0.6.0
dimod==0.6.3
six==1.11.0
networkx==2.0
enum34==1.1.6
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from penaltymodel.package_info import __version__, __author__, __description__, __authoremail__

install_requires = ['dimod>=0.6.0,<0.7.0',
install_requires = ['dimod>=0.6.3,<0.7.0',
'six>=1.11.0,<2.0.0',
'networkx>=2.0,<3.0',
'enum34>=1.1.6,<2.0.0']
Expand Down

0 comments on commit e0141f0

Please sign in to comment.