|
11 | 11 | def numpy_repr(a): |
12 | 12 | """ A numpy repr without summarization """ |
13 | 13 | opts = np.get_printoptions() |
| 14 | + # avoid numpy repr as it changes between versions |
| 15 | + # TODO handle numpy repr differences |
| 16 | + if isinstance(a, np.ndarray): |
| 17 | + return "array(" + repr(list(a)) + ")" |
14 | 18 | try: |
15 | 19 | np.set_printoptions(threshold=10**10) |
16 | 20 | return repr(a) |
17 | 21 | finally: |
18 | 22 | np.set_printoptions(**opts) |
19 | 23 |
|
20 | 24 |
|
| 25 | +def numpy_repr_int(a): |
| 26 | + # avoid numpy repr as it changes between versions |
| 27 | + # TODO handle numpy repr differences |
| 28 | + return "array(" + repr(list(a)) + ", dtype='int')" |
| 29 | + |
| 30 | + |
21 | 31 | def compress_if_all_same(l): |
22 | 32 | s = set(l) |
23 | 33 | return s.pop() if len(s) == 1 else l |
@@ -113,7 +123,7 @@ def do_colors(code, data_column, show, name): |
113 | 123 |
|
114 | 124 | code.append("{} = {}".format(name, repr(colors))) |
115 | 125 | if index is not None: |
116 | | - code.append("{}_index = {}".format(name, repr(index))) |
| 126 | + code.append("{}_index = {}".format(name, numpy_repr_int(index))) |
117 | 127 |
|
118 | 128 | decompresssed_code = name |
119 | 129 | if index is not None: |
@@ -153,7 +163,7 @@ def matplotlib_marker(m): |
153 | 163 | if np.all(indices == np.arange(x.shape[0])): |
154 | 164 | indices = None |
155 | 165 | if indices is not None: |
156 | | - code.append("indices = {}".format(numpy_repr(indices))) |
| 166 | + code.append("indices = {}".format(numpy_repr_int(indices))) |
157 | 167 |
|
158 | 168 | def indexed(data, data_name, indices=indices): |
159 | 169 | return code_with_indices(data, data_name, indices, "indices") |
|
0 commit comments