spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

Change default `durations` argument from list in `generate.py`

Open JoeZiminski opened this issue 2 years ago • 2 comments

Just leaving here so I don't forget, happy to make a PR on this. Some of the default arguments for functions in generate.py are mutable, which is not reccomended due to pythons crazy behaviour. These could be changed to None and the default value set in the body of the function.

JoeZiminski avatar Dec 15 '23 16:12 JoeZiminski

Yeah, I noticed that too recently. This is a common mistake that people make in Python. Altought we don't really mutate those lists is would be a good practice to change it. A good heuristic to remember this is that default values are values (not expressions).

I made one for the other instances of this pattern in #2345.

h-mayorquin avatar Dec 18 '23 08:12 h-mayorquin

This discussion came up again:

https://github.com/SpikeInterface/spikeinterface/pull/2777

@alejoe91 really wanted to move forward with this, @samuelgarcia supported the idea of using tuples or copying the list at the beginning of the function.

h-mayorquin avatar May 16 '24 02:05 h-mayorquin