Accept recording= consistently in detect_and_remove_bad_channels, depth_order and average_across_direction - #4779
Conversation
…th_order and average_across_direction
| recording: BaseRecording | None = None, | ||
| direction: str = "y", | ||
| dtype="float32", | ||
| parent_recording: BaseRecording | None = None, |
There was a problem hiding this comment.
we don't need to keep this. We have a mechanism to modify kwargs on-the-fly on load and it specifically to handle these kind of API changes.
I'll push the changes here directly!
|
@JESUSROYETH thanks you! We definitely need to fix it, but we have an internal mechanism to remap kwagrs before loading called In my last commit 0b40414, I modified the implementation to use it, and also extended it to As we are doing a major release, we can just drop the legacy argument IMO. @chrishalcrow @samuelgarcia do you agree? Note that both |
detect_and_remove_bad_channels(recording=rec)— the example indoc/modules/preprocessing.rst— raisesTypeError: DetectAndRemoveBadChannelsRecording.__init__() missing 1 required positional argument: 'parent_recording'. Same fordepth_orderandaverage_across_direction, different message. All three work fine called positionally, probably why this went unnoticed.Cause: these three classes name their first
__init__argumentparent_recording, while every other preprocessing class (and the dispatcher that builds the public function,core_tools.py) expectsrecording.Fix: rename to
recordingin all three, matching the rest of the module.parent_recordingstays accepted permanently, not deprecated — it's the literal keyChannelSliceRecording(and these classes) already use to serialize_kwargs, so recordings saved by older versions still reload withparent_recording=. Put the alias in the__init__s rather thanfrom_dictor the dispatcher so direct construction keeps working too, not just deserialisation — happy to move it if you'd rather handle it differently.Added a
recording=test per function plus one for the resolver helper (fail onmain, pass with the patch), and afrom_dictround-trip test per function using the legacy name (passes onmaintoo, by design — shows the fix doesn't break loading old recordings). Local preprocessing suite: 268 passed, no regressions.Fixes #4744.