spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

Move towards making set_probe in place by default

Open h-mayorquin opened this issue 1 year ago • 12 comments

Should fix https://github.com/SpikeInterface/spikeinterface/issues/2193

h-mayorquin avatar May 03 '24 01:05 h-mayorquin

Personally I don't mind if it returns a recording (for API consistency) or sets in place. But if it returns a recording I think it should be renamed from set_probe because that implies (to me at least) an in-place operation.

For probe vs. probegroup I would agree it makes sense to reflect the general existing API here too. If wanting to change in future, it is easier to take a single-decision to merge these concepts at a higher level and change all instances at once.

JoeZiminski avatar May 03 '24 11:05 JoeZiminski

set_probe because that implies (to me at least) an in-place operation.

Joe's comment actually reminded me the point of set so I've changed my mind. set should be in_place so I retract my previous statement.

For probe vs. probegroup I would agree it makes sense to reflect the general existing API here too. If wanting to change in future, it is easier to take a single-decision to merge these concepts at a higher level and change all instances at once.

Yep exactly!

zm711 avatar May 03 '24 12:05 zm711

As mentioned above, there are two functions set_probe and set_probes, it seems that set_probes is more general. I suggest opening another issue if we want to discuss the probe setting API. The aim of this is just to change the functions to be in place.

Am I missing something?

h-mayorquin avatar May 03 '24 14:05 h-mayorquin

I was referring to the new function you made called create_with_probes, which is part of this api. But let me see if I can find the function set_probes. My point was actually that I would prefer

create_with_probe create_with_probegroup

to mimic the functions I normally use set_probe and set_probegroup. I have never seen the set_probes function.

zm711 avatar May 03 '24 14:05 zm711

See line 99 which internally uses set_probes. I assumed maybe wrongly that set_probe and set_probegroup the only public "right way" to set a probe vs a probegroup.

zm711 avatar May 03 '24 15:05 zm711

All the functions are public so I think you would have to ask @samuelgarcia and @alejoe91 what is the "right way" (intendend) that they envisioned or want. Usually they prefer general functions that handle a bunch of cases (see that they prefer to use recording.save() vs recording.save_to_* () and in general I see them adding keyword to functions instead of creating a function for a different behavior) so I did in this way. I agree with you that the creation functions should mimick the setting functions once we decide on the right way.

h-mayorquin avatar May 03 '24 15:05 h-mayorquin

Agreed. I don't think I've ever seen us document set_probes which is what I meant by "right way", but as you said it is a public function so people could use. Happy to wait to see what they say.

zm711 avatar May 03 '24 15:05 zm711

Agreed. I don't think I've ever seen us document set_probes which is what I meant by "right way", but as you said it is a public function so people could use. Happy to wait to see what they say.

Looking the code base it seems that set_probe and set_probes are more commonly used on the tests. I only see one use case of set_probes.

h-mayorquin avatar May 03 '24 15:05 h-mayorquin

I just searched the docs and set_probe is mentioned like 5 times. set_probegroup is mentioned once and set_probes is never mentioned (again based on the search function).

zm711 avatar May 03 '24 15:05 zm711

Which search function are you using?

I searched before the claim above. The one use case is here and by someone that is not "us":

https://github.com/h-mayorquin/spikeinterface/blob/4f4fafb96382676c63949647b172ee013f35a290/src/spikeinterface/extractors/neoextractors/spikegadgets.py#L43-L44

h-mayorquin avatar May 03 '24 15:05 h-mayorquin

The search function on readthedocs. I'm talking about rtd documentation.

zm711 avatar May 03 '24 15:05 zm711

Got you. I think the evidence points in the direction of your claim, though. I will make these two methods. I think we probably should make the most general method set_probes private but that's probably another issue / PR.

h-mayorquin avatar May 03 '24 15:05 h-mayorquin

Another issue here: https://github.com/SpikeInterface/spikeinterface/issues/2895

alejoe91 avatar May 22 '24 13:05 alejoe91