Python to Java translation seems to be busted!

OS: Win 10
PsychoPy Version: 2020.2.10
Standalone

Dear all,

I am trying to run my experiment on Pavlovia.org (Chrome Browser). The experiment works fine on PsychoPy (was programmed in Builder), but fails at almost every unique line within the Code components. This problem seems to stem from incorrect translation between Python and JS.

Here is the link to the experiment: https://pavlovia.org/hakankarsilar/strooptask_psy329_hk

Some problematic functions I have identified are:

  • sum
  • .append
  • empty lists (e.g. accuracy=[])
  • .format

I tried manually changing the JS code on a few lines but overall the whole translation seems to be faulty, and after a while I am either trying to write the whole thing in JS (which I am not proficient in), or foregoing too much functionality of my experiment.

Has this been the case for a while or is it the result of a recent update? I hadn’t been running into these types of problems before.

I am teaching a class on PsychoPy and my students are scheduled to collect online data starting next week. I am hoping that this Python–> JS translation problem can be solved by then? Otherwise we are in big trouble :slight_smile:

Best,
Hakan

Hey Hakan,

I played around bit with the auto-translation, and I confirm it doesn’t convert well for sum, append, and format. I’m not sure what the issue is with an empty list; that one seems to convert as I’d expect.

The annoying thing is that many of these functions are named differently in JS, and while we’re trying to cover such cases, it’s quite a project :). Let me tag @sotiri; he might find the cases you found interesting.

Good luck the course and sorry for the inconvenience!

Best, Thomas

Hi Hakan, do check the cribsheet for JS to Python translation: https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit#

Some functions are named different in JS or they are functions which work differently than their Python counterparts.

For some functions you may need to re-write their Python counterparts in JS to attain full functionality. For some however, they have counterparts with different names. For example, .push in place of .append.

Your students will need to check the cribsheet linked above for the proper translation of python to JS.

1 Like