DataMatrix modification in a loop is not propagated
If you fill out the information below, we will be able to help you better. 😎 You can also consider asking SigmundAI.eu, our AI assistant with expert knowledge of OpenSesame.
OpenSesame version
[e.g. 4.0.24]
If you are running an online experiment, also provide the version of OSWeb, which is shown when you launch an experiment in a browser. We regularly fix bugs, so always make sure that you are running the latest version of OpenSesame and other relevant packages.
Operating system
[e.g. Windows 10 / macOS Ventura / Ubuntu 22.04]
If you are running an online experiment, also provide the browser version.
Backend
[PsychoPy / Expyriment / legacy / OSWeb]
You can find the backend under "General Properties / Run experiment".
Expected behavior
[e.g. "The experiment should play two sounds."]
Clearly explain what you would like to happen.
Actual behavior (what goes wrong)
[e.g. "The experiment only plays one sound."]
Clearly explain what happens, and in what way this deviates from what you would like to happen.
Error messages (if any)
[Error message here]
Copy-paste the full error message from the console output at the bottom of the OpenSesame window (for the desktop version) or from the browser console (for OSWeb). You can also attach a screenshot.
What did you try already?
[e.g. "I changed the backend, but it didn't help."]
Did you already reinstall OpenSesame, change the backend, check for similar issues on the forum, ask SigmundAI, or try anything else.?
Experiment file (optional)
Consider attaching attaching your .osexp file. If you do not want to share your experiment file, you can also attach a minimal version of the experiment that illustrates the issue.
Comments
Hello,
Modifications to a DataMatrix performed inside a loop are not reflected after the loop ends, even though the DataMatrix object remains the same (id() is unchanged). This suggests a context isolation or state persistence issue in the execution engine.
Example: A DataMatrix named dm is created in an inline script (outside the loop), with a column value initialized as [10, 20, 30]. A variable dm_index controls a loop called display_loop that displays dm.value[dm_index] in a feedback item. When dm_index == 2, modifies dm.value[1] = 50. Increments dm_index. After the loop, another feedback screen attempts to display dm.value[1].
Expected behavior: the final feedback should display 50, the value assigned during the loop. Observed behavior: the final feedback displays 20, the original value before modification — even though: dm.value[1] = 50 is printed correctly during the loop; id(dm) before and after the loop confirms the object is unchanged.
OpenSesame appears to retain a shared reference to the DataMatrix object across components but does not propagate in-place modifications made inside loops to the global context.
Gérard