def push(self, name, var):
# Convert np.ndarrays into matlab.doubles and push into the workspace
if type(var) is np.ndarray:
self._eng.workspace[name] = self._matarray(var.tolist())
elif type(var) is dict:
var_copy = var.copy()
for k, v in var_copy.iteritems():
if type(v) is np.ndarray:
var_copy[k] = self._matarray(v.tolist())
self._eng.workspace[name] = var_copy
elif type(var) in {list, int, float}:
self._eng.workspace[name] = var
else:
raise ValueError("Unknown type (%s) variable being pushed "
"into the MATLAB session." % type(var))
评论列表
文章目录