If I have an array of values, can I write it to the Script CHOP’s output in one line rather than a for-loop?
This code is fairly slow (2.5 ms), but everything before the for-loop only takes .18 ms. I hope it could be faster somehow.
import numpy as np
scriptOp.clear()
num_points = 1000
deg = np.linspace(0, math.pi*2, num=num_points)
#print(deg.shape)
data = np.stack([np.cos(deg), np.sin(deg), np.zeros(num_points)], axis=-1)
#print(data.shape)
scriptOp.appendChan('x')
scriptOp.appendChan('y')
scriptOp.appendChan('z')
scriptOp.numSamples = data.shape[0]
## I want this to work as a faster alternative to the for-loop below
#x_values = data[:, 0]
#scriptOp['x'] = x_values
for i, (x, y, z) in enumerate(data):
scriptOp['x'][i] = x.item()
scriptOp['y'][i] = y.item()
scriptOp['z'][i] = z.item()