OK, there’s the error message and then there’s something else that’s unrelated and will make this not work, so let’s try to tackle both at once.
The error message I played around with, it’s coming from ‘word_{}’.format(). I think that the javascript translator doesn’t know how to handle the string.format function. Happily, you can work around it pretty easily:
trials.addData('word_'+str(rts), rtList[rts])
It should stop giving you the error at that point and produce some javascript, but I can tell you now it won’t work if you tried to run it online. ediff1d is a numpy function, but you don’t import numpy, and you will not be able to import numpy when you convert the code to javascript (import statements don’t work in javascript, and numpy is python-specific). So you’ll need to fix that as well.
Looking at what ediff1d does, I think your best bet may be to manually recreate what the function is doing. In python that would look like this:
rtList2 = [] # Creating a new list to take the results
for x in range(len(rtList)-1):
# This cycles through the array without getting an out-of-range error on the last one.
rtList2.append(rtList[x+1] - rtList[x])
rtList = rtList2
trials.addData('senLen', len(rtList))
for rts in range(len(rtList)):
trials.addData('word_'+str(rts), rtList[rts])
That should convert to javascript, and hopefully it will work when you try to run it as well.