Skip to content

Commit 88f9895

Browse files
committed
Fix support for string types
1 parent 50ee1eb commit 88f9895

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ this project adheres to `Semantic Versioning <https://semver.org/>`_.
99
Unreleased_
1010
------------
1111

12+
0.3.2_ - 2020-08-14
13+
-------------------
14+
15+
Fixed
16+
^^^^^
17+
- Add full support for string input and output. The usage of strings would
18+
previously incorrectly give a warning.
19+
1220
0.3.1_ - 2020-07-21
1321
-------------------
1422

src/minizinc/CLI/driver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def to_python_type(mzn_type: dict) -> Type:
4141
pytype = float
4242
elif basetype == "int":
4343
pytype = int
44+
elif basetype == "string":
45+
pytype = str
4446
else:
4547
warnings.warn(
4648
f"Unable to determine minizinc type `{basetype}` assuming integer type",

tests/test_types.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,18 @@ def test_ranges(self):
8282
result = self.instance.solve()
8383
assert isinstance(result["s"], range)
8484
assert result["s"] == range(1, 4)
85+
86+
87+
class TestString(InstanceTestCase):
88+
code = """
89+
array[int] of string: names;
90+
var index_set(names): x;
91+
string: name ::output_only ::add_to_output = names[fix(x)];
92+
"""
93+
94+
def test_string(self):
95+
names = ["Guido", "Peter"]
96+
self.instance["names"] = names
97+
98+
result = self.instance.solve()
99+
assert result.solution.name in names

0 commit comments

Comments
 (0)