Skip to content

Centralize add_segment and segments to BaseExtractor#4462

Merged
alejoe91 merged 22 commits intoSpikeInterface:mainfrom
alejoe91:segments
Mar 26, 2026
Merged

Centralize add_segment and segments to BaseExtractor#4462
alejoe91 merged 22 commits intoSpikeInterface:mainfrom
alejoe91:segments

Conversation

@alejoe91
Copy link
Member

and fix a bunch of typing errors

Pulled out of #4216

@alejoe91 alejoe91 added this to the 0.105.0 milestone Mar 23, 2026
@alejoe91 alejoe91 added the core Changes to core module label Mar 23, 2026
# we remove the annotation if it exists
_ = self._annotations.pop("name", None)

@property
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe for typing we could in BaseRecording for example:

  @property
  def segments(self) -> list[BaseRecordingSegment]:
      return self._segments  # type: ignore[return-value]

As that will enable the analysis of base recording sgements methods that we call on introspection with vscode and ohter tools. Same for bas sorting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can we make this private? what is the reason for making this public?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding it! I think it's handy to have it public. The segments are a big part of the API, so exposing them (as a property) doesn't hurt IMO

mode: "extremum" | "at_index" | "peak_to_peak" = "extremum",
peak_sign: Literal["neg", "pos", "both"] = "neg",
mode: Literal["extremum", "at_index", "peak_to_peak"] = "extremum",
operator: Literal["average", "median"] = "average",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of typing errors...

@samuelgarcia
Copy link
Member

I think I was more happy with the private approach
sorting._sorting_segments over sorting.segments
but this is OK for me.

And as @h-mayorquin
the property segment could be moved to Sorting and recording for handling the correct type.

So ok for merging.

@chrishalcrow : did you check this ?

Copy link
Member

@chrishalcrow chrishalcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok by me. Thanks for all the typing tidying :)

@alejoe91 alejoe91 merged commit 7a23584 into SpikeInterface:main Mar 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants