klabhub / neurostim

Design and run visual neuroscience experiments using Matlab and the Psychophysics Toolbox.
MIT License
5 stars 4 forks source link

Fix a plugin (re-)ordering bug (re: #200). #206

Closed cnuahs closed 2 years ago

cnuahs commented 2 years ago

This change fixes a bug introduced by commit 1988ab5 (re: #190) that causes any changes to the default plugin order, imposed in cic.run(), to be immediately reverted when handling adaptive plugins/parameters (see cic.handleAdaptives()).

This change removes the call to c.order(), which reverts the plugin order, in favour of using c.pluginOrder directly.

cnuahs commented 2 years ago

@Nicroburst, can you confirm that this change fixes the behaviour you were observing?

adammorrissirrommada commented 2 years ago

This fix is good, but I would advocate removing this behaviour of c.order(). It's too implicit, easy to accidentally and silently revert to default order, as was the case here.

Instead, some sort of argument that explicitly says "give me the default order please" would be good.

THis could have backwards compatibility issues for some scripts, possibly, though I doubt anyone uses c.order() with no args.

What do you think?

cnuahs commented 2 years ago

I agree. But maybe I'm the only one who is constantly tripped up by this c.order() business.

It would be more useful (I think) if c.order() (no args) returned the current plugin order, but made no changes... in effect {c.pluginOrder.name}, and you used c.order('default',true) to get the default order. c.order('plg1','plg2) would set the plugin order to the extent that the args define it.

There could be a separate argument to 'reset' the order to the default order, or maybe you just make two calls to c.order(), e.g., c.order(c.order('default',true))

Open question in my mind is whether c.order('plg1','plg2') should return the new order, or the old order (so you can restore it if desired). Is there any use case where that would be useful?

adammorrissirrommada commented 2 years ago

If c.order('default',true) set the order to the default order, there would be no need for the slightly odd double-call above? I am fine with c.order() returning current order, even if it does seem that we are mixing a setter and getter into the one thing (as is currently the case anyway)

adammorrissirrommada commented 2 years ago

You're definitely not the only one tripped up by the current form. That's how the bug was waved through in the first place, none of us saw it because the function's behaviour is impure and implicit.

Nicroburst commented 2 years ago

Yep, this fixes the behaviour I was seeing.