|
16 | 16 |
|
17 | 17 | import json |
18 | 18 |
|
19 | | -import collections.abc |
20 | 19 | import numpy as np |
21 | 20 |
|
22 | 21 | from cython.operator cimport typeid |
@@ -59,6 +58,8 @@ cdef vector[NumberNode.BoundAxisInfo] _convert_python_bound_axes( |
59 | 58 | cdef double[:] mem |
60 | 59 |
|
61 | 60 | for bound_axis_data in bound_axes_data: |
| 61 | + # We allow lists and tuples because the _from_zipfile method yields |
| 62 | + # a list of lists not a list of tuples. |
62 | 63 | if not isinstance(bound_axis_data, (tuple, list)) or len(bound_axis_data) != 3: |
63 | 64 | raise TypeError("Each bound axis entry must be a tuple or list with" |
64 | 65 | " three elements: axis, operator(s), bound(s)") |
@@ -199,6 +200,7 @@ cdef class BinaryVariable(ArraySymbol): |
199 | 200 | subject_to = None |
200 | 201 | else: |
201 | 202 | with zf.open(info, "r") as f: |
| 203 | + # Note that import is a list of lists, not a list of tuples |
202 | 204 | subject_to = json.load(f) |
203 | 205 |
|
204 | 206 | return BinaryVariable(model, |
@@ -231,6 +233,7 @@ cdef class BinaryVariable(ArraySymbol): |
231 | 233 |
|
232 | 234 | subject_to = self.axis_wise_bounds() |
233 | 235 | if len(subject_to) > 0: |
| 236 | + # Using json here converts the tuples to lists |
234 | 237 | zf.writestr(directory + "subject_to.json", encoder.encode(subject_to)) |
235 | 238 |
|
236 | 239 | def axis_wise_bounds(self): |
@@ -404,6 +407,7 @@ cdef class IntegerVariable(ArraySymbol): |
404 | 407 | subject_to = None |
405 | 408 | else: |
406 | 409 | with zf.open(info, "r") as f: |
| 410 | + # Note that import is a list of lists, not a list of tuples |
407 | 411 | subject_to = json.load(f) |
408 | 412 |
|
409 | 413 | return IntegerVariable(model, |
@@ -442,6 +446,7 @@ cdef class IntegerVariable(ArraySymbol): |
442 | 446 |
|
443 | 447 | subject_to = self.axis_wise_bounds() |
444 | 448 | if len(subject_to) > 0: |
| 449 | + # Using json here converts the tuples to lists |
445 | 450 | zf.writestr(directory + "subject_to.json", encoder.encode(subject_to)) |
446 | 451 |
|
447 | 452 | def axis_wise_bounds(self): |
|
0 commit comments