`RDMs.sort_by()` take a `reindex` boolean argument to replace the `"index"` pattern descriptor
caiw opened this issue · comments
I just became rather confused because RDMs.sort_by()
followed by RDMs.subset_patterns(by="index", ...)
didn't have the expected effect. In other words, sorting the conditions also sorts .pattern_descriptors["index"]
, so then .subset_patterns(by="index", ...)
doesn't subset the patterns by their current indices, but by their indices prior to sorting.
I'm sure there are many cases where it makes sense to sort the "index"
pattern descriptor too, but in my case it'd be useful to automatically keep the patterns with an incremental index. I propose RDMs.sort_by()
takes a new boolean argument reindex
(default False
), which when True
resets the "index"
pattern descriptor to 0, 1, ..., n_cond-1.
Is there a reason or current usage of the "index"
pattern descriptor which would make this problematic?
I'm happy to implement this, but thought it worth the discussion first.
I think this makes sense. Maybe the reindex
argument should even be True
by default. We could throw a deprecation warning.
sort_by()
takes pattern_descriptors in the form of kwargs. This means if the RDMs
object happens to have a pattern_descriptor
named "reindex"
, we may have a conflict. E.g. one couldn't specify RDMs.sort_by(reindex='alpha', reindex=False)
.