Skip to content

Conversation

@chrishalcrow
Copy link
Member

Fixes #4328

To compute unit locations, you need to loop over templates. This PR ensures that the templates are ordered in the same way as the user-inputted unit ids if they are given.

Added a test to the common_extension_tests, but it only applies to extensions which allow for the user to input unit_ids. Turns out: this is just unit locations. I still think it's a new place to put the test?

@chrishalcrow chrishalcrow added bug Something isn't working postprocessing Related to postprocessing module labels Jan 19, 2026
unit_ids = sorting_analyzer_or_templates.unit_ids
else:
unit_ids = np.asanyarray(unit_ids)
keep = np.isin(sorting_analyzer_or_templates.unit_ids, unit_ids)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer a syntax with units_to_indices(unit_ids), but maybe this would require to implement such a function for the Templates

unit_ids = np.asanyarray(unit_ids)
keep = np.isin(sorting_analyzer_or_templates.unit_ids, unit_ids)
templates = templates[keep, :, :]
keep = [np.where(sorting_analyzer_or_templates.unit_ids == unit_id)[0][0] for unit_id in unit_ids]
Copy link
Member

@alejoe91 alejoe91 Jan 20, 2026

Choose a reason for hiding this comment

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

Suggested change
keep = [np.where(sorting_analyzer_or_templates.unit_ids == unit_id)[0][0] for unit_id in unit_ids]
unit_ids = list(sorting_analyzer_or_templates.unit_ids)
keep_unit_indices = np.array([unit_ids.index(unit_id) for unit_id in unit_ids])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working postprocessing Related to postprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Computation of unit_locations doesn't respect unit_id order

3 participants