|
111 | 111 | ' # should be kept in sync with the same function' |
112 | 112 | ' # defined in inst/private/python_header.py' |
113 | 113 | ' sys.stderr.write("pydebug: " + str(l) + "\n")' |
| 114 | + '# begin: 2D sym funcs' |
| 115 | + '# 2D sym funcs defined in inst/private/python_ipc_native.m' |
| 116 | + '# and inst/private/python_header.py should be kept in sync' |
114 | 117 | 'def make_2d_sym(it_of_it, dbg_matrix_only=False):' |
115 | | - ' # should be kept in sync with the same function' |
116 | | - ' # defined in inst/private/python_header.py' |
117 | 118 | ' # FIXME: dbg_matrix_only is used for debugging, remove' |
118 | 119 | ' # it once sympy drops non-Expr support in Matrix' |
119 | 120 | ' """' |
|
129 | 130 | ' return Matrix(ls_of_ls)' |
130 | 131 | ' else:' |
131 | 132 | ' dbout(f"make_2d_sym: constructing 2D sym...")' |
| 133 | + ' # FIXME: should we use Array or TableForm?' |
132 | 134 | ' return Array(ls_of_ls)' |
| 135 | + 'def is_2d_sym(x):' |
| 136 | + ' types = (MatrixBase, NDimArray, TableForm)' |
| 137 | + ' return isinstance(x, types)' |
| 138 | + 'def is_matrix(x):' |
| 139 | + ' return isinstance(x, MatrixBase)' |
| 140 | + 'def is_non_matrix_2d_sym(x):' |
| 141 | + ' return isinstance(x, (NDimArray, TableForm))' |
| 142 | + 'def list_from_2d_sym(X):' |
| 143 | + ' if isinstance(X, TableForm):' |
| 144 | + ' return [[x for x in tup] for tup in X._lines]' |
| 145 | + ' else:' |
| 146 | + ' return X.tolist()' |
| 147 | + 'def shape_of_2d_sym(X):' |
| 148 | + ' if isinstance(X, TableForm):' |
| 149 | + ' return (X._h, X._w)' |
| 150 | + ' else:' |
| 151 | + ' return X.shape' |
| 152 | + '# end: 2D sym funcs' |
133 | 153 | }, newl)) |
134 | 154 | have_headers = true; |
135 | 155 | end |
|
0 commit comments