Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove set to range optimization #90

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/minizinc/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def transform_enum_object(self, obj):
def mzn_object_hook(self, obj):
if isinstance(obj, dict):
if len(obj) == 1 and "set" in obj:
if len(obj["set"]) == 1 and isinstance(obj["set"][0], list):
assert len(obj["set"][0]) == 2
return range(obj["set"][0][0], obj["set"][0][1] + 1)

li = []
for item in obj["set"]:
if isinstance(item, list):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_non_ascii(self):


class TestSets(InstanceTestCase):
def test_ranges(self):
def test_sets(self):
self.instance.add_string(
"""
var set of 0..10: s;
Expand All @@ -163,8 +163,8 @@ def test_ranges(self):

self.instance["s1"] = range(1, 4)
result = self.instance.solve()
assert isinstance(result["s"], range)
assert result["s"] == range(1, 4)
assert isinstance(result["s"], set)
assert result["s"] == set(range(1, 4))


class TestString(InstanceTestCase):
Expand Down
Loading