Skip to content

Commit

Permalink
v1.2.5 (#42)
Browse files Browse the repository at this point in the history
* incremented version

* Update test_subgraph.py

* Update _subgraph.py

* Update test_subgraph.py

* Update README.rst

* Update requirements-dev.txt
  • Loading branch information
jtiosue authored Aug 31, 2022
1 parent ecff35e commit 16f21d2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Create the boolean objective function to minimize
# create the variables
x = {i: boolean_var('x(%d)' % i) for i in range(N)}
# minimize \sum_{i=0}^{N-1} (1-2x_{i}) x_{i+1}
# minimize \sum_{i=0}^{N-2} (1-2x_{i}) x_{i+1}
model = 0
for i in range(N-1):
model += (1 - 2 * x[i]) * x[i+1]
Expand Down
2 changes: 1 addition & 1 deletion qubovert/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)


__version__ = "1.2.4"
__version__ = "1.2.5"
__author__ = "Joseph T. Iosue"
__authoremail__ = "[email protected]"
__license__ = "Apache Software License 2.0"
Expand Down
4 changes: 4 additions & 0 deletions qubovert/utils/_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def subgraph(G, nodes, connections=None):
value += D.get(key, 0)
if value:
D[key] = value
else:
D.pop(key, 0)

return D

Expand Down Expand Up @@ -134,5 +136,7 @@ def subvalue(values, G):
value += D.get(key, 0)
if value:
D[key] = value
else:
D.pop(key, 0)

return D
8 changes: 8 additions & 0 deletions tests/utils/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def test_subgraph():
with assert_raises(ValueError):
subgraph({0: 1, (0, 1): 1}, {})

# from Issue #38 in GitHub
G = {(2,): 1, (2, 3): -1}
assert subgraph(G, {2}, {3: 1}) == {}


def test_subvalue():

Expand All @@ -65,3 +69,7 @@ def test_subvalue():
# edge case
assert subvalue({}, G) == G
assert subvalue({0: 0, 1: 0, 2: 0}, G) == {(): 2}

# from Issue #38 in GitHub
G = {(2,): 1, (2, 3): -1}
assert subvalue({3: 1}, G) == {}

0 comments on commit 16f21d2

Please sign in to comment.